Mercurial > urweb
diff src/cjr_print.sml @ 196:890a61991263
Lists all the way through
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 09 Aug 2008 16:48:32 -0400 |
parents | 3eb53c957d10 |
children | b1b9bcfd8c42 |
line wrap: on
line diff
--- a/src/cjr_print.sml Sat Aug 09 12:50:49 2008 -0400 +++ b/src/cjr_print.sml Sat Aug 09 16:48:32 2008 -0400 @@ -53,7 +53,7 @@ val debug = ref false -val dummyTyp = (TDatatype (Enum, 0, []), ErrorMsg.dummySpan) +val dummyTyp = (TDatatype (Enum, 0, ref []), ErrorMsg.dummySpan) fun p_typ' par env (t, loc) = case t of @@ -106,7 +106,7 @@ string (Int.toString (E.countERels env)), string ";", newline], - env) + E.pushERel env x t) | PPrim _ => (box [], env) | PCon (_, _, NONE) => (box [], env) | PCon (_, _, SOME p) => p_pat_preamble env p @@ -180,7 +180,7 @@ let val (x, to, _) = E.lookupConstructor env n in - ("__lwc_" ^ x, to) + ("lw_" ^ x, to) end | PConFfi {mod = m, con, arg, ...} => ("lw_" ^ m ^ "_" ^ con, arg) @@ -247,7 +247,7 @@ space, string "disc", string (Int.toString depth), - string ".", + string ".__lwf_", string x, string ";", newline, @@ -282,11 +282,13 @@ val (dx, _) = E.lookupDatatype env dn in ("__lwd_" ^ dx ^ "_" ^ Int.toString dn, - "__lwc_" ^ x ^ "_" ^ Int.toString n) + "__lwc_" ^ x ^ "_" ^ Int.toString n, + "lw_" ^ x) end | PConFfi {mod = m, datatyp, con, ...} => ("lw_" ^ m ^ "_" ^ datatyp, - "lw_" ^ m ^ "_" ^ con) + "lw_" ^ m ^ "_" ^ con, + "lw_" ^ con) fun p_exp' par env (e, loc) = case e of @@ -296,7 +298,7 @@ | ECon (Enum, pc, _) => p_patCon env pc | ECon (Default, pc, eo) => let - val (xd, xc) = patConInfo env pc + val (xd, xc, xn) = patConInfo env pc in box [string "({", newline, @@ -322,7 +324,7 @@ case eo of NONE => box [] | SOME e => box [string "tmp->data.", - string xd, + string xn, space, string "=", space, @@ -493,19 +495,23 @@ fun p_decl env (dAll as (d, _) : decl) = case d of DStruct (n, xts) => - box [string "struct", - space, - string ("__lws_" ^ Int.toString n), - space, - string "{", - newline, - p_list_sep (box []) (fn (x, t) => box [p_typ env t, - space, - string "__lwf_", - string x, - string ";", - newline]) xts, - string "};"] + let + val env = E.declBinds env dAll + in + box [string "struct", + space, + string ("__lws_" ^ Int.toString n), + space, + string "{", + newline, + p_list_sep (box []) (fn (x, t) => box [p_typ env t, + space, + string "__lwf_", + string x, + string ";", + newline]) xts, + string "};"] + end | DDatatype (Enum, x, n, xncs) => box [string "enum", space, @@ -552,7 +558,7 @@ newline, p_list_sep newline (fn (x, n, t) => box [p_typ env t, space, - string ("__lwc_" ^ x), + string ("lw_" ^ x), string ";"]) xncsArgs, newline, string "}", @@ -562,6 +568,8 @@ string "};"] end + | DDatatypeForward _ => box [] + | DVal (x, n, t, e) => box [p_typ env t, space, @@ -1003,18 +1011,6 @@ newline, string "int lw_input_num(char *name) {", newline, - string "if", - space, - string "(name[0]", - space, - string "==", - space, - string "0)", - space, - string "return", - space, - string "-1;", - newline, makeSwitch (fnums, 0), string "}", newline,