on master help sign in
javascript: revive EVAL optimization during codegen
9a12d46raichoo
src/IRTS/CodegenJavaScript.hs+17−14
@@ -1441,20 +1441,23 @@ translateDeclaration (path, SFun name params stackSize body)
1441 {-)-}
1441 {-)-}
1442 {-]-}
1442 {-]-}
1443
1443
1444− {-| (MN _ ev) <- name-}
1444+ | (MN _ ev) <- name
1445− {-, (SChkCase var cases) <- body-}
1445+ , (SChkCase var cases) <- body
1446− {-, ev == txt "EVAL" =-}
1446+ , ev == txt "EVAL" =
1447− {-[ lookupTable "EVAL" [] var cases-}
1447+ [ lookupTable "EVAL" [] var cases
1448− {-, jsDecl $ JSFunction ["arg0"] (JSReturn $-}
1448+ , jsDecl $ JSFunction ["arg0"] (JSReturn $
1449− {-JSTernary (-}
1449+ JSTernary (
1450− {-(JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`-}
1450+ (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
1451− {-(hasProp (idrLTNamespace ++ "EVAL") "arg0")-}
1451+ (hasProp (idrLTNamespace ++ "EVAL") "arg0")
1452− {-) (JSApp-}
1452+ ) (JSApp
1453+ (JSIndex
1453− {-(JSIndex (JSIdent (idrLTNamespace ++ "EVAL")) (JSProj (JSIdent "arg0") "tag"))-}
1454+ (JSIdent (idrLTNamespace ++ "EVAL"))
1455+ (JSProj (JSIdent "arg0") "tag")
1456+ )
1454− {-[JSIdent "arg0"]-}
1457+ [JSIdent "arg0"]
1455− {-) (JSIdent "arg0")-}
1458+ ) (JSIdent "arg0")
1456− {-)-}
1459+ )
1457− {-]-}
1460+ ]
1458 | otherwise =
1461 | otherwise =
1459 let fun = translateExpression body in
1462 let fun = translateExpression body in
1460 [jsDecl $ jsFun fun]
1463 [jsDecl $ jsFun fun]