diff src/mono_util.sml @ 182:d11754ffe252

Compiled pattern matching to C
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 12:43:20 -0400
parents 3bbed533fbd2
children 8e9f97508f0d
line wrap: on
line diff
--- a/src/mono_util.sml	Sun Aug 03 11:17:33 2008 -0400
+++ b/src/mono_util.sml	Sun Aug 03 12:43:20 2008 -0400
@@ -181,30 +181,30 @@
                       fn e' =>
                          (EField (e', x), loc))
 
-              | ECase (e, pes, t) =>
+              | ECase (e, pes, {disc, result}) =>
                 S.bind2 (mfe ctx e,
                          fn e' =>
                             S.bind2 (ListUtil.mapfold (fn (p, e) =>
                                                           let
-                                                              val dummyt = (TFfi ("", ""), ErrorMsg.dummySpan)
-
                                                               fun pb ((p, _), ctx) =
                                                                   case p of
                                                                       PWild => ctx
-                                                                    | PVar x => bind (ctx, RelE (x, dummyt))
+                                                                    | PVar (x, t) => bind (ctx, RelE (x, t))
                                                                     | PPrim _ => ctx
                                                                     | PCon (_, NONE) => ctx
                                                                     | PCon (_, SOME p) => pb (p, ctx)
-                                                                    | PRecord xps => foldl (fn ((_, p), ctx) =>
+                                                                    | PRecord xps => foldl (fn ((_, p, _), ctx) =>
                                                                                                pb (p, ctx)) ctx xps
                                                           in
                                                               S.map2 (mfe (pb (p, ctx)) e,
                                                                    fn e' => (p, e'))
                                                           end) pes,
                                     fn pes' =>
-                                       S.map2 (mft t,
-                                               fn t' =>
-                                                  (ECase (e', pes', t'), loc))))
+                                       S.bind2 (mft disc,
+                                                fn disc' =>
+                                                   S.map2 (mft result,
+                                                        fn result' =>
+                                                           (ECase (e', pes', {disc = disc', result = result'}), loc)))))
 
               | EStrcat (e1, e2) =>
                 S.bind2 (mfe ctx e1,