diff src/jscomp.sml @ 577:3d56940120b1

Setting a source server-side
author Adam Chlipala <adamc@hcoop.net>
date Tue, 30 Dec 2008 10:49:42 -0500
parents ac947e2f29ff
children 1e589a60b86f
line wrap: on
line diff
--- a/src/jscomp.sml	Tue Dec 30 09:43:45 2008 -0500
+++ b/src/jscomp.sml	Tue Dec 30 10:49:42 2008 -0500
@@ -121,6 +121,13 @@
                    (str "ERROR", st))
 
                 val strcat = strcat loc
+
+                fun quoteExp (t : typ) e =
+                    case #1 t of
+                        TSource => strcat [str "s",
+                                           (EFfiApp ("Basis", "htmlifyInt", [e]), loc)]
+                      | _ => (EM.errorAt loc "Don't know how to embed type in JavaScript";
+                              str "ERROR")
             in
                 case #1 e of
                     EPrim (Prim.String s) =>
@@ -130,6 +137,7 @@
                                                      "\\047"
                                                  else
                                                      "'"
+                                               | #"\"" => "\\\""
                                                | #"<" =>
                                                  if mode = Script then
                                                      "<"
@@ -143,7 +151,11 @@
                     if n < inner then
                         (str ("uwr" ^ var n), st)
                     else
-                        (str ("uwo" ^ var n), st)
+                        let
+                            val n = n - inner
+                        in
+                            (quoteExp (List.nth (outer, n)) (ERel n, loc), st)
+                        end
                   | ENamed _ => raise Fail "Named"
                   | ECon (_, pc, NONE) => (patCon pc, st)
                   | ECon (_, pc, SOME e) =>