Mercurial > urweb
comparison src/cjr_print.sml @ 758:8323c1beef2e
Subforms type-checks; lists urlified and unurlified
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 30 Apr 2009 11:48:56 -0400 |
parents | fa2019a63ea4 |
children | 67cd8326f743 |
comparison
equal
deleted
inserted
replaced
757:fa2019a63ea4 | 758:8323c1beef2e |
---|---|
330 val (p, env) = | 330 val (p, env) = |
331 let | 331 let |
332 val (p, env) = p_pat (env, exit, depth + 1) p | 332 val (p, env) = p_pat (env, exit, depth + 1) p |
333 in | 333 in |
334 (box [string "{", | 334 (box [string "{", |
335 newline, | |
336 string "/* ", | |
337 string (ErrorMsg.spanToString loc), | |
338 string "*/", | |
339 newline, | 335 newline, |
340 p_typ env t, | 336 p_typ env t, |
341 space, | 337 space, |
342 string "disc", | 338 string "disc", |
343 string (Int.toString (depth + 1)), | 339 string (Int.toString (depth + 1)), |
856 string "}", | 852 string "}", |
857 newline, | 853 newline, |
858 newline, | 854 newline, |
859 | 855 |
860 string "unurlify_", | 856 string "unurlify_", |
857 string (Int.toString i), | |
858 string "();", | |
859 newline, | |
860 string "})"] | |
861 end | |
862 | |
863 | TList (t', i) => | |
864 if IS.member (rf, i) then | |
865 box [string "unurlify_list_", | |
866 string (Int.toString i), | |
867 string "()"] | |
868 else | |
869 let | |
870 val rf = IS.add (rf, i) | |
871 in | |
872 box [string "({", | |
873 space, | |
874 p_typ env (t, loc), | |
875 space, | |
876 string "unurlify_list_", | |
877 string (Int.toString i), | |
878 string "(void) {", | |
879 newline, | |
880 box [string "return (request[0] == '/' ? ++request : request,", | |
881 newline, | |
882 string "((!strncmp(request, \"Nil\", 3) && (request[3] == 0 ", | |
883 string "|| request[3] == '/')) ? (request", | |
884 space, | |
885 string "+=", | |
886 space, | |
887 string "3, NULL) : ((!strncmp(request, \"Cons\", 4) && (request[4] == 0 ", | |
888 string "|| request[4] == '/')) ? (request", | |
889 space, | |
890 string "+=", | |
891 space, | |
892 string "4, (request[0] == '/' ? ++request : NULL), ", | |
893 newline, | |
894 | |
895 string "({", | |
896 newline, | |
897 p_typ env (t, loc), | |
898 space, | |
899 string "tmp", | |
900 space, | |
901 string "=", | |
902 space, | |
903 string "uw_malloc(ctx, sizeof(struct __uws_", | |
904 string (Int.toString i), | |
905 string "));", | |
906 newline, | |
907 string "*tmp", | |
908 space, | |
909 string "=", | |
910 space, | |
911 unurlify' rf (TRecord i), | |
912 string ";", | |
913 newline, | |
914 string "tmp;", | |
915 newline, | |
916 string "})", | |
917 string ")", | |
918 newline, | |
919 string ":", | |
920 space, | |
921 string ("(uw_error(ctx, FATAL, \"Error unurlifying list\"), NULL))));"), | |
922 newline], | |
923 string "}", | |
924 newline, | |
925 newline, | |
926 | |
927 string "unurlify_list_", | |
861 string (Int.toString i), | 928 string (Int.toString i), |
862 string "();", | 929 string "();", |
863 newline, | 930 newline, |
864 string "})"] | 931 string "})"] |
865 end | 932 end |