Fixed the pass that turns array constructors into replicated loops so that it handles nested array constructors and inner-procthens properly
cgtest80 now compiles and passes
This commit is contained in:
parent
4b3090b66a
commit
bf365ee41a
|
@ -227,13 +227,15 @@ transformConstr = pass "Transform array constructors into initialisation code"
|
||||||
-- to it:
|
-- to it:
|
||||||
modifyName n $ \nd -> nd {A.ndAbbrevMode = A.Original}
|
modifyName n $ \nd -> nd {A.ndAbbrevMode = A.Original}
|
||||||
|
|
||||||
|
let body = specs $ A.Several m''
|
||||||
|
[ assignItem tInner indexVar repExp'
|
||||||
|
, incrementIndex indexVar ]
|
||||||
|
body' <- applyDepthSM 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 $
|
||||||
A.Several m'' [assignIndex0 indexVar,
|
A.Several m'' [assignIndex0 indexVar,
|
||||||
replicateCode $ A.Only m'' $ A.Seq m'' $
|
replicateCode $ body'
|
||||||
specs $ A.Several m''
|
|
||||||
[ assignItem tInner indexVar repExp'
|
|
||||||
, incrementIndex indexVar ]
|
|
||||||
])
|
])
|
||||||
scope
|
scope
|
||||||
A.List {} ->
|
A.List {} ->
|
||||||
|
@ -242,11 +244,15 @@ transformConstr = pass "Transform array constructors into initialisation code"
|
||||||
scope
|
scope
|
||||||
_ -> diePC m $ formatCode "Unsupported type for array constructor: %" t
|
_ -> diePC m $ formatCode "Unsupported type for array constructor: %" t
|
||||||
where
|
where
|
||||||
|
-- Also strips ProcThen
|
||||||
stripSpecs :: A.Structured A.Expression -> (A.Structured A.Expression,
|
stripSpecs :: A.Structured A.Expression -> (A.Structured A.Expression,
|
||||||
A.Structured A.Process -> A.Structured A.Process)
|
A.Structured A.Process -> A.Structured A.Process)
|
||||||
stripSpecs (A.Spec m spec scope)
|
stripSpecs (A.Spec m spec scope)
|
||||||
= let (result, innerSpecs) = stripSpecs scope in
|
= let (result, innerSpecs) = stripSpecs scope in
|
||||||
(result, A.Spec m spec . innerSpecs)
|
(result, A.Spec m spec . innerSpecs)
|
||||||
|
stripSpecs (A.ProcThen m proc body)
|
||||||
|
= let (result, innerSpecs) = stripSpecs body in
|
||||||
|
(result, A.ProcThen m proc . innerSpecs)
|
||||||
stripSpecs se = (se, id)
|
stripSpecs se = (se, id)
|
||||||
|
|
||||||
declDest :: Data a => A.Structured a -> A.Structured a
|
declDest :: Data a => A.Structured a -> A.Structured a
|
||||||
|
|
Loading…
Reference in New Issue
Block a user