Merged in the latest changes from the trunk into the Polyplate branch
This commit is contained in:
parent
effa8189b1
commit
c69ea8815d
|
@ -198,7 +198,7 @@ seqComma :: [CGen ()] -> CGen ()
|
||||||
seqComma ps = sequence_ $ intersperse (tell [","]) ps
|
seqComma ps = sequence_ $ intersperse (tell [","]) ps
|
||||||
|
|
||||||
genLiteralRepr :: A.LiteralRepr -> CGen ()
|
genLiteralRepr :: A.LiteralRepr -> CGen ()
|
||||||
genLiteralRepr (A.ArrayLiteral _ elems)
|
genLiteralRepr (A.ArrayListLiteral _ (A.Several _ elems))
|
||||||
= do tell ["newListArray (0," ++ show (length elems - 1) ++ ") ["]
|
= do tell ["newListArray (0," ++ show (length elems - 1) ++ ") ["]
|
||||||
seqComma $ map genArrayElem elems
|
seqComma $ map genArrayElem elems
|
||||||
tell ["]"]
|
tell ["]"]
|
||||||
|
@ -226,8 +226,8 @@ convByte c
|
||||||
| otherwise = [c]
|
| otherwise = [c]
|
||||||
where o = ord c
|
where o = ord c
|
||||||
|
|
||||||
genArrayElem :: A.ArrayElem -> CGen ()
|
genArrayElem :: A.Structured A.Expression -> CGen ()
|
||||||
genArrayElem (A.ArrayElemExpr e) = genExpression e
|
genArrayElem (A.Only _ e) = genExpression e
|
||||||
genArrayElem _ = genMissing "genArrayElem"
|
genArrayElem _ = genMissing "genArrayElem"
|
||||||
|
|
||||||
genType :: A.Type -> CGen ()
|
genType :: A.Type -> CGen ()
|
||||||
|
|
|
@ -241,6 +241,7 @@ instance ShowOccam A.Type where
|
||||||
showOccamM A.Any = tell ["ANY"]
|
showOccamM A.Any = tell ["ANY"]
|
||||||
showOccamM (A.Timer _) = tell ["TIMER"]
|
showOccamM (A.Timer _) = tell ["TIMER"]
|
||||||
showOccamM A.Time = tell ["TIME"]
|
showOccamM A.Time = tell ["TIME"]
|
||||||
|
showOccamM A.Infer = tell ["inferred-type"]
|
||||||
showOccamM (A.UnknownVarType _ en)
|
showOccamM (A.UnknownVarType _ en)
|
||||||
= do tell ["(inferred type for: "]
|
= do tell ["(inferred type for: "]
|
||||||
either showName (tell . (:[]) . show) en
|
either showName (tell . (:[]) . show) en
|
||||||
|
|
|
@ -643,7 +643,6 @@ type InferTypeOps
|
||||||
`ExtOpMP` A.Expression
|
`ExtOpMP` A.Expression
|
||||||
`ExtOpMP` A.Dimension
|
`ExtOpMP` A.Dimension
|
||||||
`ExtOpMP` A.Subscript
|
`ExtOpMP` A.Subscript
|
||||||
`ExtOpMP` A.ArrayConstr
|
|
||||||
`ExtOpMP` A.Replicator
|
`ExtOpMP` A.Replicator
|
||||||
`ExtOpMP` A.Alternative
|
`ExtOpMP` A.Alternative
|
||||||
`ExtOpMP` A.InputMode
|
`ExtOpMP` A.InputMode
|
||||||
|
@ -658,6 +657,7 @@ inferTypes = occamOnlyPass "Infer types"
|
||||||
[Prop.inferredTypesRecorded]
|
[Prop.inferredTypesRecorded]
|
||||||
recurse
|
recurse
|
||||||
where
|
where
|
||||||
|
ops :: InferTypeOps
|
||||||
ops = baseOp
|
ops = baseOp
|
||||||
`extOp` doExpression
|
`extOp` doExpression
|
||||||
`extOp` doDimension
|
`extOp` doDimension
|
||||||
|
|
|
@ -145,7 +145,7 @@ removeAfter = pass "Convert AFTER to MINUS"
|
||||||
|
|
||||||
-- | For array literals that include other arrays, burst them into their
|
-- | For array literals that include other arrays, burst them into their
|
||||||
-- elements.
|
-- elements.
|
||||||
expandArrayLiterals :: PassOn A.ArrayElem
|
expandArrayLiterals :: PassOn (A.Structured A.Expression)
|
||||||
expandArrayLiterals = pass "Expand array literals"
|
expandArrayLiterals = pass "Expand array literals"
|
||||||
[Prop.expressionTypesChecked, Prop.processTypesChecked]
|
[Prop.expressionTypesChecked, Prop.processTypesChecked]
|
||||||
[Prop.arrayLiteralsExpanded]
|
[Prop.arrayLiteralsExpanded]
|
||||||
|
@ -189,7 +189,9 @@ expandArrayLiterals = pass "Expand array literals"
|
||||||
-- Therefore, we only need to pull up the counts for SEQ, PAR and ALT
|
-- Therefore, we only need to pull up the counts for SEQ, PAR and ALT
|
||||||
--
|
--
|
||||||
-- TODO for simplification, we could avoid pulling up replication counts that are known to be constants
|
-- TODO for simplification, we could avoid pulling up replication counts that are known to be constants
|
||||||
pullRepCounts :: Pass
|
--
|
||||||
|
-- TODO we should also pull up the step counts
|
||||||
|
pullRepCounts :: PassOn2 (A.Structured A.Process) (A.Structured A.Alternative)
|
||||||
pullRepCounts = pass "Pull up replicator counts for SEQs, PARs and ALTs"
|
pullRepCounts = pass "Pull up replicator counts for SEQs, PARs and ALTs"
|
||||||
(Prop.agg_namesDone ++ Prop.agg_typesDone)
|
(Prop.agg_namesDone ++ Prop.agg_typesDone)
|
||||||
[]
|
[]
|
||||||
|
@ -271,7 +273,7 @@ transformConstr = pass "Transform array constructors into initialisation code"
|
||||||
let body = specs $ A.Several m''
|
let body = specs $ A.Several m''
|
||||||
[ assignItem tInner indexVar repExp'
|
[ assignItem tInner indexVar repExp'
|
||||||
, incIndex ]
|
, incIndex ]
|
||||||
body' <- applyDepthSM doStructured body
|
body' <- applyBottomUpMS doStructured body
|
||||||
|
|
||||||
return $ declDest $ A.ProcThen m''
|
return $ declDest $ A.ProcThen m''
|
||||||
(A.Seq m'' $ A.Spec m'' indexVarSpec $
|
(A.Seq m'' $ A.Spec m'' indexVarSpec $
|
||||||
|
@ -332,6 +334,7 @@ transformConstr = pass "Transform array constructors into initialisation code"
|
||||||
|
|
||||||
type PullUpOps = ExtOpMSP BaseOp
|
type PullUpOps = ExtOpMSP BaseOp
|
||||||
`ExtOpMP` A.Process
|
`ExtOpMP` A.Process
|
||||||
|
`ExtOpMP` A.Structured A.Expression
|
||||||
`ExtOpMP` A.Specification
|
`ExtOpMP` A.Specification
|
||||||
`ExtOpMP` A.LiteralRepr
|
`ExtOpMP` A.LiteralRepr
|
||||||
`ExtOpMP` A.Expression
|
`ExtOpMP` A.Expression
|
||||||
|
@ -348,17 +351,18 @@ pullUp pullUpArraysInsideRecords = pass "Pull up definitions"
|
||||||
where
|
where
|
||||||
ops :: PullUpOps
|
ops :: PullUpOps
|
||||||
ops = baseOp
|
ops = baseOp
|
||||||
`extOpS` doStructured
|
`extOpMS` (ops, doStructured)
|
||||||
`extOp` doProcess
|
`extOpM` doProcess
|
||||||
`extOp` doSpecification
|
`extOpM` doRepArray
|
||||||
`extOp` doLiteralRepr
|
`extOpM` doSpecification
|
||||||
`extOp` doExpression
|
`extOpM` doLiteralRepr
|
||||||
`extOp` doVariable
|
`extOpM` doExpression
|
||||||
`extOp` doExpressionList
|
`extOpM` doVariable
|
||||||
recurse :: Recurse
|
`extOpM` doExpressionList
|
||||||
recurse = makeRecurse ops
|
recurse :: RecurseM PassM PullUpOps
|
||||||
descend :: Descend
|
recurse = makeRecurseM ops
|
||||||
descend = makeDescend ops
|
descend :: DescendM PassM PullUpOps
|
||||||
|
descend = makeDescendM ops
|
||||||
|
|
||||||
-- | When we encounter a Structured, create a new pulled items state,
|
-- | When we encounter a Structured, create a new pulled items state,
|
||||||
-- recurse over it, then apply whatever pulled items we found to it.
|
-- recurse over it, then apply whatever pulled items we found to it.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user