@@ -831,7 +831,7 @@ codegenJavaScript target definitions filename outputType = do
831 intercalate "\n" $ [ jsbn
831 intercalate "\n" $ [ jsbn
832 , idrRuntime
832 , idrRuntime
833 , tgtRuntime
833 , tgtRuntime
834− ] ++ functions ++ [mainLoop, invokeLoop]
834+ ] ++ functions
837 setPermissions filename (emptyPermissions { readable = True
837 setPermissions filename (emptyPermissions { readable = True
@@ -844,7 +844,9 @@ codegenJavaScript target definitions filename outputType = do
845 functions :: [String]
845 functions :: [String]
846 functions =
846 functions =
847− let translated = concatMap translateDeclaration def
848+ concatMap translateDeclaration def ++ [mainLoop, invokeLoop]
848 optimized = map optimizeJS translated
850 optimized = map optimizeJS translated
849 idsRemoved = removeIDs optimized
851 idsRemoved = removeIDs optimized
850 reduced = reduceJS idsRemoved
852 reduced = reduceJS idsRemoved
@@ -854,8 +856,8 @@ codegenJavaScript target definitions filename outputType = do
854 js = deadEvalApplyCases removeAlloc in
856 js = deadEvalApplyCases removeAlloc in
855 map compileJS js
857 map compileJS js
857− mainLoop :: String
859+ mainLoop :: JS
858− mainLoop = compileJS $
860+ mainLoop =
859 JSAlloc "main" $ Just $ JSFunction [] (
861 JSAlloc "main" $ Just $ JSFunction [] (
860 case target of
862 case target of
861 Node -> mainFun
863 Node -> mainFun
@@ -872,8 +874,8 @@ codegenJavaScript target definitions filename outputType = do
872 runMain :: String
874 runMain :: String
873 runMain = idrNamespace ++ translateName (sMN 0 "runMain")
875 runMain = idrNamespace ++ translateName (sMN 0 "runMain")
875− invokeLoop :: String
877+ invokeLoop :: JS
876− invokeLoop = compileJS $ jsCall "main" []
878+ invokeLoop = jsCall "main" []
878translateIdentifier :: String -> String
880translateIdentifier :: String -> String
879translateIdentifier =
881translateIdentifier =