summaryrefslogtreecommitdiff
path: root/src/cjr_print.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-30 11:48:56 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-30 11:48:56 -0400
commit1a60a233b9349f320e67f35db1aa3b87d7c2a591 (patch)
tree3c14a4c191641933ffd1dc31c3d4d34535687368 /src/cjr_print.sml
parent7a3ba5558cb363006aae188e02dd57dda833d356 (diff)
Subforms type-checks; lists urlified and unurlified
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r--src/cjr_print.sml75
1 files changed, 71 insertions, 4 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index ee2307b6..babd0315 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -333,10 +333,6 @@ fun p_pat (env, exit, depth) (p, loc) =
in
(box [string "{",
newline,
- string "/* ",
- string (ErrorMsg.spanToString loc),
- string "*/",
- newline,
p_typ env t,
space,
string "disc",
@@ -864,6 +860,77 @@ fun unurlify env (t, loc) =
string "})"]
end
+ | TList (t', i) =>
+ if IS.member (rf, i) then
+ box [string "unurlify_list_",
+ string (Int.toString i),
+ string "()"]
+ else
+ let
+ val rf = IS.add (rf, i)
+ in
+ box [string "({",
+ space,
+ p_typ env (t, loc),
+ space,
+ string "unurlify_list_",
+ string (Int.toString i),
+ string "(void) {",
+ newline,
+ box [string "return (request[0] == '/' ? ++request : request,",
+ newline,
+ string "((!strncmp(request, \"Nil\", 3) && (request[3] == 0 ",
+ string "|| request[3] == '/')) ? (request",
+ space,
+ string "+=",
+ space,
+ string "3, NULL) : ((!strncmp(request, \"Cons\", 4) && (request[4] == 0 ",
+ string "|| request[4] == '/')) ? (request",
+ space,
+ string "+=",
+ space,
+ string "4, (request[0] == '/' ? ++request : NULL), ",
+ newline,
+
+ string "({",
+ newline,
+ p_typ env (t, loc),
+ space,
+ string "tmp",
+ space,
+ string "=",
+ space,
+ string "uw_malloc(ctx, sizeof(struct __uws_",
+ string (Int.toString i),
+ string "));",
+ newline,
+ string "*tmp",
+ space,
+ string "=",
+ space,
+ unurlify' rf (TRecord i),
+ string ";",
+ newline,
+ string "tmp;",
+ newline,
+ string "})",
+ string ")",
+ newline,
+ string ":",
+ space,
+ string ("(uw_error(ctx, FATAL, \"Error unurlifying list\"), NULL))));"),
+ newline],
+ string "}",
+ newline,
+ newline,
+
+ string "unurlify_list_",
+ string (Int.toString i),
+ string "();",
+ newline,
+ string "})"]
+ end
+
| TOption t =>
box [string "(request[0] == '/' ? ++request : request, ",
string "((!strncmp(request, \"None\", 4) ",