@@ -786,10 +786,10 @@ optimizeRuntimeCalls fun tc js =
786 JSSeq [ JSAlloc "ret" $ Just (
786 JSSeq [ JSAlloc "ret" $ Just (
787 JSTernary (
787 JSTernary (
788 (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
788 (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
789− (hasProp "__IDRLT__mEVAL0" "arg0")
789+ (hasProp "__IDRLT__EVAL" "arg0")
792− (JSIdent "__IDRLT__mEVAL0")
792+ (JSIdent "__IDRLT__EVAL")
793 (JSProj (JSIdent "arg0") "tag")
793 (JSProj (JSIdent "arg0") "tag")
795 [JSIdent "arg0"]
795 [JSIdent "arg0"]
@@ -812,10 +812,10 @@ optimizeRuntimeCalls fun tc js =
812 , JSAlloc "ret" $ Just (
812 , JSAlloc "ret" $ Just (
813 JSTernary (
813 JSTernary (
814 (JSIdent "ev" `jsInstanceOf` jsCon) `jsAnd`
814 (JSIdent "ev" `jsInstanceOf` jsCon) `jsAnd`
815− (hasProp "__IDRLT__mAPPLY0" "ev")
815+ (hasProp "__IDRLT__APPLY" "ev")
818− (JSIdent "__IDRLT__mAPPLY0")
818+ (JSIdent "__IDRLT__APPLY")
819 (JSProj (JSIdent "ev") "tag")
819 (JSProj (JSIdent "ev") "tag")
821 [JSIdent "fn0", JSIdent "arg0", JSIdent "ev"]
821 [JSIdent "fn0", JSIdent "arg0", JSIdent "ev"]
@@ -838,8 +838,8 @@ optimizeRuntimeCalls fun tc js =
839unfoldLookupTable :: [JS] -> [JS]
839unfoldLookupTable :: [JS] -> [JS]
840unfoldLookupTable input =
840unfoldLookupTable input =
841− let (evals, evalunfold) = unfoldLT "__IDRLT__mEVAL0" input
841+ let (evals, evalunfold) = unfoldLT "__IDRLT__EVAL" input
842− (applys, applyunfold) = unfoldLT "__IDRLT__mAPPLY0" evalunfold
842+ (applys, applyunfold) = unfoldLT "__IDRLT__APPLY" evalunfold
843 js = applyunfold in
843 js = applyunfold in
844 adaptRuntime $ expandCons evals applys js
844 adaptRuntime $ expandCons evals applys js
@@ -849,12 +849,12 @@ unfoldLookupTable input =
851 adaptApply var = map (jsSubst (
851 adaptApply var = map (jsSubst (
852− JSIndex (JSIdent "__IDRLT__mAPPLY0") (JSProj (JSIdent var) "tag")
852+ JSIndex (JSIdent "__IDRLT__APPLY") (JSProj (JSIdent var) "tag")
853 ) (JSProj (JSIdent var) "app"))
853 ) (JSProj (JSIdent var) "app"))
856 adaptEval = map (jsSubst (
856 adaptEval = map (jsSubst (
857− JSIndex (JSIdent "__IDRLT__mEVAL0") (JSProj (JSIdent "arg0") "tag")
857+ JSIndex (JSIdent "__IDRLT__EVAL") (JSProj (JSIdent "arg0") "tag")
858 ) (JSProj (JSIdent "arg0") "eval"))
858 ) (JSProj (JSIdent "arg0") "eval"))
@@ -894,8 +894,8 @@ unfoldLookupTable input =
895 expandCons' :: JS -> JS
895 expandCons' :: JS -> JS
896 expandCons' (JSNew "__IDRRT__Con" [JSNum (JSInt tag), JSArray args])
896 expandCons' (JSNew "__IDRRT__Con" [JSNum (JSInt tag), JSArray args])
897− | evalid <- getId "__IDRLT__mEVAL0" tag evals
897+ | evalid <- getId "__IDRLT__EVAL" tag evals
898− , applyid <- getId "__IDRLT__mAPPLY0" tag applys =
898+ , applyid <- getId "__IDRLT__APPLY" tag applys =
899 JSNew "__IDRRT__Con" [ JSNum (JSInt tag)
899 JSNew "__IDRRT__Con" [ JSNum (JSInt tag)
900 , maybe JSNull JSIdent evalid
900 , maybe JSNull JSIdent evalid
901 , maybe JSNull JSIdent applyid
901 , maybe JSNull JSIdent applyid
@@ -912,8 +912,8 @@ unfoldLookupTable input =
914 ltIdentifier :: String -> Int -> String
914 ltIdentifier :: String -> Int -> String
915− ltIdentifier "__IDRLT__mEVAL0" id = idrLTNamespace ++ "EVAL" ++ show id
915+ ltIdentifier "__IDRLT__EVAL" id = idrLTNamespace ++ "EVAL" ++ show id
916− ltIdentifier "__IDRLT__mAPPLY0" id = idrLTNamespace ++ "APPLY" ++ show id
916+ ltIdentifier "__IDRLT__APPLY" id = idrLTNamespace ++ "APPLY" ++ show id
919 extractLT :: String -> [JS] -> (JS, [JS])
919 extractLT :: String -> [JS] -> (JS, [JS])
@@ -1228,7 +1228,7 @@ translateDeclaration (path, SFun name params stackSize body)
1228 lookup t = (JSApp
1228 lookup t = (JSApp
1229 (JSIndex (JSIdent t) (JSProj (JSIdent lvar) "tag"))
1229 (JSIndex (JSIdent t) (JSProj (JSIdent lvar) "tag"))
1230 [JSIdent "fn0", JSIdent "arg0", JSIdent lvar]) in
1230 [JSIdent "fn0", JSIdent "arg0", JSIdent lvar]) in
1231− [ lookupTable [(var, "chk")] var cases
1231+ [ lookupTable "APPLY" [(var, "chk")] var cases
1232 , jsDecl $ JSFunction ["fn0", "arg0"] (
1232 , jsDecl $ JSFunction ["fn0", "arg0"] (
1233 JSSeq [ JSAlloc "__var_0" (Just $ JSIdent "fn0")
1233 JSSeq [ JSAlloc "__var_0" (Just $ JSIdent "fn0")
1234 , JSAlloc (translateVariableName var) (
1234 , JSAlloc (translateVariableName var) (
@@ -1236,8 +1236,8 @@ translateDeclaration (path, SFun name params stackSize body)
1237 , JSReturn $ (JSTernary (
1237 , JSReturn $ (JSTernary (
1238 (JSVar var `jsInstanceOf` jsCon) `jsAnd`
1238 (JSVar var `jsInstanceOf` jsCon) `jsAnd`
1239− (hasProp lookupTableName (translateVariableName var))
1239+ (hasProp (idrLTNamespace ++ "APPLY") (translateVariableName var))
1240− ) (lookup lookupTableName) JSNull)
1240+ ) (lookup (idrLTNamespace ++ "APPLY")) JSNull)
@@ -1245,13 +1245,13 @@ translateDeclaration (path, SFun name params stackSize body)
1245 | (MN _ ev) <- name
1245 | (MN _ ev) <- name
1246 , (SChkCase var cases) <- body
1246 , (SChkCase var cases) <- body
1247 , ev == txt "EVAL" =
1247 , ev == txt "EVAL" =
1248− [ lookupTable [] var cases
1248+ [ lookupTable "EVAL" [] var cases
1249 , jsDecl $ JSFunction ["arg0"] (JSReturn $
1249 , jsDecl $ JSFunction ["arg0"] (JSReturn $
1250 JSTernary (
1250 JSTernary (
1251 (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
1251 (JSIdent "arg0" `jsInstanceOf` jsCon) `jsAnd`
1252− (hasProp lookupTableName "arg0")
1252+ (hasProp (idrLTNamespace ++ "EVAL") "arg0")
1253 ) (JSApp
1253 ) (JSApp
1254− (JSIndex (JSIdent lookupTableName) (JSProj (JSIdent "arg0") "tag"))
1254+ (JSIndex (JSIdent (idrLTNamespace ++ "EVAL")) (JSProj (JSIdent "arg0") "tag"))
1255 [JSIdent "arg0"]
1255 [JSIdent "arg0"]
1256 ) (JSIdent "arg0")
1256 ) (JSIdent "arg0")
@@ -1277,13 +1277,9 @@ translateDeclaration (path, SFun name params stackSize body)
1277 getTag _ = Nothing
1277 getTag _ = Nothing
1280− lookupTableName :: String
1281− lookupTableName = idrLTNamespace ++ translateName name
1284− lookupTable :: [(LVar, String)] -> LVar -> [SAlt] -> JS
1280+ lookupTable :: String -> [(LVar, String)] -> LVar -> [SAlt] -> JS
1285− lookupTable aux var cases =
1281+ lookupTable table aux var cases =
1286− JSAlloc lookupTableName $ Just (
1282+ JSAlloc (idrLTNamespace ++ table) $ Just (
1287 JSApp (JSFunction [] (
1283 JSApp (JSFunction [] (
1288 JSSeq $ [
1284 JSSeq $ [
1289 JSAlloc "t" $ Just (JSArray [])
1285 JSAlloc "t" $ Just (JSArray [])