From c1c73f91860aabb0041696db3b0586a5af0fa9c0 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 30 Mar 2009 15:32:38 +0000 Subject: [PATCH] Added constant-folding support for VariableSizes --- common/EvalConstants.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/EvalConstants.hs b/common/EvalConstants.hs index 0c64e7e..40bab93 100644 --- a/common/EvalConstants.hs +++ b/common/EvalConstants.hs @@ -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