on master help sign in
javascript: remove some more constructors
commitec562e98ea57f3575b30b31fb38b8f21e3498440 authorraichoo <raichoo@googlemail.com> dateFri 2 May 2014, 16:22 (12 years ago) parent7c8a6b9
1 file changed+16
src/IRTS/CodegenJavaScript.hs+16
src/IRTS/CodegenJavaScript.hs+16
@@ -1449,6 +1449,21 @@ elimConds js =
14491449 )) = map (inlineFunction fun args (JSTernary c t f)) js
14501450
14511451
1452+removeUselessCons :: [JS] -> [JS]
1453+removeUselessCons js =
1454+ let (cons, rest) = partition isUseless js in
1455+ foldl' eraseCon rest cons
1456+ where
1457+ isUseless :: JS -> Bool
1458+ isUseless (JSAlloc fun (Just JSNull)) = True
1459+ isUseless (JSAlloc fun (Just (JSIdent _))) = True
1460+ isUseless _ = False
1461+
1462+
1463+ eraseCon :: [JS] -> JS -> [JS]
1464+ eraseCon js (JSAlloc fun (Just val)) = map (jsSubst (JSIdent fun) val) js
1465+
1466+
14521467getGlobalCons :: JS -> [(String, JS)]
14531468getGlobalCons js = foldJS match (++) [] js
14541469 where
@@ -1551,6 +1566,7 @@ codegenJS_all target definitions includes filename outputType = do
15511566 , unfoldLookupTable
15521567 , evalCons
15531568 , elimConds
1569+ , removeUselessCons
15541570 ]
15551571
15561572 functions :: [String]