comparison src/cjr_print.sml @ 463:bb27c7efcd90

Reading cookies works
author Adam Chlipala <adamc@hcoop.net>
date Thu, 06 Nov 2008 12:08:41 -0500
parents 322c8620bbdf
children 3f1b9231a37b
comparison
equal deleted inserted replaced
462:21bb5bbba2e9 463:bb27c7efcd90
59 59
60 val ident = String.translate (fn #"'" => "PRIME" 60 val ident = String.translate (fn #"'" => "PRIME"
61 | ch => str ch) 61 | ch => str ch)
62 62
63 val p_ident = string o ident 63 val p_ident = string o ident
64
65 fun isUnboxable (t : typ) =
66 case #1 t of
67 TDatatype (Default, _, _) => true
68 | TFfi ("Basis", "string") => true
69 | _ => false
64 70
65 fun p_typ' par env (t, loc) = 71 fun p_typ' par env (t, loc) =
66 case t of 72 case t of
67 TFun (t1, t2) => parenIf par (box [p_typ' true env t2, 73 TFun (t1, t2) => parenIf par (box [p_typ' true env t2,
68 space, 74 space,
94 space, 100 space,
95 string ("__uwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")] 101 string ("__uwd_" ^ #1 (E.lookupDatatype env n) ^ "_" ^ Int.toString n ^ "*")]
96 handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n)) 102 handle CjrEnv.UnboundNamed _ => string ("__uwd_UNBOUND__" ^ Int.toString n))
97 | TFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x] 103 | TFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x]
98 | TOption t => 104 | TOption t =>
99 (case #1 t of 105 if isUnboxable t then
100 TDatatype _ => p_typ' par env t 106 p_typ' par env t
101 | TFfi ("Basis", "string") => p_typ' par env t 107 else
102 | _ => box [p_typ' par env t, 108 box [p_typ' par env t,
103 string "*"]) 109 string "*"]
104 110
105 and p_typ env = p_typ' false env 111 and p_typ env = p_typ' false env
106 112
107 fun p_rel env n = string ("__uwr_" ^ ident (#1 (E.lookupERel env n)) ^ "_" ^ Int.toString (E.countERels env - n - 1)) 113 fun p_rel env n = string ("__uwr_" ^ ident (#1 (E.lookupERel env n)) ^ "_" ^ Int.toString (E.countERels env - n - 1))
108 handle CjrEnv.UnboundRel _ => string ("__uwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1)) 114 handle CjrEnv.UnboundRel _ => string ("__uwr_UNBOUND_" ^ Int.toString (E.countERels env - n - 1))
226 | Default => box [string "disc", 232 | Default => box [string "disc",
227 string (Int.toString depth), 233 string (Int.toString depth),
228 string "->data.", 234 string "->data.",
229 string x] 235 string x]
230 | Option => 236 | Option =>
231 case #1 t of 237 if isUnboxable t then
232 TDatatype _ => box [string "disc", 238 box [string "disc",
233 string (Int.toString depth)] 239 string (Int.toString depth)]
234 | TFfi ("Basis", "string") => box [string "disc", 240 else
235 string (Int.toString depth)] 241 box [string "*disc",
236 | _ => box [string "*disc", 242 string (Int.toString depth)],
237 string (Int.toString depth)],
238 string ";", 243 string ";",
239 newline, 244 newline,
240 p, 245 p,
241 newline, 246 newline,
242 string "}"], 247 string "}"],
333 string "disc", 338 string "disc",
334 string (Int.toString (depth + 1)), 339 string (Int.toString (depth + 1)),
335 space, 340 space,
336 string "=", 341 string "=",
337 space, 342 space,
338 case #1 t of 343 if isUnboxable t then
339 TDatatype _ => box [string "disc", 344 box [string "disc",
340 string (Int.toString depth)] 345 string (Int.toString depth)]
341 | TFfi ("Basis", "string") => box [string "disc", 346 else
342 string (Int.toString depth)] 347 box [string "*disc",
343 | _ => box [string "*disc", 348 string (Int.toString depth)],
344 string (Int.toString depth)],
345 string ";", 349 string ";",
346 newline, 350 newline,
347 p, 351 p,
348 newline, 352 newline,
349 string "}"], 353 string "}"],
466 | TOption t => allowHeapAllocated andalso nl t 470 | TOption t => allowHeapAllocated andalso nl t
467 in 471 in
468 nl 472 nl
469 end 473 end
470 474
475 fun capitalize s =
476 if s = "" then
477 ""
478 else
479 str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
480
481 fun unurlify env (t, loc) =
482 let
483 fun unurlify' rf t =
484 case t of
485 TFfi ("Basis", "unit") => string ("uw_unit_v")
486 | TFfi (m, t) => string ("uw_" ^ ident m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)")
487
488 | TRecord 0 => string "uw_unit_v"
489 | TRecord i =>
490 let
491 val xts = E.lookupStruct env i
492 in
493 box [string "({",
494 newline,
495 box (map (fn (x, t) =>
496 box [p_typ env t,
497 space,
498 string "uwr_",
499 string x,
500 space,
501 string "=",
502 space,
503 unurlify' rf (#1 t),
504 string ";",
505 newline]) xts),
506 string "struct",
507 space,
508 string "__uws_",
509 string (Int.toString i),
510 space,
511 string "tmp",
512 space,
513 string "=",
514 space,
515 string "{",
516 space,
517 p_list_sep (box [string ",", space]) (fn (x, _) => box [string "uwr_",
518 string x]) xts,
519 space,
520 string "};",
521 newline,
522 string "tmp;",
523 newline,
524 string "})"]
525 end
526
527 | TDatatype (Enum, i, _) =>
528 let
529 val (x, xncs) = E.lookupDatatype env i
530
531 fun doEm xncs =
532 case xncs of
533 [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype "
534 ^ x ^ "\"), (enum __uwe_"
535 ^ x ^ "_" ^ Int.toString i ^ ")0)")
536 | (x', n, to) :: rest =>
537 box [string "((!strncmp(request, \"",
538 string x',
539 string "\", ",
540 string (Int.toString (size x')),
541 string ") && (request[",
542 string (Int.toString (size x')),
543 string "] == 0 || request[",
544 string (Int.toString (size x')),
545 string ("] == '/')) ? __uwc_" ^ ident x' ^ "_" ^ Int.toString n),
546 space,
547 string ":",
548 space,
549 doEm rest,
550 string ")"]
551 in
552 doEm xncs
553 end
554
555 | TDatatype (Option, i, xncs) =>
556 if IS.member (rf, i) then
557 box [string "unurlify_",
558 string (Int.toString i),
559 string "()"]
560 else
561 let
562 val (x, _) = E.lookupDatatype env i
563
564 val (no_arg, has_arg, t) =
565 case !xncs of
566 [(no_arg, _, NONE), (has_arg, _, SOME t)] =>
567 (no_arg, has_arg, t)
568 | [(has_arg, _, SOME t), (no_arg, _, NONE)] =>
569 (no_arg, has_arg, t)
570 | _ => raise Fail "CjrPrint: unfooify misclassified Option datatype"
571
572 val rf = IS.add (rf, i)
573 in
574 box [string "({",
575 space,
576 p_typ env t,
577 space,
578 string "*unurlify_",
579 string (Int.toString i),
580 string "(void) {",
581 newline,
582 box [string "return (request[0] == '/' ? ++request : request,",
583 newline,
584 string "((!strncmp(request, \"",
585 string no_arg,
586 string "\", ",
587 string (Int.toString (size no_arg)),
588 string ") && (request[",
589 string (Int.toString (size no_arg)),
590 string "] == 0 || request[",
591 string (Int.toString (size no_arg)),
592 string "] == '/')) ? (request",
593 space,
594 string "+=",
595 space,
596 string (Int.toString (size no_arg)),
597 string ", NULL) : ((!strncmp(request, \"",
598 string has_arg,
599 string "\", ",
600 string (Int.toString (size has_arg)),
601 string ") && (request[",
602 string (Int.toString (size has_arg)),
603 string "] == 0 || request[",
604 string (Int.toString (size has_arg)),
605 string "] == '/')) ? (request",
606 space,
607 string "+=",
608 space,
609 string (Int.toString (size has_arg)),
610 string ", (request[0] == '/' ? ++request : NULL), ",
611 newline,
612
613 if isUnboxable t then
614 unurlify' rf (#1 t)
615 else
616 box [string "({",
617 newline,
618 p_typ env t,
619 space,
620 string "*tmp",
621 space,
622 string "=",
623 space,
624 string "uw_malloc(ctx, sizeof(",
625 p_typ env t,
626 string "));",
627 newline,
628 string "*tmp",
629 space,
630 string "=",
631 space,
632 unurlify' rf (#1 t),
633 string ";",
634 newline,
635 string "tmp;",
636 newline,
637 string "})"],
638 string ")",
639 newline,
640 string ":",
641 space,
642 string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x
643 ^ "\"), NULL))));"),
644 newline],
645 string "}",
646 newline,
647 newline,
648
649 string "unurlify_",
650 string (Int.toString i),
651 string "();",
652 newline,
653 string "})"]
654 end
655
656 | TDatatype (Default, i, _) =>
657 if IS.member (rf, i) then
658 box [string "unurlify_",
659 string (Int.toString i),
660 string "()"]
661 else
662 let
663 val (x, xncs) = E.lookupDatatype env i
664
665 val rf = IS.add (rf, i)
666
667 fun doEm xncs =
668 case xncs of
669 [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype "
670 ^ x ^ "\"), NULL)")
671 | (x', n, to) :: rest =>
672 box [string "((!strncmp(request, \"",
673 string x',
674 string "\", ",
675 string (Int.toString (size x')),
676 string ") && (request[",
677 string (Int.toString (size x')),
678 string "] == 0 || request[",
679 string (Int.toString (size x')),
680 string "] == '/')) ? ({",
681 newline,
682 string "struct",
683 space,
684 string ("__uwd_" ^ ident x ^ "_" ^ Int.toString i),
685 space,
686 string "*tmp = uw_malloc(ctx, sizeof(struct __uwd_",
687 string x,
688 string "_",
689 string (Int.toString i),
690 string "));",
691 newline,
692 string "tmp->tag",
693 space,
694 string "=",
695 space,
696 string ("__uwc_" ^ ident x' ^ "_" ^ Int.toString n),
697 string ";",
698 newline,
699 string "request",
700 space,
701 string "+=",
702 space,
703 string (Int.toString (size x')),
704 string ";",
705 newline,
706 string "if (request[0] == '/') ++request;",
707 newline,
708 case to of
709 NONE => box []
710 | SOME (t, _) => box [string "tmp->data.uw_",
711 p_ident x',
712 space,
713 string "=",
714 space,
715 unurlify' rf t,
716 string ";",
717 newline],
718 string "tmp;",
719 newline,
720 string "})",
721 space,
722 string ":",
723 space,
724 doEm rest,
725 string ")"]
726 in
727 box [string "({",
728 space,
729 p_typ env (t, ErrorMsg.dummySpan),
730 space,
731 string "unurlify_",
732 string (Int.toString i),
733 string "(void) {",
734 newline,
735 box [string "return",
736 space,
737 doEm xncs,
738 string ";",
739 newline],
740 string "}",
741 newline,
742 newline,
743
744 string "unurlify_",
745 string (Int.toString i),
746 string "();",
747 newline,
748 string "})"]
749 end
750
751 | _ => (ErrorMsg.errorAt loc "Unable to choose a URL decoding function";
752 space)
753 in
754 unurlify' IS.empty t
755 end
756
471 fun p_exp' par env (e, loc) = 757 fun p_exp' par env (e, loc) =
472 case e of 758 case e of
473 EPrim p => Prim.p_t_GCC p 759 EPrim p => Prim.p_t_GCC p
474 | ERel n => p_rel env n 760 | ERel n => p_rel env n
475 | ENamed n => p_enamed env n 761 | ENamed n => p_enamed env n
483 769
484 val t = case to of 770 val t = case to of
485 NONE => raise Fail "CjrPrint: ECon argument status mismatch" 771 NONE => raise Fail "CjrPrint: ECon argument status mismatch"
486 | SOME t => t 772 | SOME t => t
487 in 773 in
488 case #1 t of 774 if isUnboxable t then
489 TDatatype _ => p_exp' par env e 775 p_exp' par env e
490 | TFfi ("Basis", "string") => p_exp' par env e 776 else
491 | _ => box [string "({", 777 box [string "({",
492 newline, 778 newline,
493 p_typ env t, 779 p_typ env t,
494 space, 780 space,
495 string "*tmp", 781 string "*tmp",
496 space, 782 space,
497 string "=", 783 string "=",
498 space, 784 space,
499 string "uw_malloc(ctx, sizeof(", 785 string "uw_malloc(ctx, sizeof(",
500 p_typ env t, 786 p_typ env t,
501 string "));", 787 string "));",
502 newline, 788 newline,
503 string "*tmp", 789 string "*tmp",
504 space, 790 space,
505 string "=", 791 string "=",
506 p_exp' par env e, 792 p_exp' par env e,
507 string ";", 793 string ";",
508 newline, 794 newline,
509 string "tmp;", 795 string "tmp;",
510 newline, 796 newline,
511 string "})"] 797 string "})"]
512 end 798 end
513 | ECon (Default, pc, eo) => 799 | ECon (Default, pc, eo) =>
514 let 800 let
515 val (xd, xc, xn) = patConInfo env pc 801 val (xd, xc, xn) = patConInfo env pc
516 in 802 in
549 newline, 835 newline,
550 string "})"] 836 string "})"]
551 end 837 end
552 | ENone _ => string "NULL" 838 | ENone _ => string "NULL"
553 | ESome (t, e) => 839 | ESome (t, e) =>
554 (case #1 t of 840 if isUnboxable t then
555 TDatatype _ => p_exp' par env e 841 p_exp' par env e
556 | TFfi ("Basis", "string") => p_exp' par env e 842 else
557 | _ => box [string "({", 843 box [string "({",
558 newline, 844 newline,
559 p_typ env t, 845 p_typ env t,
560 space, 846 space,
561 string "*tmp", 847 string "*tmp",
562 space, 848 space,
563 string "=", 849 string "=",
564 space, 850 space,
565 string "uw_malloc(ctx, sizeof(", 851 string "uw_malloc(ctx, sizeof(",
566 p_typ env t, 852 p_typ env t,
567 string "));", 853 string "));",
568 newline, 854 newline,
569 string "*tmp", 855 string "*tmp",
570 space, 856 space,
571 string "=", 857 string "=",
572 p_exp' par env e, 858 p_exp' par env e,
573 string ";", 859 string ";",
574 newline, 860 newline,
575 string "tmp;", 861 string "tmp;",
576 newline, 862 newline,
577 string "})"]) 863 string "})"]
578 864
579 | EFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x] 865 | EFfi (m, x) => box [string "uw_", p_ident m, string "_", p_ident x]
580 | EError (e, t) => 866 | EError (e, t) =>
581 box [string "({", 867 box [string "({",
582 newline, 868 newline,
1074 string "PQclear(res);", 1360 string "PQclear(res);",
1075 newline, 1361 newline,
1076 string "n;", 1362 string "n;",
1077 newline, 1363 newline,
1078 string "}))"] 1364 string "}))"]
1365 end
1366
1367 | EUnurlify (e, t) =>
1368 let
1369 fun getIt () =
1370 if isUnboxable t then
1371 unurlify env t
1372 else
1373 box [string "({",
1374 newline,
1375 p_typ env t,
1376 string " *tmp = uw_malloc(ctx, sizeof(",
1377 p_typ env t,
1378 string "));",
1379 newline,
1380 string "*tmp = ",
1381 unurlify env t,
1382 string ";",
1383 newline,
1384 string "tmp;",
1385 newline,
1386 string "})"]
1387 in
1388 box [string "({",
1389 newline,
1390 string "uw_Basis_string request = ",
1391 p_exp env e,
1392 string ";",
1393 newline,
1394 newline,
1395 string "(request ? ",
1396 getIt (),
1397 string " : NULL);",
1398 newline,
1399 string "})"]
1079 end 1400 end
1080 1401
1081 and p_exp env = p_exp' false env 1402 and p_exp env = p_exp' false env
1082 1403
1083 fun p_fun env (fx, n, args, ran, e) = 1404 fun p_fun env (fx, n, args, ran, e) =
1525 string "-1;", 1846 string "-1;",
1526 newline, 1847 newline,
1527 string "}"] 1848 string "}"]
1528 end 1849 end
1529 1850
1530 fun capitalize s =
1531 if s = "" then
1532 ""
1533 else
1534 str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
1535
1536 fun unurlify (t, loc) =
1537 let
1538 fun unurlify' rf t =
1539 case t of
1540 TFfi ("Basis", "unit") => string ("uw_unit_v")
1541 | TFfi (m, t) => string ("uw_" ^ ident m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)")
1542
1543 | TRecord 0 => string "uw_unit_v"
1544 | TRecord i =>
1545 let
1546 val xts = E.lookupStruct env i
1547 in
1548 box [string "({",
1549 newline,
1550 box (map (fn (x, t) =>
1551 box [p_typ env t,
1552 space,
1553 string "uwr_",
1554 string x,
1555 space,
1556 string "=",
1557 space,
1558 unurlify' rf (#1 t),
1559 string ";",
1560 newline]) xts),
1561 string "struct",
1562 space,
1563 string "__uws_",
1564 string (Int.toString i),
1565 space,
1566 string "tmp",
1567 space,
1568 string "=",
1569 space,
1570 string "{",
1571 space,
1572 p_list_sep (box [string ",", space]) (fn (x, _) => box [string "uwr_",
1573 string x]) xts,
1574 space,
1575 string "};",
1576 newline,
1577 string "tmp;",
1578 newline,
1579 string "})"]
1580 end
1581
1582 | TDatatype (Enum, i, _) =>
1583 let
1584 val (x, xncs) = E.lookupDatatype env i
1585
1586 fun doEm xncs =
1587 case xncs of
1588 [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype "
1589 ^ x ^ "\"), (enum __uwe_"
1590 ^ x ^ "_" ^ Int.toString i ^ ")0)")
1591 | (x', n, to) :: rest =>
1592 box [string "((!strncmp(request, \"",
1593 string x',
1594 string "\", ",
1595 string (Int.toString (size x')),
1596 string ") && (request[",
1597 string (Int.toString (size x')),
1598 string "] == 0 || request[",
1599 string (Int.toString (size x')),
1600 string ("] == '/')) ? __uwc_" ^ ident x' ^ "_" ^ Int.toString n),
1601 space,
1602 string ":",
1603 space,
1604 doEm rest,
1605 string ")"]
1606 in
1607 doEm xncs
1608 end
1609
1610 | TDatatype (Option, i, xncs) =>
1611 if IS.member (rf, i) then
1612 box [string "unurlify_",
1613 string (Int.toString i),
1614 string "()"]
1615 else
1616 let
1617 val (x, _) = E.lookupDatatype env i
1618
1619 val (no_arg, has_arg, t) =
1620 case !xncs of
1621 [(no_arg, _, NONE), (has_arg, _, SOME t)] =>
1622 (no_arg, has_arg, t)
1623 | [(has_arg, _, SOME t), (no_arg, _, NONE)] =>
1624 (no_arg, has_arg, t)
1625 | _ => raise Fail "CjrPrint: unfooify misclassified Option datatype"
1626
1627 val rf = IS.add (rf, i)
1628 in
1629 box [string "({",
1630 space,
1631 p_typ env t,
1632 space,
1633 string "*unurlify_",
1634 string (Int.toString i),
1635 string "(void) {",
1636 newline,
1637 box [string "return (request[0] == '/' ? ++request : request,",
1638 newline,
1639 string "((!strncmp(request, \"",
1640 string no_arg,
1641 string "\", ",
1642 string (Int.toString (size no_arg)),
1643 string ") && (request[",
1644 string (Int.toString (size no_arg)),
1645 string "] == 0 || request[",
1646 string (Int.toString (size no_arg)),
1647 string "] == '/')) ? (request",
1648 space,
1649 string "+=",
1650 space,
1651 string (Int.toString (size no_arg)),
1652 string ", NULL) : ((!strncmp(request, \"",
1653 string has_arg,
1654 string "\", ",
1655 string (Int.toString (size has_arg)),
1656 string ") && (request[",
1657 string (Int.toString (size has_arg)),
1658 string "] == 0 || request[",
1659 string (Int.toString (size has_arg)),
1660 string "] == '/')) ? (request",
1661 space,
1662 string "+=",
1663 space,
1664 string (Int.toString (size has_arg)),
1665 string ", (request[0] == '/' ? ++request : NULL), ",
1666 newline,
1667
1668 case #1 t of
1669 TDatatype _ => unurlify' rf (#1 t)
1670 | TFfi ("Basis", "string") => unurlify' rf (#1 t)
1671 | _ => box [string "({",
1672 newline,
1673 p_typ env t,
1674 space,
1675 string "*tmp",
1676 space,
1677 string "=",
1678 space,
1679 string "uw_malloc(ctx, sizeof(",
1680 p_typ env t,
1681 string "));",
1682 newline,
1683 string "*tmp",
1684 space,
1685 string "=",
1686 space,
1687 unurlify' rf (#1 t),
1688 string ";",
1689 newline,
1690 string "tmp;",
1691 newline,
1692 string "})"],
1693 string ")",
1694 newline,
1695 string ":",
1696 space,
1697 string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype " ^ x
1698 ^ "\"), NULL))));"),
1699 newline],
1700 string "}",
1701 newline,
1702 newline,
1703
1704 string "unurlify_",
1705 string (Int.toString i),
1706 string "();",
1707 newline,
1708 string "})"]
1709 end
1710
1711 | TDatatype (Default, i, _) =>
1712 if IS.member (rf, i) then
1713 box [string "unurlify_",
1714 string (Int.toString i),
1715 string "()"]
1716 else
1717 let
1718 val (x, xncs) = E.lookupDatatype env i
1719
1720 val rf = IS.add (rf, i)
1721
1722 fun doEm xncs =
1723 case xncs of
1724 [] => string ("(uw_error(ctx, FATAL, \"Error unurlifying datatype "
1725 ^ x ^ "\"), NULL)")
1726 | (x', n, to) :: rest =>
1727 box [string "((!strncmp(request, \"",
1728 string x',
1729 string "\", ",
1730 string (Int.toString (size x')),
1731 string ") && (request[",
1732 string (Int.toString (size x')),
1733 string "] == 0 || request[",
1734 string (Int.toString (size x')),
1735 string "] == '/')) ? ({",
1736 newline,
1737 string "struct",
1738 space,
1739 string ("__uwd_" ^ ident x ^ "_" ^ Int.toString i),
1740 space,
1741 string "*tmp = uw_malloc(ctx, sizeof(struct __uwd_",
1742 string x,
1743 string "_",
1744 string (Int.toString i),
1745 string "));",
1746 newline,
1747 string "tmp->tag",
1748 space,
1749 string "=",
1750 space,
1751 string ("__uwc_" ^ ident x' ^ "_" ^ Int.toString n),
1752 string ";",
1753 newline,
1754 string "request",
1755 space,
1756 string "+=",
1757 space,
1758 string (Int.toString (size x')),
1759 string ";",
1760 newline,
1761 string "if (request[0] == '/') ++request;",
1762 newline,
1763 case to of
1764 NONE => box []
1765 | SOME (t, _) => box [string "tmp->data.uw_",
1766 p_ident x',
1767 space,
1768 string "=",
1769 space,
1770 unurlify' rf t,
1771 string ";",
1772 newline],
1773 string "tmp;",
1774 newline,
1775 string "})",
1776 space,
1777 string ":",
1778 space,
1779 doEm rest,
1780 string ")"]
1781 in
1782 box [string "({",
1783 space,
1784 p_typ env (t, ErrorMsg.dummySpan),
1785 space,
1786 string "unurlify_",
1787 string (Int.toString i),
1788 string "(void) {",
1789 newline,
1790 box [string "return",
1791 space,
1792 doEm xncs,
1793 string ";",
1794 newline],
1795 string "}",
1796 newline,
1797 newline,
1798
1799 string "unurlify_",
1800 string (Int.toString i),
1801 string "();",
1802 newline,
1803 string "})"]
1804 end
1805
1806 | _ => (ErrorMsg.errorAt loc "Unable to choose a URL decoding function";
1807 space)
1808 in
1809 unurlify' IS.empty t
1810 end
1811
1812 fun p_page (ek, s, n, ts) = 1851 fun p_page (ek, s, n, ts) =
1813 let 1852 let
1814 val (ts, defInputs, inputsVar) = 1853 val (ts, defInputs, inputsVar) =
1815 case ek of 1854 case ek of
1816 Core.Link => (List.take (ts, length ts - 1), string "", string "") 1855 Core.Link => (List.take (ts, length ts - 1), string "", string "")
1853 string "uw_input_", 1892 string "uw_input_",
1854 p_ident x, 1893 p_ident x,
1855 space, 1894 space,
1856 string "=", 1895 string "=",
1857 space, 1896 space,
1858 unurlify t, 1897 unurlify env t,
1859 string ";", 1898 string ";",
1860 newline] 1899 newline]
1861 end) xts), 1900 end) xts),
1862 string "struct __uws_", 1901 string "struct __uws_",
1863 string (Int.toString i), 1902 string (Int.toString i),
1902 string "arg", 1941 string "arg",
1903 string (Int.toString i), 1942 string (Int.toString i),
1904 space, 1943 space,
1905 string "=", 1944 string "=",
1906 space, 1945 space,
1907 unurlify t, 1946 unurlify env t,
1908 string ";", 1947 string ";",
1909 newline]) ts), 1948 newline]) ts),
1910 defInputs, 1949 defInputs,
1911 p_enamed env n, 1950 p_enamed env n,
1912 string "(", 1951 string "(",