@@ -857,8 +857,8 @@ unfoldLookupTable input =
857857 adaptRuntime $ expandCons evals applys js
858858 where
859859 adaptRuntime :: [JS] -> [JS]
860− adaptRuntime js =
861− (adaptApplyTC . adaptEval . adaptApply . adaptCon) js
860+ adaptRuntime =
861+ adaptEvalTC . adaptApplyTC . adaptEval . adaptApply . adaptCon
862862
863863
864864 adaptApply :: [JS] -> [JS]
@@ -943,6 +943,40 @@ unfoldLookupTable input =
943943 )
944944 )
945945
946+
947+ adaptEvalTC :: [JS] -> [JS]
948+ adaptEvalTC js = adaptEvalTC' [] js
949+ where
950+ adaptEvalTC' :: [JS] -> [JS] -> [JS]
951+ adaptEvalTC' front ((JSAlloc "__IDRRT__EVALTC" (Just _)):back) =
952+ front ++ (new:back)
953+
954+ adaptEvalTC' front (next:back) =
955+ adaptEvalTC' (front ++ [next]) back
956+
957+ adaptEvalTC' front [] = front
958+
959+ new =
960+ JSAlloc "__IDRRT__EVALTC" (Just $ JSFunction ["marg0"] (
961+ JSSeq [ JSAlloc "ret" $ Just (
962+ JSTernary (
963+ (JSIdent "marg0" `jsInstanceOf` jsCon) `jsAnd`
964+ (JSProj (JSIdent "marg0") "eval")
965+ ) (JSApp
966+ (JSProj (JSIdent "marg0") "eval")
967+ [JSIdent "marg0"]
968+ ) (JSIdent "marg0")
969+ )
970+ , JSWhile (JSIdent "ret" `jsInstanceOf` (JSIdent "__IDRRT__Cont")) (
971+ JSAssign (JSIdent "ret") (
972+ JSApp (JSProj (JSIdent "ret") "k") []
973+ )
974+ )
975+ , JSReturn $ JSIdent "ret"
976+ ]
977+ ))
978+
979+
946980 adaptCon js =
947981 adaptCon' [] js
948982 where