on master help sign in
Connect erasure with analysis.
commitb1bef1c2a939107120f9bceb2642396670cb2a1a authorMatus Tejiscak <ziman@functor.sk> dateTue 28 Jan 2014, 15:58 (13 years ago) parentad0dce1
1 file changed+10
src/IRTS/Compiler.hs+10
src/IRTS/Compiler.hs+10
@@ -28,6 +28,7 @@ import Idris.Core.CaseTree
2828import Control.Applicative
2929import Control.Monad.State
3030import Data.List
31+import Data.IntSet (IntSet)
3132import qualified Data.IntMap as IM
3233import qualified Data.IntSet as IS
3334import qualified Data.Map as M
@@ -60,6 +61,8 @@ compile codegen f tm
6061 let fmtDepMap = unlines . map (\(n,is) -> show n ++ " -> " ++ show (IS.toList is)) . M.toList
6162 let minUse = minimalUsage depMap
6263 iLOG $ "MINIMAL USAGE:\n" ++ fmtDepMap minUse
64+
65+ mapM_ (uncurry storeUsage) (M.toList minUse)
6366 -- END TODO
6467
6568 maindef <- irMain tm
@@ -116,6 +119,13 @@ compile codegen f tm
116119 ex <- doesFileExist f
117120 if ex then return f else return h
118121
122+storeUsage :: Name -> IntSet -> Idris ()
123+storeUsage n args = do
124+ cg <- idris_callgraph <$> getIState
125+ case lookupCtxt n cg of
126+ [x] -> addToCG n x{ usedpos = IS.toList args }
127+ _ -> return ()
128+
119129irMain :: TT Name -> Idris LDecl
120130irMain tm = do i <- ir tm
121131 return $ LFun [] (sMN 0 "runMain") [] (LForce i)