From d90f0aa68086522cd9a4255f152bab2a20e37b92 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 22 Aug 2007 17:03:47 +0000 Subject: [PATCH] Rain: corrected the transformation of foreach loops to use ValAbbrev when looping over an expression --- RainPassTest.hs | 3 ++- RainPasses.hs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/RainPassTest.hs b/RainPassTest.hs index 9c24a6b..1304909 100644 --- a/RainPassTest.hs +++ b/RainPassTest.hs @@ -74,7 +74,8 @@ testEachPass0 = testPassWithItemsStateCheck "testEachPass0" exp (transformEach o (tag4 A.For DontCare indexVar (intLiteral 0) (tag2 A.SizeVariable DontCare listVar)) (tag3 A.Spec DontCare (tag3 A.Specification DontCare (simpleName "c") - (tag4 A.Is DontCare A.Abbrev A.Byte + --ValAbbrev because we are abbreviating an expression: + (tag4 A.Is DontCare A.ValAbbrev A.Byte (tag3 A.SubscriptedVariable DontCare (tag2 A.Subscript DontCare (tag2 A.ExprVariable DontCare (tag2 A.Variable DontCare indexVar))) listVar diff --git a/RainPasses.hs b/RainPasses.hs index b620499..a02c74c 100644 --- a/RainPasses.hs +++ b/RainPasses.hs @@ -135,11 +135,11 @@ transformEach = everywhereM (mkM transformEach') where transformEach' :: A.Structured -> PassM A.Structured transformEach' (A.Rep m (A.ForEach m' loopVar loopExp) s) - = do (spec,var) <- case loopExp of - (A.ExprVariable _ v) -> return (id,v) + = do (spec,var,am) <- case loopExp of + (A.ExprVariable _ v) -> return (id,v,A.Abbrev) _ -> do t <- typeOfExpression loopExp spec@(A.Specification _ n' _) <- makeNonceIsExpr "loopVar" m t loopExp - return (A.Spec m spec,A.Variable m n') + return (A.Spec m spec,A.Variable m n',A.ValAbbrev) --spec is a function A.Structured -> A.Structured, var is an A.Variable loopVarType <- typeOfName loopVar @@ -148,7 +148,7 @@ transformEach = everywhereM (mkM transformEach') let newRep = A.For m' loopIndexName (intLiteral 0) (A.SizeVariable m' var) let s' = A.Spec m' (A.Specification m' loopVar - (A.Is m' A.Abbrev loopVarType + (A.Is m' am loopVarType (A.SubscriptedVariable m' (A.Subscript m' (A.ExprVariable m' (A.Variable m' loopIndexName))) var) ) )