diff --git a/fco2/AST.hs b/fco2/AST.hs index 5af5b99..b214173 100644 --- a/fco2/AST.hs +++ b/fco2/AST.hs @@ -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 diff --git a/fco2/GenerateC.hs b/fco2/GenerateC.hs index a58c206..d7a10be 100644 --- a/fco2/GenerateC.hs +++ b/fco2/GenerateC.hs @@ -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 diff --git a/fco2/Parse.hs b/fco2/Parse.hs index de48fcc..98698b0 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -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 diff --git a/fco2/Types.hs b/fco2/Types.hs index 4ed1745..af8b6eb 100644 --- a/fco2/Types.hs +++ b/fco2/Types.hs @@ -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