Allow SIZE cs, where cs is an array of channels or timers or ports

This isn't in the occam2 ordered syntax, but it's very common in occam2 code,
so I assume it's not an intentional omission.
This commit is contained in:
Adam Sampson 2007-04-19 16:49:12 +00:00
parent 124cf8f433
commit 05aad0602c
4 changed files with 8 additions and 1 deletions

View File

@ -94,6 +94,7 @@ data Expression =
| MostNeg Meta Type
| SizeType Meta Type
| SizeExpr Meta Expression
| SizeVariable Meta Variable
| Conversion Meta ConversionMode Type Expression
| ExprVariable Meta Variable
| ExprLiteral Meta Literal

View File

@ -326,6 +326,9 @@ genExpression (A.MostNeg m t) = genTypeConstant "mostneg" t
genExpression (A.SizeExpr m e)
= do genExpression e
tell ["_sizes[0]"]
genExpression (A.SizeVariable m v)
= do genVariable v
tell ["_sizes[0]"]
genExpression (A.Conversion m cm t e) = genConversion cm t e
genExpression (A.ExprVariable m v) = genVariable v
genExpression (A.ExprLiteral m l) = genLiteral l

View File

@ -662,7 +662,8 @@ sizeExpr
= do m <- md
sSIZE
(try (do { t <- dataType; return $ A.SizeType m t })
<|> do { v <- operand; return $ A.SizeExpr m v })
<|> do { v <- operand; return $ A.SizeExpr m v }
<|> do { v <- channel <|> timer <|> port; return $ A.SizeVariable m v })
<?> "sizeExpr"
exprOfType :: A.Type -> OccParser A.Expression

View File

@ -89,6 +89,7 @@ typeOfExpression ps e
A.MostNeg m t -> Just t
A.SizeType m t -> Just A.Int
A.SizeExpr m t -> Just A.Int
A.SizeVariable m t -> Just A.Int
A.Conversion m cm t e -> Just t
A.ExprVariable m v -> typeOfVariable ps v
A.ExprLiteral m l -> typeOfLiteral ps l
@ -122,6 +123,7 @@ isConstExpression ps e
A.MostNeg m t -> True
A.SizeType m t -> True
A.SizeExpr m e -> isConstExpression ps e
A.SizeVariable m v -> isConstVariable ps v
A.Conversion m cm t e -> isConstExpression ps e
A.ExprVariable m v -> isConstVariable ps v
A.ExprLiteral m l -> isConstLiteral ps l