Added constant-folding support for VariableSizes

This commit is contained in:
Neil Brown 2009-03-30 15:32:38 +00:00
parent 1144975abc
commit c1c73f9186

View File

@ -115,6 +115,16 @@ evalVariable (A.Variable m n)
evalVariable (A.SubscriptedVariable _ sub v) = evalVariable v >>= evalSubscript sub
evalVariable (A.DirectedVariable _ _ v) = evalVariable v
evalVariable (A.DerefVariable _ v) = evalVariable v
evalVariable (A.VariableSizes m v)
= do t <- astTypeOf v
case t of
A.Array ds _ -> sequence [case d of
A.Dimension e -> evalExpression e
A.UnknownDimension ->
throwError (Just m, "Unknown dimension")
| d <- ds] >>* OccArray
_ -> throwError (Just m, " variable not array")
evalIndex :: A.Expression -> EvalM Int
evalIndex e