@@ -529,6 +529,7 @@ data Def = Function Type Term
529data CaseDefs = CaseDefs {
529data CaseDefs = CaseDefs {
530 cases_totcheck :: ([Name], SC),
530 cases_totcheck :: ([Name], SC),
531 cases_compiletime :: ([Name], SC),
531 cases_compiletime :: ([Name], SC),
532+ cases_inlined :: ([Name], SC),
532 cases_runtime :: ([Name], SC)
533 cases_runtime :: ([Name], SC)
@@ -676,31 +677,37 @@ addCasedef :: Name -> CaseInfo -> Bool -> Bool -> Bool -> Bool ->
676 [Either Term (Term, Term)] ->
677 [Either Term (Term, Term)] ->
677 [([Name], Term, Term)] -> -- totality
678 [([Name], Term, Term)] -> -- totality
678 [([Name], Term, Term)] -> -- compile time
679 [([Name], Term, Term)] -> -- compile time
680+ [([Name], Term, Term)] -> -- inlined
679 [([Name], Term, Term)] -> -- run time
681 [([Name], Term, Term)] -> -- run time
680 Type -> Context -> Context
682 Type -> Context -> Context
681addCasedef n ci@(CaseInfo alwaysInline tcdict)
683addCasedef n ci@(CaseInfo alwaysInline tcdict)
682− tcase covering reflect asserted ps_in ps_tot ps_ct ps_rt ty uctxt
684+ tcase covering reflect asserted ps_in
685+ ps_tot ps_inl ps_ct ps_rt ty uctxt
683 = let ctxt = definitions uctxt
686 = let ctxt = definitions uctxt
684 access = case lookupDefAcc n False uctxt of
687 access = case lookupDefAcc n False uctxt of
685 [(_, acc)] -> acc
688 [(_, acc)] -> acc
686 _ -> Public
689 _ -> Public
687 ctxt' = case (simpleCase tcase covering reflect CompileTime (FC "" 0) ps_tot,
690 ctxt' = case (simpleCase tcase covering reflect CompileTime (FC "" 0) ps_tot,
688 simpleCase tcase covering reflect CompileTime (FC "" 0) ps_ct,
691 simpleCase tcase covering reflect CompileTime (FC "" 0) ps_ct,
692+ simpleCase tcase covering reflect CompileTime (FC "" 0) ps_inl,
689 simpleCase tcase covering reflect RunTime (FC "" 0) ps_rt) of
693 simpleCase tcase covering reflect RunTime (FC "" 0) ps_rt) of
690 (OK (CaseDef args_tot sc_tot _),
694 (OK (CaseDef args_tot sc_tot _),
691 OK (CaseDef args_ct sc_ct _),
695 OK (CaseDef args_ct sc_ct _),
696+ OK (CaseDef args_inl sc_inl _),
692 OK (CaseDef args_rt sc_rt _)) ->
697 OK (CaseDef args_rt sc_rt _)) ->
693 let inl = alwaysInline -- || tcdict
698 let inl = alwaysInline -- || tcdict
694 inlc = (inl || small n args_ct sc_ct) && (not asserted)
699 inlc = (inl || small n args_ct sc_ct) && (not asserted)
695 inlr = inl || small n args_rt sc_rt
700 inlr = inl || small n args_rt sc_rt
696 cdef = CaseDefs (args_tot, sc_tot)
701 cdef = CaseDefs (args_tot, sc_tot)
697 (args_ct, sc_ct)
702 (args_ct, sc_ct)
698 (args_rt, sc_rt) in
704 (args_rt, sc_rt) in
699 addDef n (CaseOp (ci { case_inlinable = inlc })
705 addDef n (CaseOp (ci { case_inlinable = inlc })
700 ty ps_in ps_tot cdef,
706 ty ps_in ps_tot cdef,
701 access, Unchecked) ctxt in
707 access, Unchecked) ctxt in
702 uctxt { definitions = ctxt' }
708 uctxt { definitions = ctxt' }
710+-- simplify a definition for totality checking
704simplifyCasedef :: Name -> Context -> Context
711simplifyCasedef :: Name -> Context -> Context
705simplifyCasedef n uctxt
712simplifyCasedef n uctxt
706 = let ctxt = definitions uctxt
713 = let ctxt = definitions uctxt