Altered transformEachRange to make it more straight-forward
This commit is contained in:
parent
713b5c3e5c
commit
ad7a76dace
|
@ -189,14 +189,10 @@ transformEachRange = doGeneric `ext1M` doStructured
|
||||||
|
|
||||||
doStructured :: Data a => A.Structured a -> PassM (A.Structured a)
|
doStructured :: Data a => A.Structured a -> PassM (A.Structured a)
|
||||||
doStructured (A.Rep repMeta (A.ForEach eachMeta loopVar (A.ExprConstr
|
doStructured (A.Rep repMeta (A.ForEach eachMeta loopVar (A.ExprConstr
|
||||||
_ (A.RangeConstr _ _ (A.Literal _ _ begin) (A.Literal _ _ end)))) body)
|
_ (A.RangeConstr _ _ begin end))) body)
|
||||||
= do body' <- doStructured body
|
= do body' <- doStructured body
|
||||||
-- TODO should probably not do mini-constant-folding here:
|
return $ A.Rep repMeta (A.For eachMeta loopVar begin
|
||||||
if (isJust $ checkIntegral begin) && (isJust $ checkIntegral end)
|
(addOne $ subExprs end begin)) body'
|
||||||
then return $ A.Rep repMeta (A.For eachMeta loopVar (A.Literal eachMeta A.Int begin)
|
|
||||||
(A.Literal eachMeta A.Int $ A.IntLiteral eachMeta $ show ((fromJust $ checkIntegral end) - (fromJust $ checkIntegral begin) + 1))
|
|
||||||
) body'
|
|
||||||
else dieP eachMeta "Items in range constructor (x..y) are not integer literals"
|
|
||||||
doStructured s = doGeneric s
|
doStructured s = doGeneric s
|
||||||
|
|
||||||
-- | A pass that changes all the Rain range constructor expressions into the more general array constructor expressions
|
-- | A pass that changes all the Rain range constructor expressions into the more general array constructor expressions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user