@@ -208,6 +208,7 @@ instance ToIR (TT Name) where
208 tm == txt "trace_malloc"
208 tm == txt "trace_malloc"
209 = do t' <- ir' env t
209 = do t' <- ir' env t
210 return t' -- TODO
210 return t' -- TODO
211 -- This case is here until we get more general inlining. It's just
212 -- This case is here until we get more general inlining. It's just
212 -- a really common case, and the laziness hurts...
213 -- a really common case, and the laziness hurts...
213 | (P _ (NS (UN be) [b,p]) _, [_,x,(App (P _ (UN d) _) t),
214 | (P _ (NS (UN be) [b,p]) _, [_,x,(App (P _ (UN d) _) t),
@@ -218,16 +219,14 @@ instance ToIR (TT Name) where
218 e' <- ir' env e
219 e' <- ir' env e
219 return (LCase x' [LConCase 0 (sNS (sUN "False") ["Bool","Prelude"]) [] e',
220 return (LCase x' [LConCase 0 (sNS (sUN "False") ["Bool","Prelude"]) [] e',
220 LConCase 1 (sNS (sUN "True") ["Bool","Prelude"]) [] t'])
221 LConCase 1 (sNS (sUN "True") ["Bool","Prelude"]) [] t'])
221− | (P (DCon t a) n _, args) <- unApply tm
223+ | (P (DCon t a) n _, args) <- unApply tm = do
223 cg <- idris_callgraph <$> getIState
224 cg <- idris_callgraph <$> getIState
224 case lookupCtxtExact n cg of
225 case lookupCtxtExact n cg of
225 Just (CGInfo _ _ _ _ usedpos)
226 Just (CGInfo _ _ _ _ usedpos)
226 -> irCon env t a n [if i `elem` map fst usedpos then a else Erased | (i,a) <- zip [0..] args]
227 -> irCon env t a n [if i `elem` map fst usedpos then a else Erased | (i,a) <- zip [0..] args]
227− Nothing -> irCon env t a n args
228+ Nothing -> return LNothing -- no usage info -> not used at all
229− | (P (DCon t a) n _, args) <- unApply tm
230− = irCon env t a n args
231 | (P (TCon t a) n _, args) <- unApply tm
230 | (P (TCon t a) n _, args) <- unApply tm
232 = return LNothing
231 = return LNothing
@@ -263,6 +262,8 @@ instance ToIR (TT Name) where
264 arity = case fst4 <$> lookupCtxt n (definitions . tt_ctxt $ ist) of
263 arity = case fst4 <$> lookupCtxt n (definitions . tt_ctxt $ ist) of
265 [CaseOp ci ty tys def tot cdefs] -> length tys
264 [CaseOp ci ty tys def tot cdefs] -> length tys
265+ [TyDecl (DCon tag ar) _] -> ar
266+ [Operator ty ar op] -> ar
268 used = fromMaybe [] (map fst . usedpos <$> lookupCtxtExact n (idris_callgraph ist))
269 used = fromMaybe [] (map fst . usedpos <$> lookupCtxtExact n (idris_callgraph ist))