@@ -332,6 +332,12 @@ codegenJS_all target definitions includes filename outputType = do
332 ) [ JSIdent "vm"
332 ) [ JSIdent "vm"
333 , JSNum (JSInt 0)
333 , JSNum (JSInt 0)
335+ , JSWhile (JSProj (JSProj (JSIdent ("vm")) "callstack") "length") (
336+ JSSeq [ JSAlloc "func" (Just (JSApp (JSProj (JSProj (JSIdent ("vm")) "callstack") "pop") []))
337+ , JSAlloc "args" (Just (JSApp (JSProj (JSProj (JSIdent ("vm")) "callstack") "pop") []))
338+ , JSApp (JSProj (JSIdent "func") "apply") [JSThis, JSIdent "args"]
@@ -377,8 +383,7 @@ splitFunction (JSAlloc name (Just (JSFunction args body@(JSSeq _)))) = do
377 put (depth + 1)
383 put (depth + 1)
378 new <- splitFunction (newFun rest)
384 new <- splitFunction (newFun rest)
379 tell [(depth, new)]
385 tell [(depth, new)]
380− {-return $ JSSeq (pre ++ [newCall depth, call])-}
386+ return $ JSSeq (pre ++ (newCall depth : [call]))
381− return $ JSSeq (pre ++ (call : [newCall depth]))
383 splitSequence js = return js
388 splitSequence js = return js