on master help sign in
javascript: remove more continuations
c847db7raichoo
src/IRTS/CodegenJavaScript.hs+20−5
@@ -741,14 +741,29 @@ inlineFunctions js =
741
741
742
742
743reduceContinuations :: JS -> JS
743reduceContinuations :: JS -> JS
744−reduceContinuations = transformJS reduceHelper
744+reduceContinuations = inlineTC . reduceJS
745 where
745 where
746− reduceHelper :: JS -> JS
746+ reduceJS :: JS -> JS
747− reduceHelper (JSNew "__IDRRT__Cont" [JSFunction [] (
747+ reduceJS (JSNew "__IDRRT__Cont" [JSFunction [] (
748 JSReturn js@(JSNew "__IDRRT__Cont" [JSFunction [] body])
748 JSReturn js@(JSNew "__IDRRT__Cont" [JSFunction [] body])
749− )]) = js
749+ )]) = reduceJS js
750+
751+ reduceJS js = transformJS reduceJS js
752+
753+
754+ inlineTC :: JS -> JS
755+ inlineTC js
756+ | JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
757+ JSReturn (JSNew "__IDRRT__Cont" [JSFunction [] (
758+ JSReturn ret@(JSApp (JSIdent "__IDRRT__tailcall") [JSFunction [] (
759+ JSReturn (JSNew "__IDRRT__Cont" _)
760+ )])
761+ )])
762+ )] <- js = inlineTC ret
763+
764+ inlineTC js = transformJS inlineTC js
765+
750
766
751− reduceHelper js = transformJS reduceHelper js
752
767
753
768
754reduceConstant :: JS -> JS
769reduceConstant :: JS -> JS