From f2c7bad3e2229c4ec5e3e61bd45d0e5d0c55b9dc Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 9 Feb 2009 12:14:01 +0000 Subject: [PATCH] Added a pass that turns directed subscripts into subscripted directed arrays, to make the usage checking easier --- frontends/OccamPasses.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontends/OccamPasses.hs b/frontends/OccamPasses.hs index d837d7c..4b0433f 100644 --- a/frontends/OccamPasses.hs +++ b/frontends/OccamPasses.hs @@ -45,6 +45,7 @@ occamPasses = , checkConstants , resolveAmbiguities , checkTypes + , pushUpDirections ] -- | Fixed the types of array constructors according to the replicator count @@ -146,4 +147,17 @@ checkConstants = occamOnlyPass "Check mandatory constants" return o doOption o = return o - +pushUpDirections :: Pass +pushUpDirections = occamOnlyPass "Push up direction specifiers on arrays" + [] [] + (applyDepthM doVariable) + where + doVariable :: Transform A.Variable + doVariable origV@(A.DirectedVariable m dir v) + = do t <- astTypeOf v + case (t, v) of + (A.Array {}, _) -> return origV + (_, A.SubscriptedVariable m sub v') -> + return $ A.SubscriptedVariable m sub $ A.DirectedVariable m dir v' + _ -> return origV + doVariable v = return v