on master help sign in
Generate legal DChkCase expressions when defunctionalization is trivial
commitc70992b02ccd3fe184f9c096b33555676440cf2a authorBenjamin Saunders <besaunde@sfu.ca> dateWed 6 Mar 2013, 14:43 (14 years ago) parent095301f
1 file changed+7−4
src/IRTS/Defunctionalise.hs+7−4
src/IRTS/Defunctionalise.hs+7−4
@@ -212,10 +212,13 @@ mkEval xs = (MN 0 "EVAL", DFun (MN 0 "EVAL") [MN 0 "arg"]
212212
213213mkApply :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
214214mkApply xs = (MN 0 "APPLY", DFun (MN 0 "APPLY") [MN 0 "fn", MN 0 "arg"]
215− (mkBigCase (MN 0 "APPLY")
216− 256 (DApp False (MN 0 "EVAL")
217− [DV (Glob (MN 0 "fn"))])
218− (mapMaybe applyCase xs)))
215+ (case mapMaybe applyCase xs of
216+ [] -> DNothing
217+ cases ->
218+ mkBigCase (MN 0 "APPLY") 256
219+ (DApp False (MN 0 "EVAL")
220+ [DV (Glob (MN 0 "fn"))])
221+ cases))
219222 where
220223 applyCase (n, t, ApplyCase x) = Just x
221224 applyCase _ = Nothing