[make Grin.DeadCode handle local functions properly
John Meacham <john@repetae.net>**20060815030719] hunk ./Grin/DeadCode.hs 42
-    -- using a CAF implies using its function if pre-inlining
---    unless postInline $ flip mapM_ (grinCafs grin) $ \ (var,~(NodeC a [])) -> do
---        x <- supplyValue usedCafs var
---        f <- supplyValue usedFuncs (tagFlipFunction a)
---        addRule $ x `implies` f
hunk ./Grin/DeadCode.hs 50
+    when True $ do
+        putStrLn "usedArgs"
+        mapM_ print ua
+        putStrLn "usedCafs"
+        mapM_ print uc
+        putStrLn "usedFuncs"
+        mapM_ print uf
+        putStrLn "pappFuncs"
+        print pappFuncs
+        putStrLn "suspFuncs"
+        print suspFuncs
hunk ./Grin/DeadCode.hs 88
-
-
-    --putStrLn "partialapplied:"
-    --mapM_ print $ Set.toList pappFuncs
-    --putStrLn "suspended:"
-    --mapM_ print $ Set.toList suspFuncs
-    --putStrLn "none:"
-    --mapM_ print $ Set.toList $ funSet Set.\\ suspFuncs Set.\\ pappFuncs
hunk ./Grin/DeadCode.hs 100
+    goAgain = go fixer pappFuncs suspFuncs usedFuncs usedArgs usedCafs postInline
hunk ./Grin/DeadCode.hs 128
-            g Let {} = return ()
+            g Let { expDefs = defs, expBody = body } = do
+                mapM_ goAgain [ (name,bod) | FuncDef { funcDefBody = bod, funcDefName = name } <- defs]
+                -- g body
hunk ./Grin/DeadCode.hs 159
-removeDeadArgs postInline funSet directFuncs usedCafs usedArgs (a,l) =  whizExps f (margs l) >>= return . (,) a where
-    margs (Tup as :-> e) | a `Set.member` directFuncs = (Tup (removeArgs a as) :-> e)
-    margs x = x
+removeDeadArgs postInline funSet directFuncs usedCafs usedArgs (a,l) =  whizExps f (margs a l) >>= return . (,) a where
+    margs fn (Tup as :-> e) | a `Set.member` directFuncs = (Tup (removeArgs fn as) :-> e)
+    margs _ x = x
hunk ./Grin/DeadCode.hs 181
+    f lt@Let { expDefs = defs }  = return lt { expDefs = [ df { funcDefBody = margs name body } | df@FuncDef { funcDefName = name, funcDefBody = body } <- defs ] }