comparison src/jscomp.sml @ 614:5891f47d7cff

Parameterized RPC query
author Adam Chlipala <adamc@hcoop.net>
date Sun, 15 Feb 2009 13:03:09 -0500
parents c5991cdb0c4b
children 3ee6bb48f6e8
comparison
equal deleted inserted replaced
613:c5991cdb0c4b 614:5891f47d7cff
41 (("Basis", "htmlifyBool"), "bs"), 41 (("Basis", "htmlifyBool"), "bs"),
42 (("Basis", "htmlifyFloat"), "ts"), 42 (("Basis", "htmlifyFloat"), "ts"),
43 (("Basis", "htmlifyInt"), "ts"), 43 (("Basis", "htmlifyInt"), "ts"),
44 (("Basis", "htmlifyString"), "eh"), 44 (("Basis", "htmlifyString"), "eh"),
45 (("Basis", "new_client_source"), "sc"), 45 (("Basis", "new_client_source"), "sc"),
46 (("Basis", "set_client_source"), "sv")] 46 (("Basis", "set_client_source"), "sv"),
47 (("Basis", "urlifyInt"), "ts"),
48 (("Basis", "urlifyFloat"), "ts"),
49 (("Basis", "urlifyString"), "escape")]
47 50
48 structure FM = BinaryMapFn(struct 51 structure FM = BinaryMapFn(struct
49 type ord_key = string * string 52 type ord_key = string * string
50 fun compare ((m1, x1), (m2, x2)) = 53 fun compare ((m1, x1), (m2, x2)) =
51 Order.join (String.compare (m1, m2), 54 Order.join (String.compare (m1, m2),
96 | EUnurlify _ => 0 99 | EUnurlify _ => 0
97 | EJavaScript _ => 0 100 | EJavaScript _ => 0
98 | ESignalReturn e => varDepth e 101 | ESignalReturn e => varDepth e
99 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2) 102 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2)
100 | ESignalSource e => varDepth e 103 | ESignalSource e => varDepth e
101 | EServerCall (_, es, ek, _) => foldl Int.max (varDepth ek) (map varDepth es) 104 | EServerCall (e, ek, _) => Int.max (varDepth e, varDepth ek)
102 105
103 fun closedUpto d = 106 fun closedUpto d =
104 let 107 let
105 fun cu inner (e, _) = 108 fun cu inner (e, _) =
106 case e of 109 case e of
137 | EUnurlify (e, _) => cu inner e 140 | EUnurlify (e, _) => cu inner e
138 | EJavaScript (_, e, _) => cu inner e 141 | EJavaScript (_, e, _) => cu inner e
139 | ESignalReturn e => cu inner e 142 | ESignalReturn e => cu inner e
140 | ESignalBind (e1, e2) => cu inner e1 andalso cu inner e2 143 | ESignalBind (e1, e2) => cu inner e1 andalso cu inner e2
141 | ESignalSource e => cu inner e 144 | ESignalSource e => cu inner e
142 | EServerCall (_, es, ek, _) => List.all (cu inner) es andalso cu inner ek 145 | EServerCall (e, ek, _) => cu inner e andalso cu inner ek
143 in 146 in
144 cu 0 147 cu 0
145 end 148 end
146 149
147 fun strcat loc es = 150 fun strcat loc es =
924 e, 927 e,
925 str ")"], 928 str ")"],
926 st) 929 st)
927 end 930 end
928 931
929 | EServerCall (x, es, ek, t) => 932 | EServerCall (e, ek, t) =>
930 let 933 let
934 val (e, st) = jsE inner (e, st)
931 val (ek, st) = jsE inner (ek, st) 935 val (ek, st) = jsE inner (ek, st)
932 val (unurl, st) = unurlifyExp loc (t, st) 936 val (unurl, st) = unurlifyExp loc (t, st)
933 in 937 in
934 (strcat [str ("rc(\"" ^ !Monoize.urlPrefix ^ x ^ "\", function(s){var t=s.split(\"/\");var i=0;return " 938 (strcat [str ("rc(\"" ^ !Monoize.urlPrefix ^ "\"+"),
939 e,
940 str (", function(s){var t=s.split(\"/\");var i=0;return "
935 ^ unurl ^ "},"), 941 ^ unurl ^ "},"),
936 ek, 942 ek,
937 str ")"], 943 str ")"],
938 st) 944 st)
939 end 945 end