Added an AllSizesVariable item to the AST so that the backend inserts the right code for mobiles and non-mobiles
This commit is contained in:
parent
f5ce1c8f89
commit
65550b705e
|
@ -384,10 +384,10 @@ addSizesActualParameters = occamOnlyPass "Add array-size arrays to PROC calls"
|
|||
= do t <- astTypeOf v
|
||||
case t of
|
||||
A.Array ds _ ->
|
||||
return [a, A.ActualVariable $ sizes v]
|
||||
return [a, A.ActualExpression $ sizes v]
|
||||
_ -> return [a]
|
||||
where
|
||||
sizes (A.Variable m n) = A.Variable m (append_sizes n)
|
||||
sizes v@(A.Variable m _) = A.AllSizesVariable m v
|
||||
sizes (A.DerefVariable _ v) = sizes v
|
||||
sizes (A.DirectedVariable _ _ v) = sizes v
|
||||
sizes (A.SubscriptedVariable _ _ v) = sizes v
|
||||
|
|
|
@ -936,6 +936,20 @@ cgenExpression (A.SizeVariable m v)
|
|||
call genSizeSuffix (show n)
|
||||
A.List _ ->
|
||||
call genListSize v
|
||||
cgenExpression e@(A.AllSizesVariable m v)
|
||||
= case v of
|
||||
A.SubscriptedVariable {} -> call genMissing $ "genExpression" ++ show e
|
||||
A.DirectedVariable _ _ v' -> call genExpression $ A.AllSizesVariable m v'
|
||||
A.DerefVariable _ v' -> do call genVariable v'
|
||||
tell ["->dimensions"]
|
||||
A.Variable _ n -> do t <- astTypeOf v
|
||||
case t of
|
||||
A.Array {} -> do call genVariable v
|
||||
tell ["_sizes"]
|
||||
A.Mobile (A.Array {})
|
||||
-> do call genVariable v
|
||||
tell ["->dimensions"]
|
||||
_ -> call genMissing $ "genExpression" ++ show e
|
||||
cgenExpression (A.Conversion m cm t e) = call genConversion m cm t e
|
||||
cgenExpression (A.ExprVariable m v) = call genVariable v
|
||||
cgenExpression (A.Literal _ t lr) = call genLiteral lr t
|
||||
|
|
|
@ -415,6 +415,7 @@ instance ShowOccam A.Expression where
|
|||
showOccamM (A.SizeType _ t) = bracket $ tell ["SIZE "] >> showOccamM t
|
||||
showOccamM (A.SizeExpr _ e) = bracket $ tell ["SIZE "] >> showOccamM e
|
||||
showOccamM (A.SizeVariable _ v) = bracket $ tell ["SIZE "] >> showOccamM v
|
||||
showOccamM (A.AllSizesVariable _ v) = bracket $ tell ["SIZES "] >> showOccamM v
|
||||
showOccamM (A.Conversion _ cm t e) = bracket $ showOccamM t >> convOrSpace cm >> showOccamM e
|
||||
showOccamM (A.ExprVariable _ v) = showOccamM v
|
||||
showOccamM (A.Literal _ _ lit) = showOccamM lit
|
||||
|
@ -427,7 +428,7 @@ instance ShowOccam A.Expression where
|
|||
showOccamM (A.BytesInType _ t) = bracket $ tell ["BYTESIN "] >> showOccamM t
|
||||
showOccamM (A.OffsetOf _ t n) = tell ["OFFSETOF("] >> showOccamM t >> tell [" , "] >> showName n >> tell [")"]
|
||||
showOccamM (A.AllocMobile _ t me) = showOccamM t >> maybe (return ()) showOccamM me
|
||||
|
||||
showOccamM (A.CloneMobile _ e) = tell["CLONE "] >> showOccamM e
|
||||
|
||||
instance ShowRain A.Expression where
|
||||
showRainM (A.Monadic _ op e) = bracket $ showRainM op >> space >> showRainM e
|
||||
|
|
|
@ -263,6 +263,9 @@ data Expression =
|
|||
-- | The size of the outermost dimension of an array variable (see
|
||||
-- 'SizeExpr').
|
||||
| SizeVariable Meta Variable
|
||||
-- | An array that contains all the dimensions of an array. Hence this is different
|
||||
-- from SizeVariable which is only the outermost dimension.
|
||||
| AllSizesVariable Meta Variable
|
||||
| Conversion Meta ConversionMode Type Expression
|
||||
| ExprVariable Meta Variable
|
||||
| Literal Meta Type LiteralRepr
|
||||
|
|
Loading…
Reference in New Issue
Block a user