@@ -503,6 +503,42 @@ inlineJS = inlineAssign . inlineError . inlineApply . inlineCaseMatch . inlineJS
503 inlineAssign js = transformJS inlineAssign js
503 inlineAssign js = transformJS inlineAssign js
506+removeEval :: [JS] -> [JS]
508+ let (ret, isReduced) = checkEval js in
510+ then removeEvalApp ret
513+ removeEvalApp js = catMaybes (map removeEvalApp' js)
515+ removeEvalApp' :: JS -> Maybe JS
516+ removeEvalApp' (JSAlloc "__IDR__mEVAL0" _) = Nothing
517+ removeEvalApp' js = Just $ transformJS match js
519+ match (JSApp (JSIdent "__IDR__mEVAL0") [val]) = val
520+ match js = transformJS match js
522+ removeEvalApp js = js
524+ checkEval :: [JS] -> ([JS], Bool)
525+ checkEval js = foldr f ([], False) $ map checkEval' js
527+ f :: (Maybe JS, Bool) -> ([JS], Bool) -> ([JS], Bool)
528+ f (Just js, isReduced) (ret, b) = (js : ret, isReduced || b)
529+ f (Nothing, isReduced) (ret, b) = (ret, isReduced || b)
532+ checkEval' :: JS -> (Maybe JS, Bool)
533+ checkEval' (JSAlloc "__IDRLT__EVAL" (Just (JSApp (JSFunction [] (
535+ , JSReturn (JSIdent "t")
537+ )) []))) = (Nothing, True)
539+ checkEval' js = (Just js, False)
506reduceJS :: [JS] -> [JS]
542reduceJS :: [JS] -> [JS]
507reduceJS js = moveJSDeclToTop "__IDRRT__Con" $ reduceLoop [] ([], js)
543reduceJS js = moveJSDeclToTop "__IDRRT__Con" $ reduceLoop [] ([], js)
@@ -1319,7 +1355,8 @@ codegenJavaScript target definitions filename outputType = do
1319 map compileJS
1355 map compileJS
1322− [ map inlineJS
1359+ , map inlineJS
1323 , removeIDs
1360 , removeIDs
1324 , reduceJS
1361 , reduceJS
1325 , map reduceConstants
1362 , map reduceConstants