on master help sign in
javascript: remove some more constructors
ec562e9raichoo
src/IRTS/CodegenJavaScript.hs+16
@@ -1449,6 +1449,21 @@ elimConds js =
1449 )) = map (inlineFunction fun args (JSTernary c t f)) js
1449 )) = map (inlineFunction fun args (JSTernary c t f)) js
1450
1450
1451
1451
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+
1452getGlobalCons :: JS -> [(String, JS)]
1467getGlobalCons :: JS -> [(String, JS)]
1453getGlobalCons js = foldJS match (++) [] js
1468getGlobalCons js = foldJS match (++) [] js
1454 where
1469 where
@@ -1551,6 +1566,7 @@ codegenJS_all target definitions includes filename outputType = do
1551 , unfoldLookupTable
1566 , unfoldLookupTable
1552 , evalCons
1567 , evalCons
1553 , elimConds
1568 , elimConds
1569+ , removeUselessCons
1554 ]
1570 ]
1555
1571
1556 functions :: [String]
1572 functions :: [String]