@@ -857,24 +857,38 @@ unfoldLookupTable input =
857 adaptRuntime $ expandCons evals applys js
857 adaptRuntime $ expandCons evals applys js
859 adaptRuntime :: [JS] -> [JS]
859 adaptRuntime :: [JS] -> [JS]
860− adaptRuntime =
860+ adaptRuntime js = (adaptApply . adaptCon) js
861− adaptCon . adaptApply "__var_2" . adaptApply "ev" . adaptEval
864− adaptApply var = map (jsSubst (
863+ adaptApply :: [JS] -> [JS]
865− JSIndex (JSIdent "__IDRLT__APPLY") (JSProj (JSIdent var) "tag")
864+ adaptApply js = adaptApply' [] js
866− ) (JSProj (JSIdent var) "app"))
865+ where
866+ adaptApply' :: [JS] -> [JS] -> [JS]
867+ adaptApply' front ((JSAlloc "__IDR__mAPPLY0" (Just _)):back) =
870+ adaptApply' front (next:back) =
871+ adaptApply' (front ++ [next]) back
873+ adaptApply' front [] = front
869− adaptEval = map (jsSubst (
875+ new =
870− JSIndex (JSIdent "__IDRLT__EVAL") (JSProj (JSIdent "arg0") "tag")
876+ JSAlloc "__IDR__mAPPLY0" (Just $ JSFunction ["mfn0", "marg0"] (JSReturn $
878+ (JSIdent "mfn0" `jsInstanceOf` jsCon) `jsAnd`
879+ (JSProj (JSIdent "mfn0") "app")
871− ) (JSProj (JSIdent "arg0") "eval"))
881+ (JSProj (JSIdent "mfn0") "app")
882+ [JSIdent "mfn0", JSIdent "marg0"]
874 adaptCon js =
888 adaptCon js =
875 adaptCon' [] js
889 adaptCon' [] js
877− adaptCon' front ((JSAlloc "__IDRRT__Con" (Just body)):back) =
891+ adaptCon' front ((JSAlloc "__IDRRT__Con" (Just _)):back) =
878 front ++ (new:back)
892 front ++ (new:back)
880 adaptCon' front (next:back) =
894 adaptCon' front (next:back) =