diff 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
line wrap: on
line diff
--- a/src/jscomp.sml	Sun Mar 22 15:16:34 2009 -0400
+++ b/src/jscomp.sml	Sun Mar 22 16:03:45 2009 -0400
@@ -49,7 +49,8 @@
              (("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 @@
       | 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 @@
               | 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 @@
                                     @ ["}"]), 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 @@
                                          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