summaryrefslogtreecommitdiff
path: root/src/jscomp.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-03-22 16:03:45 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-03-22 16:03:45 -0400
commite2f6b11fd4fc806c5cdf88cf669ed5b2d9e34caf (patch)
treee2cac8cf9ae665630df1564c8942ad1d84484ac0 /src/jscomp.sml
parentbac67ca0f668cd381205b243355da8c906c58b5b (diff)
Proper recv
Diffstat (limited to 'src/jscomp.sml')
-rw-r--r--src/jscomp.sml22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/jscomp.sml b/src/jscomp.sml
index be227035..36d42754 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -49,7 +49,8 @@ val funcs = [(("Basis", "alert"), "alert"),
(("Basis", "urlifyInt"), "ts"),
(("Basis", "urlifyFloat"), "ts"),
(("Basis", "urlifyString"), "escape"),
- (("Basis", "urlifyChannel"), "ts")]
+ (("Basis", "urlifyChannel"), "ts"),
+ (("Basis", "recv"), "rv")]
structure FM = BinaryMapFn(struct
type ord_key = string * string
@@ -106,6 +107,7 @@ fun varDepth (e, _) =
| ESignalBind (e1, e2) => Int.max (varDepth e1, varDepth e2)
| ESignalSource e => varDepth e
| EServerCall (e, ek, _) => Int.max (varDepth e, varDepth ek)
+ | ERecv (e, ek, _) => Int.max (varDepth e, varDepth ek)
fun closedUpto d =
let
@@ -147,6 +149,7 @@ fun closedUpto d =
| ESignalBind (e1, e2) => cu inner e1 andalso cu inner e2
| ESignalSource e => cu inner e
| EServerCall (e, ek, _) => cu inner e andalso cu inner ek
+ | ERecv (e, ek, _) => cu inner e andalso cu inner ek
in
cu 0
end
@@ -342,7 +345,7 @@ fun process file =
@ ["}"]), st)
end
- | TFfi ("Basis", "string") => ("unescape(t[i++])", st)
+ | TFfi ("Basis", "string") => ("unesc(t[i++])", st)
| TFfi ("Basis", "int") => ("parseInt(t[i++])", st)
| TFfi ("Basis", "float") => ("parseFloat(t[i++])", st)
@@ -952,6 +955,21 @@ fun process file =
str ")"],
st)
end
+
+ | ERecv (e, ek, t) =>
+ let
+ val (e, st) = jsE inner (e, st)
+ val (ek, st) = jsE inner (ek, st)
+ val (unurl, st) = unurlifyExp loc (t, st)
+ in
+ (strcat [str "rv(",
+ e,
+ str (", function(s){var t=s.split(\"/\");var i=0;return "
+ ^ unurl ^ "},"),
+ ek,
+ str ")"],
+ st)
+ end
end
in
jsE