improve stmt representation

This commit is contained in:
Zachary Snow
2020-06-09 21:18:31 -04:00
parent 2f5b746e27
commit 9adb7522e9
5 changed files with 43 additions and 45 deletions
+3 -3
View File
@@ -22,9 +22,9 @@ convertStmt :: Stmt -> Stmt
convertStmt (Foreach x idxs stmt) =
(foldl (.) id $ map toLoop $ zip [1..] idxs) stmt
where
toLoop :: (Int, Maybe Identifier) -> (Stmt -> Stmt)
toLoop (_, Nothing) = id
toLoop (d, Just i) =
toLoop :: (Int, Identifier) -> (Stmt -> Stmt)
toLoop (_, "") = id
toLoop (d, i) =
For (Left [idxDecl]) cmp [incr]
where
queryFn f = DimFn f (Right $ Ident x) (Number $ show d)
+2 -6
View File
@@ -255,14 +255,10 @@ traverseSinglyNestedStmtsM fullMapper = cs
traverseAssertionStmtsM :: Monad m => MapperM m Stmt -> MapperM m Assertion
traverseAssertionStmtsM mapper = assertionMapper
where
actionBlockMapper (ActionBlockIf stmt) =
mapper stmt >>= return . ActionBlockIf
actionBlockMapper (ActionBlockElse Nothing stmt) =
mapper stmt >>= return . ActionBlockElse Nothing
actionBlockMapper (ActionBlockElse (Just s1) s2) = do
actionBlockMapper (ActionBlock s1 s2) = do
s1' <- mapper s1
s2' <- mapper s2
return $ ActionBlockElse (Just s1') s2'
return $ ActionBlock s1' s2'
assertionMapper (Assert e ab) =
actionBlockMapper ab >>= return . Assert e
assertionMapper (Assume e ab) =