on master help sign in
Redefine dep analysis data structures.
commitaff298871377e7590860833c95d440925680752d authorMatus Tejiscak <ziman@functor.sk> dateTue 21 Jan 2014, 12:11 (13 years ago) parent20b544c
2 files changed+10−24
src/IRTS/Compiler.hs+1−1 src/Idris/Erasure.hs+9−23
src/IRTS/Compiler.hs+1−1
@@ -41,7 +41,7 @@ compile codegen f tm
4141 = do checkMVs
4242 let tmnames = namesUsed (STerm tm)
4343 usedIn <- mapM (allNames []) tmnames
44− let used = sUN "prim__subBigInt" : sUN "prim__addBigInt"] : concat usedIn
44+ let used = sUN "prim__subBigInt" : sUN "prim__addBigInt" : concat usedIn
4545 defsIn <- mkDecls tm used
4646 findUnusedArgs used
4747
src/Idris/Erasure.hs+9−23
@@ -28,37 +28,23 @@ import Data.IntMap (IntMap)
2828-- UseMap maps names to the set of used (reachable) argument positions.
2929type UseMap = Map Name IntSet
3030
31−-- A dependency, potential edge in the dep graph.
32−-- Every dependency belongs to a certain Idris function.
33−-- For the effect to take place, the condition must be true.
34−data Dep = Dep
35− -- Effect
36− { depArg :: Int -- | This argument of the function should be marked as used.
37− , depCtors :: Set (Name, Int) -- | These ctor fields should be marked as used.
38− , depTags :: Set Name -- | Tags of these ADTs should be marked as used.
39−
40− -- Condition
41− , depGuards :: Set (Name, Int) -- | All these arguments must be marked as used.
42− }
43− deriving (Eq, Ord, Show)
44−
45−-- DepMap maps function names to their sets of dependencies.
46−type DepMap = Map Name (Set Dep)
31+type Deps = IntMap (Set (Name, Int))
32+type DepMap = Map Name Deps
4733
48−findUsed :: Context -> Ctxt CGInfo -> [Name] -> UseMap
34+findUsed :: Context -> Ctxt CGInfo -> [Name] -> DepMap
4935findUsed ctx cg ns = M.fromList [(n, getDeps n) | n <- ns]
5036 where
51− getDeps :: Name -> Set Dep
37+ getDeps :: Name -> Deps
5238 getDeps n = case lookupDef n ctx of
5339 [def] -> getDepsDef def
5440 [] -> error $ "erasure checker: unknown name: " ++ show n
5541 _ -> error $ "erasure checker: ambiguous name: " ++ show n
5642
57− getDepsDef :: Def -> Set Dep
58− getDepsDef (Function ty t) = S.empty
59− getDepsDef (TyDecl ty t) = S.empty
60− getDepsDef (Operator ty n f) = S.empty
61− getDepsDef (CaseOp ci ty tys def tot cdefs) = S.empty
43+ getDepsDef :: Def -> Deps
44+ getDepsDef (Function ty t) = IM.empty
45+ getDepsDef (TyDecl ty t) = IM.empty
46+ getDepsDef (Operator ty n f) = IM.empty
47+ getDepsDef (CaseOp ci ty tys def tot cdefs) = IM.empty
6248
6349{-
6450buildDepGraph :: Context -> Ctxt CGInfo -> [Name] -> DepGraph