on master help sign in
Merge pull request #214 from bitlisp/trivialdefun

Generate legal DChkCase expressions when defunctionalization is trivial

commitb1037e1ded99b1f0685f1cb188058693e1525e97 authorEdwin Brady <edwin.brady@gmail.com> dateSat 9 Mar 2013, 04:40 (14 years ago) parentae62b2fc70992b
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