on master help sign in
Add method deps.
commit27fbd564b3a9d45cab9bd5ada2af9143e80ef015 authorMatus Tejiscak <ziman@functor.sk> dateFri 7 Mar 2014, 15:13 (13 years ago) parente31205d
1 file changed+20−13
src/Idris/Erasure.hs+20−13
src/Idris/Erasure.hs+20−13
@@ -240,21 +240,18 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
240240 -- to capture these dependencies as well
241241 etaIdx = [length vars .. length tys - 1]
242242 etaVars = [eta i | i <- etaIdx]
243− etaMap = M.fromList [(eta i, VI
244− { viDeps = M.singleton (fn, Arg i) S.empty
245− , viFunArg = Just i
246− })
247− | i <- etaIdx]
243+ etaMap = M.fromList [varPair (eta i) i | i <- etaIdx]
248244 eta i = MN i (pack "eta")
249245
250246 -- the variables that arose as function arguments only depend on (n, i)
251− varMap = M.fromList
252− [(v, VI
253− { viDeps = M.singleton (fn, Arg i) S.empty
254− , viFunArg = Just i
255− }
256− )
257− | (v,i) <- zip vars [0..]]
247+ varMap = M.fromList [varPair v i | (v,i) <- zip vars [0..]]
248+
249+ varPair n argNo = (n, VI
250+ { viDeps = M.singleton (fn, Arg argNo) S.empty
251+ , viFunArg = Just argNo
252+ , viMethod = Nothing
253+ })
254+
258255 (vars, sc) = cases_runtime cdefs
259256 -- we use cases_runtime in order to have case-blocks
260257 -- resolved to top-level functions before our analysis
@@ -363,10 +360,20 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
363360 -- a bound variable might draw in additional dependencies,
364361 -- think: f x = x 0 <-- here, `x' _is_ used
365362 P _ n _
363+ -- local name that refers to a method
366364 | Just var <- M.lookup n vs
365+ , Just (cn, i) <- viMethod var
366+ -> node (SN (WhereN i cn $ sMN i "field")) args
367+
368+ -- local name
369+ | Just var <- M.lookup n vs
370+ -- unconditional use
367371 -> viDeps var `ins` unconditionalDeps args
372+
373+ -- global name
368374 | otherwise
369− -> node n args -- depends on whether the referred thing uses its argument
375+ -- depends on whether the referred thing uses its argument
376+ -> node n args
370377
371378 -- TODO: could we somehow infer how bound variables use their arguments?
372379 V i -> M.unionWith (M.unionWith S.union) ((bs !! i) cd) (unconditionalDeps args)