diff src/monoize.sml @ 1655:b694f9153faa

Adapt Monoize serialization to handle freshly created variant types
author Adam Chlipala <adam@chlipala.net>
date Mon, 02 Jan 2012 16:54:18 -0500
parents dfc854e478bb
children 0577be31a435
line wrap: on
line diff
--- a/src/monoize.sml	Mon Jan 02 15:38:52 2012 -0500
+++ b/src/monoize.sml	Mon Jan 02 16:54:18 2012 -0500
@@ -531,7 +531,20 @@
                     let
                         fun makeDecl n fm =
                             let
-                                val (x, _, xncs) = Env.lookupDatatype env i
+                                val (x, xncs) =
+                                    case ListUtil.search (fn (L'.DDatatype [(x, i', xncs)], _) =>
+                                                             if i' = i then
+                                                                 SOME (x, xncs)
+                                                             else
+                                                                 NONE
+                                                           | _ => NONE) (!pvarDefs) of
+                                        NONE =>
+                                        let
+                                            val (x, _, xncs) = Env.lookupDatatype env i
+                                        in
+                                            (x, map (fn (x, n, c) => (x, n, Option.map (monoType env) c)) xncs)
+                                        end
+                                      | SOME v => v
 
                                 val (branches, fm) =
                                     ListUtil.foldlMap
@@ -543,7 +556,6 @@
                                                  fm)
                                               | SOME t =>
                                                 let
-                                                    val t = monoType env t
                                                     val (arg, fm) = fooify fm ((L'.ERel 0, loc), t)
                                                 in
                                                     (((L'.PCon (dk, L'.PConVar n, SOME (L'.PVar ("a", t), loc)), loc),