Mercurial > urweb
comparison src/cjr_print.sml @ 316:04ebfe929a98
Unpolyed a polymorphic function of two arguments
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 11 Sep 2008 10:14:59 -0400 |
parents | a07f476d9b61 |
children | aa89b73d83e4 |
comparison
equal
deleted
inserted
replaced
315:e21d0dddda09 | 316:04ebfe929a98 |
---|---|
54 end) | 54 end) |
55 | 55 |
56 val debug = ref false | 56 val debug = ref false |
57 | 57 |
58 val dummyTyp = (TDatatype (Enum, 0, ref []), ErrorMsg.dummySpan) | 58 val dummyTyp = (TDatatype (Enum, 0, ref []), ErrorMsg.dummySpan) |
59 | |
60 val ident = String.translate (fn #"'" => "PRIME" | |
61 | ch => str ch) | |
62 | |
63 val p_ident = string o ident | |
59 | 64 |
60 fun p_typ' par env (t, loc) = | 65 fun p_typ' par env (t, loc) = |
61 case t of | 66 case t of |
62 TFun (t1, t2) => parenIf par (box [p_typ' true env t2, | 67 TFun (t1, t2) => parenIf par (box [p_typ' true env t2, |
63 space, | 68 space, |
87 | TDatatype (Default, n, _) => | 92 | TDatatype (Default, n, _) => |
88 (box [string "struct", | 93 (box [string "struct", |
89 space, | 94 space, |
90 string ("__uwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")] | 95 string ("__uwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")] |
91 handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n)) | 96 handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n)) |
92 | TFfi (m, x) => box [string "uw_", string m, string "_", string x] | 97 | TFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x] |
93 | TOption t => | 98 | TOption t => |
94 (case #1 t of | 99 (case #1 t of |
95 TDatatype _ => p_typ' par env t | 100 TDatatype _ => p_typ' par env t |
96 | TFfi ("Basis", "string") => p_typ' par env t | 101 | TFfi ("Basis", "string") => p_typ' par env t |
97 | _ => box [p_typ' par env t, | 102 | _ => box [p_typ' par env t, |
98 string "*"]) | 103 string "*"]) |
99 | 104 |
100 and p_typ env = p_typ' false env | 105 and p_typ env = p_typ' false env |
101 | 106 |
102 fun p_rel env n = string ("__uwr_" ^ #1 (E.lookupERel env n) ^ "_" ^ Int.toString (E.countERels env - n - 1)) | 107 fun p_rel env n = string ("__uwr_" ^ ident (#1 (E.lookupERel env n)) ^ "_" ^ Int.toString (E.countERels env - n - 1)) |
103 handle CjrEnv.UnboundRel _ => string ("__uwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1)) | 108 handle CjrEnv.UnboundRel _ => string ("__uwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1)) |
104 | 109 |
105 fun p_enamed env n = | 110 fun p_enamed env n = |
106 string ("__uwn_" ^ #1 (E.lookupENamed env n) ^ "_" ^ Int.toString n) | 111 string ("__uwn_" ^ ident (#1 (E.lookupENamed env n)) ^ "_" ^ Int.toString n) |
107 handle CjrEnv.UnboundNamed _ => string ("__uwn_UNBOUND_" ^ Int.toString n) | 112 handle CjrEnv.UnboundNamed _ => string ("__uwn_UNBOUND_" ^ Int.toString n) |
108 | 113 |
109 fun p_con_named env n = | 114 fun p_con_named env n = |
110 string ("__uwc_" ^ #1 (E.lookupConstructor env n) ^ "_" ^ Int.toString n) | 115 string ("__uwc_" ^ ident (#1 (E.lookupConstructor env n)) ^ "_" ^ Int.toString n) |
111 handle CjrEnv.UnboundNamed _ => string ("__uwc_UNBOUND_" ^ Int.toString n) | 116 handle CjrEnv.UnboundNamed _ => string ("__uwc_UNBOUND_" ^ Int.toString n) |
112 | 117 |
113 fun p_pat_preamble env (p, _) = | 118 fun p_pat_preamble env (p, _) = |
114 case p of | 119 case p of |
115 PWild => (box [], | 120 PWild => (box [], |
116 env) | 121 env) |
117 | PVar (x, t) => (box [p_typ env t, | 122 | PVar (x, t) => (box [p_typ env t, |
118 space, | 123 space, |
119 string "__uwr_", | 124 string "__uwr_", |
120 string x, | 125 p_ident x, |
121 string "_", | 126 string "_", |
122 string (Int.toString (E.countERels env)), | 127 string (Int.toString (E.countERels env)), |
123 string ";", | 128 string ";", |
124 newline], | 129 newline], |
125 E.pushERel env x t) | 130 E.pushERel env x t) |
137 | PSome (_, p) => p_pat_preamble env p | 142 | PSome (_, p) => p_pat_preamble env p |
138 | 143 |
139 fun p_patCon env pc = | 144 fun p_patCon env pc = |
140 case pc of | 145 case pc of |
141 PConVar n => p_con_named env n | 146 PConVar n => p_con_named env n |
142 | PConFfi {mod = m, con, ...} => string ("uw_" ^ m ^ "_" ^ con) | 147 | PConFfi {mod = m, con, ...} => string ("uw_" ^ ident m ^ "_" ^ ident con) |
143 | 148 |
144 fun p_pat (env, exit, depth) (p, _) = | 149 fun p_pat (env, exit, depth) (p, _) = |
145 case p of | 150 case p of |
146 PWild => | 151 PWild => |
147 (box [], env) | 152 (box [], env) |
148 | PVar (x, t) => | 153 | PVar (x, t) => |
149 (box [string "__uwr_", | 154 (box [string "__uwr_", |
150 string x, | 155 p_ident x, |
151 string "_", | 156 string "_", |
152 string (Int.toString (E.countERels env)), | 157 string (Int.toString (E.countERels env)), |
153 space, | 158 space, |
154 string "=", | 159 string "=", |
155 space, | 160 space, |
196 val (x, to) = case pc of | 201 val (x, to) = case pc of |
197 PConVar n => | 202 PConVar n => |
198 let | 203 let |
199 val (x, to, _) = E.lookupConstructor env n | 204 val (x, to, _) = E.lookupConstructor env n |
200 in | 205 in |
201 ("uw_" ^ x, to) | 206 ("uw_" ^ ident x, to) |
202 end | 207 end |
203 | PConFfi {mod = m, con, arg, ...} => | 208 | PConFfi {mod = m, con, arg, ...} => |
204 ("uw_" ^ m ^ "_" ^ con, arg) | 209 ("uw_" ^ ident m ^ "_" ^ ident con, arg) |
205 | 210 |
206 val t = case to of | 211 val t = case to of |
207 NONE => raise Fail "CjrPrint: Constructor mismatch" | 212 NONE => raise Fail "CjrPrint: Constructor mismatch" |
208 | SOME t => t | 213 | SOME t => t |
209 in | 214 in |
285 string "=", | 290 string "=", |
286 space, | 291 space, |
287 string "disc", | 292 string "disc", |
288 string (Int.toString depth), | 293 string (Int.toString depth), |
289 string ".__uwf_", | 294 string ".__uwf_", |
290 string x, | 295 p_ident x, |
291 string ";", | 296 string ";", |
292 newline, | 297 newline, |
293 p, | 298 p, |
294 newline, | 299 newline, |
295 string "}"] | 300 string "}"] |
377 PConVar n => | 382 PConVar n => |
378 let | 383 let |
379 val (x, _, dn) = E.lookupConstructor env n | 384 val (x, _, dn) = E.lookupConstructor env n |
380 val (dx, _) = E.lookupDatatype env dn | 385 val (dx, _) = E.lookupDatatype env dn |
381 in | 386 in |
382 ("__uwd_" ^ dx ^ "_" ^ Int.toString dn, | 387 ("__uwd_" ^ ident dx ^ "_" ^ Int.toString dn, |
383 "__uwc_" ^ x ^ "_" ^ Int.toString n, | 388 "__uwc_" ^ ident x ^ "_" ^ Int.toString n, |
384 "uw_" ^ x) | 389 "uw_" ^ ident x) |
385 end | 390 end |
386 | PConFfi {mod = m, datatyp, con, ...} => | 391 | PConFfi {mod = m, datatyp, con, ...} => |
387 ("uw_" ^ m ^ "_" ^ datatyp, | 392 ("uw_" ^ ident m ^ "_" ^ ident datatyp, |
388 "uw_" ^ m ^ "_" ^ con, | 393 "uw_" ^ ident m ^ "_" ^ ident con, |
389 "uw_" ^ con) | 394 "uw_" ^ ident con) |
390 | 395 |
391 fun p_unsql env (tAll as (t, loc)) e = | 396 fun p_unsql env (tAll as (t, loc)) e = |
392 case t of | 397 case t of |
393 TFfi ("Basis", "int") => box [string "uw_Basis_stringToInt_error(ctx, ", e, string ")"] | 398 TFfi ("Basis", "int") => box [string "uw_Basis_stringToInt_error(ctx, ", e, string ")"] |
394 | TFfi ("Basis", "float") => box [string "uw_Basis_stringToFloat_error(ctx, ", e, string ")"] | 399 | TFfi ("Basis", "float") => box [string "uw_Basis_stringToFloat_error(ctx, ", e, string ")"] |
543 newline, | 548 newline, |
544 string "tmp;", | 549 string "tmp;", |
545 newline, | 550 newline, |
546 string "})"]) | 551 string "})"]) |
547 | 552 |
548 | EFfi (m, x) => box [string "uw_", string m, string "_", string x] | 553 | EFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x] |
549 | EError (e, t) => | 554 | EError (e, t) => |
550 box [string "({", | 555 box [string "({", |
551 newline, | 556 newline, |
552 p_typ env t, | 557 p_typ env t, |
553 space, | 558 space, |
561 newline, | 566 newline, |
562 string "tmp;", | 567 string "tmp;", |
563 newline, | 568 newline, |
564 string "})"] | 569 string "})"] |
565 | EFfiApp (m, x, es) => box [string "uw_", | 570 | EFfiApp (m, x, es) => box [string "uw_", |
566 string m, | 571 p_ident m, |
567 string "_", | 572 string "_", |
568 string x, | 573 p_ident x, |
569 string "(ctx, ", | 574 string "(ctx, ", |
570 p_list (p_exp env) es, | 575 p_list (p_exp env) es, |
571 string ")"] | 576 string ")"] |
572 | EApp (e1, e2) => | 577 | EApp (f, args) => |
573 let | 578 parenIf par (box [p_exp' true env f, |
574 fun unravel (f, acc) = | 579 string "(ctx,", |
575 case #1 f of | 580 space, |
576 EApp (f', arg) => unravel (f', arg :: acc) | 581 p_list_sep (box [string ",", space]) (p_exp env) args, |
577 | _ => (f, acc) | 582 string ")"]) |
578 | |
579 val (f, args) = unravel (e1, [e2]) | |
580 in | |
581 parenIf par (box [p_exp' true env e1, | |
582 string "(ctx,", | |
583 space, | |
584 p_list_sep (box [string ",", space]) (p_exp env) args, | |
585 string ")"]) | |
586 end | |
587 | 583 |
588 | ERecord (i, xes) => box [string "({", | 584 | ERecord (i, xes) => box [string "({", |
589 space, | 585 space, |
590 string "struct", | 586 string "struct", |
591 space, | 587 space, |
604 space, | 600 space, |
605 string "})" ] | 601 string "})" ] |
606 | EField (e, x) => | 602 | EField (e, x) => |
607 box [p_exp' true env e, | 603 box [p_exp' true env e, |
608 string ".__uwf_", | 604 string ".__uwf_", |
609 string x] | 605 p_ident x] |
610 | 606 |
611 | ECase (e, pes, {disc, result}) => | 607 | ECase (e, pes, {disc, result}) => |
612 let | 608 let |
613 val final = newGoto () | 609 val final = newGoto () |
614 | 610 |
690 | ELet (x, t, e1, e2) => box [string "({", | 686 | ELet (x, t, e1, e2) => box [string "({", |
691 newline, | 687 newline, |
692 p_typ env t, | 688 p_typ env t, |
693 space, | 689 space, |
694 string "__uwr_", | 690 string "__uwr_", |
695 string x, | 691 p_ident x, |
696 string "_", | 692 string "_", |
697 string (Int.toString (E.countERels env)), | 693 string (Int.toString (E.countERels env)), |
698 space, | 694 space, |
699 string "=", | 695 string "=", |
700 space, | 696 space, |
706 newline, | 702 newline, |
707 string "})"] | 703 string "})"] |
708 | 704 |
709 | EQuery {exps, tables, rnum, state, query, body, initial, prepared} => | 705 | EQuery {exps, tables, rnum, state, query, body, initial, prepared} => |
710 let | 706 let |
711 val exps = map (fn (x, t) => ("__uwf_" ^ x, t)) exps | 707 val exps = map (fn (x, t) => ("__uwf_" ^ ident x, t)) exps |
712 val tables = ListUtil.mapConcat (fn (x, xts) => | 708 val tables = ListUtil.mapConcat (fn (x, xts) => |
713 map (fn (x', t) => ("__uwf_" ^ x ^ ".__uwf_" ^ x', t)) xts) | 709 map (fn (x', t) => ("__uwf_" ^ ident x ^ ".__uwf_" ^ ident x', t)) xts) |
714 tables | 710 tables |
715 | 711 |
716 val outputs = exps @ tables | 712 val outputs = exps @ tables |
717 in | 713 in |
718 box [string "({", | 714 box [string "({", |
943 in | 939 in |
944 box [string "static", | 940 box [string "static", |
945 space, | 941 space, |
946 p_typ env ran, | 942 p_typ env ran, |
947 space, | 943 space, |
948 string ("__uwn_" ^ fx ^ "_" ^ Int.toString n), | 944 string ("__uwn_" ^ ident fx ^ "_" ^ Int.toString n), |
949 string "(", | 945 string "(", |
950 p_list_sep (box [string ",", space]) (fn x => x) | 946 p_list_sep (box [string ",", space]) (fn x => x) |
951 (string "uw_context ctx" :: ListUtil.mapi (fn (i, (_, dom)) => | 947 (string "uw_context ctx" :: ListUtil.mapi (fn (i, (_, dom)) => |
952 box [p_typ env dom, | 948 box [p_typ env dom, |
953 space, | 949 space, |
976 string "{", | 972 string "{", |
977 newline, | 973 newline, |
978 p_list_sep (box []) (fn (x, t) => box [p_typ env t, | 974 p_list_sep (box []) (fn (x, t) => box [p_typ env t, |
979 space, | 975 space, |
980 string "__uwf_", | 976 string "__uwf_", |
981 string x, | 977 p_ident x, |
982 string ";", | 978 string ";", |
983 newline]) xts, | 979 newline]) xts, |
984 string "};"] | 980 string "};"] |
985 end | 981 end |
986 | DDatatype (Enum, x, n, xncs) => | 982 | DDatatype (Enum, x, n, xncs) => |
987 box [string "enum", | 983 box [string "enum", |
988 space, | 984 space, |
989 string ("__uwe_" ^ x ^ "_" ^ Int.toString n), | 985 string ("__uwe_" ^ ident x ^ "_" ^ Int.toString n), |
990 space, | 986 space, |
991 string "{", | 987 string "{", |
992 space, | 988 space, |
993 p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__uwc_" ^ x ^ "_" ^ Int.toString n)) xncs, | 989 p_list_sep (box [string ",", space]) (fn (x, n, _) => |
990 string ("__uwc_" ^ ident x ^ "_" ^ Int.toString n)) xncs, | |
994 space, | 991 space, |
995 string "};"] | 992 string "};"] |
996 | DDatatype (Option, _, _, _) => box [] | 993 | DDatatype (Option, _, _, _) => box [] |
997 | DDatatype (Default, x, n, xncs) => | 994 | DDatatype (Default, x, n, xncs) => |
998 let | 995 let |
999 val xncsArgs = List.mapPartial (fn (x, n, NONE) => NONE | 996 val xncsArgs = List.mapPartial (fn (x, n, NONE) => NONE |
1000 | (x, n, SOME t) => SOME (x, n, t)) xncs | 997 | (x, n, SOME t) => SOME (x, n, t)) xncs |
1001 in | 998 in |
1002 box [string "enum", | 999 box [string "enum", |
1003 space, | 1000 space, |
1004 string ("__uwe_" ^ x ^ "_" ^ Int.toString n), | 1001 string ("__uwe_" ^ ident x ^ "_" ^ Int.toString n), |
1005 space, | 1002 space, |
1006 string "{", | 1003 string "{", |
1007 space, | 1004 space, |
1008 p_list_sep (box [string ",", space]) (fn (x, n, _) => string ("__uwc_" ^ x ^ "_" ^ Int.toString n)) xncs, | 1005 p_list_sep (box [string ",", space]) (fn (x, n, _) => |
1006 string ("__uwc_" ^ ident x ^ "_" ^ Int.toString n)) xncs, | |
1009 space, | 1007 space, |
1010 string "};", | 1008 string "};", |
1011 newline, | 1009 newline, |
1012 newline, | 1010 newline, |
1013 string "struct", | 1011 string "struct", |
1014 space, | 1012 space, |
1015 string ("__uwd_" ^ x ^ "_" ^ Int.toString n), | 1013 string ("__uwd_" ^ ident x ^ "_" ^ Int.toString n), |
1016 space, | 1014 space, |
1017 string "{", | 1015 string "{", |
1018 newline, | 1016 newline, |
1019 string "enum", | 1017 string "enum", |
1020 space, | 1018 space, |
1021 string ("__uwe_" ^ x ^ "_" ^ Int.toString n), | 1019 string ("__uwe_" ^ ident x ^ "_" ^ Int.toString n), |
1022 space, | 1020 space, |
1023 string "tag;", | 1021 string "tag;", |
1024 newline, | 1022 newline, |
1025 box (case xncsArgs of | 1023 box (case xncsArgs of |
1026 [] => [] | 1024 [] => [] |
1028 space, | 1026 space, |
1029 string "{", | 1027 string "{", |
1030 newline, | 1028 newline, |
1031 p_list_sep newline (fn (x, n, t) => box [p_typ env t, | 1029 p_list_sep newline (fn (x, n, t) => box [p_typ env t, |
1032 space, | 1030 space, |
1033 string ("uw_" ^ x), | 1031 string ("uw_" ^ ident x), |
1034 string ";"]) xncsArgs, | 1032 string ";"]) xncsArgs, |
1035 newline, | 1033 newline, |
1036 string "}", | 1034 string "}", |
1037 space, | 1035 space, |
1038 string "data;", | 1036 string "data;", |
1043 | DDatatypeForward _ => box [] | 1041 | DDatatypeForward _ => box [] |
1044 | 1042 |
1045 | DVal (x, n, t, e) => | 1043 | DVal (x, n, t, e) => |
1046 box [p_typ env t, | 1044 box [p_typ env t, |
1047 space, | 1045 space, |
1048 string ("__uwn_" ^ x ^ "_" ^ Int.toString n), | 1046 string ("__uwn_" ^ ident x ^ "_" ^ Int.toString n), |
1049 space, | 1047 space, |
1050 string "=", | 1048 string "=", |
1051 space, | 1049 space, |
1052 p_exp env e, | 1050 p_exp env e, |
1053 string ";"] | 1051 string ";"] |
1059 box [p_list_sep newline (fn (fx, n, args, ran, _) => | 1057 box [p_list_sep newline (fn (fx, n, args, ran, _) => |
1060 box [string "static", | 1058 box [string "static", |
1061 space, | 1059 space, |
1062 p_typ env ran, | 1060 p_typ env ran, |
1063 space, | 1061 space, |
1064 string ("__uwn_" ^ fx ^ "_" ^ Int.toString n), | 1062 string ("__uwn_" ^ ident fx ^ "_" ^ Int.toString n), |
1065 string "(uw_context,", | 1063 string "(uw_context,", |
1066 space, | 1064 space, |
1067 p_list_sep (box [string ",", space]) | 1065 p_list_sep (box [string ",", space]) |
1068 (fn (_, dom) => p_typ env dom) args, | 1066 (fn (_, dom) => p_typ env dom) args, |
1069 string ");"]) vis, | 1067 string ");"]) vis, |
1312 else | 1310 else |
1313 str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) | 1311 str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) |
1314 | 1312 |
1315 fun unurlify (t, loc) = | 1313 fun unurlify (t, loc) = |
1316 case t of | 1314 case t of |
1317 TFfi (m, t) => string ("uw_" ^ m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)") | 1315 TFfi (m, t) => string ("uw_" ^ ident m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)") |
1318 | 1316 |
1319 | TRecord 0 => string "uw_unit_v" | 1317 | TRecord 0 => string "uw_unit_v" |
1320 | TRecord i => | 1318 | TRecord i => |
1321 let | 1319 let |
1322 val xts = E.lookupStruct env i | 1320 val xts = E.lookupStruct env i |
1368 string (Int.toString (size x')), | 1366 string (Int.toString (size x')), |
1369 string ") && (request[", | 1367 string ") && (request[", |
1370 string (Int.toString (size x')), | 1368 string (Int.toString (size x')), |
1371 string "] == 0 || request[", | 1369 string "] == 0 || request[", |
1372 string (Int.toString (size x')), | 1370 string (Int.toString (size x')), |
1373 string ("] == '/')) ? __uwc_" ^ x' ^ "_" ^ Int.toString n), | 1371 string ("] == '/')) ? __uwc_" ^ ident x' ^ "_" ^ Int.toString n), |
1374 space, | 1372 space, |
1375 string ":", | 1373 string ":", |
1376 space, | 1374 space, |
1377 doEm rest, | 1375 doEm rest, |
1378 string ")"] | 1376 string ")"] |
1473 string (Int.toString (size x')), | 1471 string (Int.toString (size x')), |
1474 string "] == '/')) ? ({", | 1472 string "] == '/')) ? ({", |
1475 newline, | 1473 newline, |
1476 string "struct", | 1474 string "struct", |
1477 space, | 1475 space, |
1478 string ("__uwd_" ^ x ^ "_" ^ Int.toString i), | 1476 string ("__uwd_" ^ ident x ^ "_" ^ Int.toString i), |
1479 space, | 1477 space, |
1480 string "*tmp = uw_malloc(ctx, sizeof(struct __uwd_", | 1478 string "*tmp = uw_malloc(ctx, sizeof(struct __uwd_", |
1481 string x, | 1479 string x, |
1482 string "_", | 1480 string "_", |
1483 string (Int.toString i), | 1481 string (Int.toString i), |
1485 newline, | 1483 newline, |
1486 string "tmp->tag", | 1484 string "tmp->tag", |
1487 space, | 1485 space, |
1488 string "=", | 1486 string "=", |
1489 space, | 1487 space, |
1490 string ("__uwc_" ^ x' ^ "_" ^ Int.toString n), | 1488 string ("__uwc_" ^ ident x' ^ "_" ^ Int.toString n), |
1491 string ";", | 1489 string ";", |
1492 newline, | 1490 newline, |
1493 string "request", | 1491 string "request", |
1494 space, | 1492 space, |
1495 string "+=", | 1493 string "+=", |
1500 string "if (request[0] == '/') ++request;", | 1498 string "if (request[0] == '/') ++request;", |
1501 newline, | 1499 newline, |
1502 case to of | 1500 case to of |
1503 NONE => box [] | 1501 NONE => box [] |
1504 | SOME t => box [string "tmp->data.uw_", | 1502 | SOME t => box [string "tmp->data.uw_", |
1505 string x', | 1503 p_ident x', |
1506 space, | 1504 space, |
1507 string "=", | 1505 string "=", |
1508 space, | 1506 space, |
1509 unurlify t, | 1507 unurlify t, |
1510 string ";", | 1508 string ";", |
1538 in | 1536 in |
1539 (List.take (ts, length ts - 2), | 1537 (List.take (ts, length ts - 2), |
1540 box [box (map (fn (x, t) => box [p_typ env t, | 1538 box [box (map (fn (x, t) => box [p_typ env t, |
1541 space, | 1539 space, |
1542 string "uw_input_", | 1540 string "uw_input_", |
1543 string x, | 1541 p_ident x, |
1544 string ";", | 1542 string ";", |
1545 newline]) xts), | 1543 newline]) xts), |
1546 newline, | 1544 newline, |
1547 box (map (fn (x, t) => | 1545 box (map (fn (x, t) => |
1548 let | 1546 let |
1569 string "exit(1);"], | 1567 string "exit(1);"], |
1570 newline, | 1568 newline, |
1571 string "}", | 1569 string "}", |
1572 newline, | 1570 newline, |
1573 string "uw_input_", | 1571 string "uw_input_", |
1574 string x, | 1572 p_ident x, |
1575 space, | 1573 space, |
1576 string "=", | 1574 string "=", |
1577 space, | 1575 space, |
1578 unurlify t, | 1576 unurlify t, |
1579 string ";", | 1577 string ";", |
1585 string "uw_inputs", | 1583 string "uw_inputs", |
1586 space, | 1584 space, |
1587 string "= {", | 1585 string "= {", |
1588 newline, | 1586 newline, |
1589 box (map (fn (x, _) => box [string "uw_input_", | 1587 box (map (fn (x, _) => box [string "uw_input_", |
1590 string x, | 1588 p_ident x, |
1591 string ",", | 1589 string ",", |
1592 newline]) xts), | 1590 newline]) xts), |
1593 string "};", | 1591 string "};", |
1594 newline], | 1592 newline], |
1595 box [string ",", | 1593 box [string ",", |
1669 "') AND (", | 1667 "') AND (", |
1670 String.concatWith " OR " | 1668 String.concatWith " OR " |
1671 (map (fn (x, t) => | 1669 (map (fn (x, t) => |
1672 String.concat ["(attname = 'uw_", | 1670 String.concat ["(attname = 'uw_", |
1673 CharVector.map | 1671 CharVector.map |
1674 Char.toLower x, | 1672 Char.toLower (ident x), |
1675 "' AND atttypid = (SELECT oid FROM pg_type", | 1673 "' AND atttypid = (SELECT oid FROM pg_type", |
1676 " WHERE typname = '", | 1674 " WHERE typname = '", |
1677 p_sqltype' env t, | 1675 p_sqltype' env t, |
1678 "'))"]) xts), | 1676 "'))"]) xts), |
1679 ")"] | 1677 ")"] |