comparison src/cjr_print.sml @ 199:c938fe391c84

strings get 'Option' datatype handling; fix datatype unurlifying
author Adam Chlipala <adamc@hcoop.net>
date Sat, 09 Aug 2008 19:46:12 -0400
parents ab86aa858e6c
children 5dbba661deab
comparison
equal deleted inserted replaced
198:ab86aa858e6c 199:c938fe391c84
78 (case ListUtil.search #3 (!xncs) of 78 (case ListUtil.search #3 (!xncs) of
79 NONE => raise Fail "CjrPrint: TDatatype marked Option has no constructor with an argument" 79 NONE => raise Fail "CjrPrint: TDatatype marked Option has no constructor with an argument"
80 | SOME t => 80 | SOME t =>
81 case #1 t of 81 case #1 t of
82 TDatatype _ => p_typ' par env t 82 TDatatype _ => p_typ' par env t
83 | TFfi ("Basis", "string") => p_typ' par env t
83 | _ => box [p_typ' par env t, 84 | _ => box [p_typ' par env t,
84 string "*"]) 85 string "*"])
85 | TDatatype (Default, n, _) => 86 | TDatatype (Default, n, _) =>
86 (box [string "struct", 87 (box [string "struct",
87 space, 88 space,
214 string x] 215 string x]
215 | Option => 216 | Option =>
216 case #1 t of 217 case #1 t of
217 TDatatype _ => box [string "disc", 218 TDatatype _ => box [string "disc",
218 string (Int.toString depth)] 219 string (Int.toString depth)]
220 | TFfi ("Basis", "string") => box [string "disc",
221 string (Int.toString depth)]
219 | _ => box [string "*disc", 222 | _ => box [string "*disc",
220 string (Int.toString depth)], 223 string (Int.toString depth)],
221 string ";", 224 string ";",
222 newline, 225 newline,
223 p, 226 p,
334 NONE => raise Fail "CjrPrint: ECon argument status mismatch" 337 NONE => raise Fail "CjrPrint: ECon argument status mismatch"
335 | SOME t => t 338 | SOME t => t
336 in 339 in
337 case #1 t of 340 case #1 t of
338 TDatatype _ => p_exp' par env e 341 TDatatype _ => p_exp' par env e
342 | TFfi ("Basis", "string") => p_exp' par env e
339 | _ => box [string "({", 343 | _ => box [string "({",
340 newline, 344 newline,
341 p_typ env t, 345 p_typ env t,
342 space, 346 space,
343 string "*tmp", 347 string "*tmp",
912 string (Int.toString (size has_arg)), 916 string (Int.toString (size has_arg)),
913 string ", ", 917 string ", ",
914 918
915 case #1 t of 919 case #1 t of
916 TDatatype _ => unurlify t 920 TDatatype _ => unurlify t
921 | TFfi ("Basis", "string") => unurlify t
917 | _ => box [string "({", 922 | _ => box [string "({",
918 newline, 923 newline,
919 p_typ env t, 924 p_typ env t,
920 space, 925 space,
921 string "*tmp", 926 string "*tmp",
982 space, 987 space,
983 string "+=", 988 string "+=",
984 space, 989 space,
985 string (Int.toString (size x')), 990 string (Int.toString (size x')),
986 string ";", 991 string ";",
987 newline,
988 string "if (request[0] == '/') ++request;",
989 newline, 992 newline,
990 case to of 993 case to of
991 NONE => box [] 994 NONE => box []
992 | SOME t => box [string "tmp->data.lw_", 995 | SOME t => box [string "tmp->data.lw_",
993 string x', 996 string x',