Mercurial > urweb
comparison src/monoize.sml @ 164:6847741e1f5f
Datatypes through monoize
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 29 Jul 2008 13:32:07 -0400 |
parents | 80192edca30d |
children | 2be573fec9a6 |
comparison
equal
deleted
inserted
replaced
163:80192edca30d | 164:6847741e1f5f |
---|---|
112 case t of | 112 case t of |
113 L'.TFfi ("Basis", "string") => (L'.EFfiApp ("Basis", name ^ "ifyString", [e]), loc) | 113 L'.TFfi ("Basis", "string") => (L'.EFfiApp ("Basis", name ^ "ifyString", [e]), loc) |
114 | L'.TFfi ("Basis", "int") => (L'.EFfiApp ("Basis", name ^ "ifyInt", [e]), loc) | 114 | L'.TFfi ("Basis", "int") => (L'.EFfiApp ("Basis", name ^ "ifyInt", [e]), loc) |
115 | L'.TFfi ("Basis", "float") => (L'.EFfiApp ("Basis", name ^ "ifyFloat", [e]), loc) | 115 | L'.TFfi ("Basis", "float") => (L'.EFfiApp ("Basis", name ^ "ifyFloat", [e]), loc) |
116 | L'.TRecord [] => (L'.EPrim (Prim.String ""), loc) | 116 | L'.TRecord [] => (L'.EPrim (Prim.String ""), loc) |
117 | |
118 | L'.TNamed _ => (L'.EPrim (Prim.String ""), loc) | |
117 | 119 |
118 | _ => (E.errorAt loc "Don't know how to encode attribute type"; | 120 | _ => (E.errorAt loc "Don't know how to encode attribute type"; |
119 Print.eprefaces' [("Type", MonoPrint.p_typ MonoEnv.empty tAll)]; | 121 Print.eprefaces' [("Type", MonoPrint.p_typ MonoEnv.empty tAll)]; |
120 dummyExp) | 122 dummyExp) |
121 in | 123 in |
451 Print.eprefaces' [("Declaration", CorePrint.p_decl env all)]; | 453 Print.eprefaces' [("Declaration", CorePrint.p_decl env all)]; |
452 NONE) | 454 NONE) |
453 in | 455 in |
454 case d of | 456 case d of |
455 L.DCon _ => NONE | 457 L.DCon _ => NONE |
456 | L.DDatatype _ => raise Fail "Monoize DDatatype" | 458 | L.DDatatype (x, n, xncs) => |
459 let | |
460 val d = (L'.DDatatype (x, n, map (fn (x, n, to) => (x, n, Option.map (monoType env) to)) xncs), loc) | |
461 in | |
462 SOME (Env.declBinds env all, d) | |
463 end | |
457 | L.DVal (x, n, t, e, s) => SOME (Env.pushENamed env x n t (SOME e) s, | 464 | L.DVal (x, n, t, e, s) => SOME (Env.pushENamed env x n t (SOME e) s, |
458 (L'.DVal (x, n, monoType env t, monoExp (env, St.empty) e, s), loc)) | 465 (L'.DVal (x, n, monoType env t, monoExp (env, St.empty) e, s), loc)) |
459 | L.DValRec vis => | 466 | L.DValRec vis => |
460 let | 467 let |
461 val env = foldl (fn ((x, n, t, e, s), env) => Env.pushENamed env x n t NONE s) env vis | 468 val env = foldl (fn ((x, n, t, e, s), env) => Env.pushENamed env x n t NONE s) env vis |