comparison src/cjr_print.sml @ 186:88d46972de53

bool in Basis
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 Aug 2008 18:53:20 -0400
parents 19ee24bffbc0
children 8e9f97508f0d
comparison
equal deleted inserted replaced
185:19ee24bffbc0 186:88d46972de53
114 end) (box [], env) xps 114 end) (box [], env) xps
115 115
116 fun p_patCon env pc = 116 fun p_patCon env pc =
117 case pc of 117 case pc of
118 PConVar n => p_con_named env n 118 PConVar n => p_con_named env n
119 | PConFfi _ => raise Fail "CjrPrint PConFfi" 119 | PConFfi {mod = m, con, ...} => string ("lw_" ^ m ^ "_" ^ con)
120 120
121 fun p_pat (env, exit, depth) (p, _) = 121 fun p_pat (env, exit, depth) (p, _) =
122 case p of 122 case p of
123 PWild => 123 PWild =>
124 (box [], env) 124 (box [], env)
274 val (dx, _) = E.lookupDatatype env dn 274 val (dx, _) = E.lookupDatatype env dn
275 in 275 in
276 ("__lwd_" ^ dx ^ "_" ^ Int.toString dn, 276 ("__lwd_" ^ dx ^ "_" ^ Int.toString dn,
277 "__lwc_" ^ x ^ "_" ^ Int.toString n) 277 "__lwc_" ^ x ^ "_" ^ Int.toString n)
278 end 278 end
279 | PConFfi {mod = m, datatyp, con} => 279 | PConFfi {mod = m, datatyp, con, ...} =>
280 ("lw_" ^ m ^ "_" ^ datatyp, 280 ("lw_" ^ m ^ "_" ^ datatyp,
281 "lw_" ^ m ^ "_" ^ con) 281 "lw_" ^ m ^ "_" ^ con)
282 282
283 fun p_exp' par env (e, loc) = 283 fun p_exp' par env (e, loc) =
284 case e of 284 case e of
704 string "-1;", 704 string "-1;",
705 newline, 705 newline,
706 string "}"] 706 string "}"]
707 end 707 end
708 708
709 fun capitalize s =
710 if s = "" then
711 ""
712 else
713 str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
714
709 fun unurlify (t, loc) = 715 fun unurlify (t, loc) =
710 case t of 716 case t of
711 TFfi ("Basis", "int") => string "lw_unurlifyInt(&request)" 717 TFfi (m, t) => string ("lw_" ^ m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)")
712 | TFfi ("Basis", "float") => string "lw_unurlifyFloat(&request)"
713 | TFfi ("Basis", "string") => string "lw_unurlifyString(ctx, &request)"
714 718
715 | TRecord 0 => string "lw_unit_v" 719 | TRecord 0 => string "lw_unit_v"
716 | TRecord i => 720 | TRecord i =>
717 let 721 let
718 val xts = E.lookupStruct env i 722 val xts = E.lookupStruct env i