on master help sign in
Generate legal DChkCase expressions when defunctionalization is trivial
c70992bBenjamin Saunders
src/IRTS/Defunctionalise.hs+7−4
@@ -212,10 +212,13 @@ mkEval xs = (MN 0 "EVAL", DFun (MN 0 "EVAL") [MN 0 "arg"]
212
212
213mkApply :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
213mkApply :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
214mkApply xs = (MN 0 "APPLY", DFun (MN 0 "APPLY") [MN 0 "fn", MN 0 "arg"]
214mkApply xs = (MN 0 "APPLY", DFun (MN 0 "APPLY") [MN 0 "fn", MN 0 "arg"]
215+ (case mapMaybe applyCase xs of
216+ [] -> DNothing
217+ cases ->
215− (mkBigCase (MN 0 "APPLY")
218+ mkBigCase (MN 0 "APPLY") 256
216− 256 (DApp False (MN 0 "EVAL")
219+ (DApp False (MN 0 "EVAL")
217− [DV (Glob (MN 0 "fn"))])
220+ [DV (Glob (MN 0 "fn"))])
218− (mapMaybe applyCase xs)))
221+ cases))
219 where
222 where
220 applyCase (n, t, ApplyCase x) = Just x
223 applyCase (n, t, ApplyCase x) = Just x
221 applyCase _ = Nothing
224 applyCase _ = Nothing