Mercurial > urweb
comparison src/jscomp.sml @ 670:f73913d97a40
Proper recv
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 22 Mar 2009 16:03:45 -0400 |
parents | b0c1a46b1f15 |
children | 44f23712020d |
comparison
equal
deleted
inserted
replaced
669:f68eee90dbcf | 670:f73913d97a40 |
---|---|
47 (("Basis", "stringToFloat_error"), "pfl"), | 47 (("Basis", "stringToFloat_error"), "pfl"), |
48 (("Basis", "stringToInt_error"), "pi"), | 48 (("Basis", "stringToInt_error"), "pi"), |
49 (("Basis", "urlifyInt"), "ts"), | 49 (("Basis", "urlifyInt"), "ts"), |
50 (("Basis", "urlifyFloat"), "ts"), | 50 (("Basis", "urlifyFloat"), "ts"), |
51 (("Basis", "urlifyString"), "escape"), | 51 (("Basis", "urlifyString"), "escape"), |
52 (("Basis", "urlifyChannel"), "ts")] | 52 (("Basis", "urlifyChannel"), "ts"), |
53 (("Basis", "recv"), "rv")] | |
53 | 54 |
54 structure FM = BinaryMapFn(struct | 55 structure FM = BinaryMapFn(struct |
55 type ord_key = string * string | 56 type ord_key = string * string |
56 fun compare ((m1, x1), (m2, x2)) = | 57 fun compare ((m1, x1), (m2, x2)) = |
57 Order.join (String.compare (m1, m2), | 58 Order.join (String.compare (m1, m2), |
104 | EJavaScript _ => 0 | 105 | EJavaScript _ => 0 |
105 | ESignalReturn e => varDepth e | 106 | ESignalReturn e => varDepth e |
106 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2) | 107 | ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2) |
107 | ESignalSource e => varDepth e | 108 | ESignalSource e => varDepth e |
108 | EServerCall (e, ek, _) => Int.max (varDepth e, varDepth ek) | 109 | EServerCall (e, ek, _) => Int.max (varDepth e, varDepth ek) |
110 | ERecv (e, ek, _) => Int.max (varDepth e, varDepth ek) | |
109 | 111 |
110 fun closedUpto d = | 112 fun closedUpto d = |
111 let | 113 let |
112 fun cu inner (e, _) = | 114 fun cu inner (e, _) = |
113 case e of | 115 case e of |
145 | EJavaScript (_, e, _) => cu inner e | 147 | EJavaScript (_, e, _) => cu inner e |
146 | ESignalReturn e => cu inner e | 148 | ESignalReturn e => cu inner e |
147 | ESignalBind (e1, e2) => cu inner e1 andalso cu inner e2 | 149 | ESignalBind (e1, e2) => cu inner e1 andalso cu inner e2 |
148 | ESignalSource e => cu inner e | 150 | ESignalSource e => cu inner e |
149 | EServerCall (e, ek, _) => cu inner e andalso cu inner ek | 151 | EServerCall (e, ek, _) => cu inner e andalso cu inner ek |
152 | ERecv (e, ek, _) => cu inner e andalso cu inner ek | |
150 in | 153 in |
151 cu 0 | 154 cu 0 |
152 end | 155 end |
153 | 156 |
154 fun strcat loc es = | 157 fun strcat loc es = |
340 :: e' | 343 :: e' |
341 :: es | 344 :: es |
342 @ ["}"]), st) | 345 @ ["}"]), st) |
343 end | 346 end |
344 | 347 |
345 | TFfi ("Basis", "string") => ("unescape(t[i++])", st) | 348 | TFfi ("Basis", "string") => ("unesc(t[i++])", st) |
346 | TFfi ("Basis", "int") => ("parseInt(t[i++])", st) | 349 | TFfi ("Basis", "int") => ("parseInt(t[i++])", st) |
347 | TFfi ("Basis", "float") => ("parseFloat(t[i++])", st) | 350 | TFfi ("Basis", "float") => ("parseFloat(t[i++])", st) |
348 | 351 |
349 | TFfi ("Basis", "bool") => ("t[i++] == \"True\"", st) | 352 | TFfi ("Basis", "bool") => ("t[i++] == \"True\"", st) |
350 | 353 |
950 ^ unurl ^ "},"), | 953 ^ unurl ^ "},"), |
951 ek, | 954 ek, |
952 str ")"], | 955 str ")"], |
953 st) | 956 st) |
954 end | 957 end |
958 | |
959 | ERecv (e, ek, t) => | |
960 let | |
961 val (e, st) = jsE inner (e, st) | |
962 val (ek, st) = jsE inner (ek, st) | |
963 val (unurl, st) = unurlifyExp loc (t, st) | |
964 in | |
965 (strcat [str "rv(", | |
966 e, | |
967 str (", function(s){var t=s.split(\"/\");var i=0;return " | |
968 ^ unurl ^ "},"), | |
969 ek, | |
970 str ")"], | |
971 st) | |
972 end | |
955 end | 973 end |
956 in | 974 in |
957 jsE | 975 jsE |
958 end | 976 end |
959 | 977 |