on master help sign in
javascript: revive EVAL optimization during codegen
commit9a12d468477e97d32f7f8db170ea5d2f211b3121 authorraichoo <raichoo@googlemail.com> dateFri 14 Feb 2014, 12:32 (13 years ago) parent5d4f534
1 file changed+17−14
src/IRTS/CodegenJavaScript.hs+17−14
src/IRTS/CodegenJavaScript.hs+17−14
@@ -1441,20 +1441,23 @@ translateDeclaration (path, SFun name params stackSize body)
14411441 {-)-}
14421442 {-]-}
14431443
1444− {-| (MN _ ev) <- name-}
1445− {-, (SChkCase var cases) <- body-}
1446− {-, ev == txt "EVAL" =-}
1447− {-[ lookupTable "EVAL" [] var cases-}
1448− {-, jsDecl $ JSFunction ["arg0"] (JSReturn $-}
1449− {-JSTernary (-}
1450− {-(JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`-}
1451− {-(hasProp (idrLTNamespace ++ "EVAL") "arg0")-}
1452− {-) (JSApp-}
1453− {-(JSIndex (JSIdent (idrLTNamespace ++ "EVAL")) (JSProj (JSIdent "arg0") "tag"))-}
1454− {-[JSIdent "arg0"]-}
1455− {-) (JSIdent "arg0")-}
1456− {-)-}
1457− {-]-}
1444+ | (MN _ ev) <- name
1445+ , (SChkCase var cases) <- body
1446+ , ev == txt "EVAL" =
1447+ [ lookupTable "EVAL" [] var cases
1448+ , jsDecl $ JSFunction ["arg0"] (JSReturn $
1449+ JSTernary (
1450+ (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
1451+ (hasProp (idrLTNamespace ++ "EVAL") "arg0")
1452+ ) (JSApp
1453+ (JSIndex
1454+ (JSIdent (idrLTNamespace ++ "EVAL"))
1455+ (JSProj (JSIdent "arg0") "tag")
1456+ )
1457+ [JSIdent "arg0"]
1458+ ) (JSIdent "arg0")
1459+ )
1460+ ]
14581461 | otherwise =
14591462 let fun = translateExpression body in
14601463 [jsDecl $ jsFun fun]