git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
TCO updates
commit2f68d4e7cf320b7f9063049fe6bfec3d25e00d65 authorAndy Arvanitis <andyarvanitis@gmail.com> dateSun 30 Jun 2019, 18:10 (7 years ago) parent52a6638
1 file changed+4−4
src/CodeGen/IL/Optimizer/TCO.hs+4−4
src/CodeGen/IL/Optimizer/TCO.hs+4−4
@@ -89,14 +89,14 @@ tco mn = everywhere convert where
8989 toLoop :: Text -> [Text] -> [Text] -> AST -> AST
9090 toLoop ident outerArgs innerArgs js =
9191 Block rootSS $
92− concatMap (\arg -> [ VariableIntroduction rootSS (tcoVar arg) Nothing
93− , Assignment rootSS (Var rootSS (tcoVar arg)) (Var rootSS (copyVar arg)) ]) (outerArgs ++ innerArgs) ++
92+ concatMap (\arg -> [ VariableIntroduction rootSS (tcoVar arg) . Just $
93+ Var rootSS (copyVar arg) ]) (outerArgs ++ innerArgs) ++
9494 [ Var rootSS (tcoDone <> " := false")
9595 , VariableIntroduction rootSS tcoResult Nothing
9696 , Assignment rootSS (Var rootSS ("var " <> tcoLoop)) (Function rootSS (Just tcoLoop) (outerArgs ++ innerArgs) (Block rootSS [loopify js]))
9797 , While rootSS (Unary Nothing Not (Var rootSS tcoDone))
9898 (Block rootSS
99− [(Assignment rootSS (Var rootSS tcoResult) (App rootSS (Var rootSS tcoLoop) ((map (Var rootSS . tcoVar) outerArgs) ++ (map (Var rootSS . tcoVar) innerArgs))))])
99+ [(Assignment rootSS (Var rootSS tcoResult) (App rootSS (Var rootSS tcoLoop) ((map (Var rootSS . tcoVar) outerArgs) ++ (map (Var rootSS . copyVar) innerArgs))))])
100100 , Return rootSS (Var rootSS tcoResult)
101101 ]
102102 where
@@ -112,7 +112,7 @@ tco mn = everywhere convert where
112112 zipWith (\val arg ->
113113 Assignment ss (Var ss (tcoVar arg)) val) allArgumentValues outerArgs
114114 ++ zipWith (\val arg ->
115− Assignment ss (Var ss (tcoVar arg)) val) (drop (length outerArgs) allArgumentValues) innerArgs
115+ Assignment ss (Var ss (copyVar arg)) val) (drop (length outerArgs) allArgumentValues) innerArgs
116116 ++ [ ReturnNoResult ss ]
117117 | otherwise = Block ss [ markDone ss, Return ss ret ]
118118 loopify (ReturnNoResult ss) = Block ss [ markDone ss, ReturnNoResult ss ]