diff src/jscomp.sml @ 2048:4d64af730e35

Differentiate between HTML and normal string literals
author Adam Chlipala <adam@chlipala.net>
date Fri, 01 Aug 2014 15:44:17 -0400
parents 057b08253a75
children 9e9c915f554c 278e10629ba1
line wrap: on
line diff
--- a/src/jscomp.sml	Fri Aug 01 11:43:44 2014 -0400
+++ b/src/jscomp.sml	Fri Aug 01 15:44:17 2014 -0400
@@ -55,7 +55,7 @@
 
 fun strcat loc es =
     case es of
-        [] => (EPrim (Prim.String ""), loc)
+        [] => (EPrim (Prim.String (Prim.Normal, "")), loc)
       | [x] => x
       | x :: es' => (EStrcat (x, strcat loc es'), loc)
 
@@ -81,7 +81,7 @@
                     | (_, state) => state)
                   (IM.empty, IM.empty) (#1 file)
 
-        fun str loc s = (EPrim (Prim.String s), loc)
+        fun str loc s = (EPrim (Prim.String (Prim.Normal, s)), loc)
 
         fun isNullable (t, _) =
             case t of
@@ -149,7 +149,7 @@
                     val (e', st) = quoteExp loc t ((ERel 0, loc), st)
                 in
                     (case #1 e' of
-                        EPrim (Prim.String "ERROR") => raise Fail "UHOH"
+                        EPrim (Prim.String (_, "ERROR")) => raise Fail "UHOH"
                       | _ =>
                         (ECase (e,
                                 [((PNone t, loc),
@@ -450,7 +450,7 @@
                                                             3)
                             in
                                 case p of
-                                    Prim.String s =>
+                                    Prim.String (_, s) =>
                                     str ("\"" ^ String.translate jsChar s ^ "\"")
                                   | Prim.Char ch => str ("\"" ^ jsChar ch ^ "\"")
                                   | _ => str (Prim.toString p)
@@ -519,7 +519,7 @@
 
                         fun deStrcat level (all as (e, loc)) =
                             case e of
-                                EPrim (Prim.String s) => jsifyStringMulti (level, s)
+                                EPrim (Prim.String (_, s)) => jsifyStringMulti (level, s)
                               | EStrcat (e1, e2) => deStrcat level e1 ^ deStrcat level e2
                               | EFfiApp ("Basis", "jsifyString", [(e, _)]) => "\"" ^ deStrcat (level + 1) e ^ "\""
                               | _ => (ErrorMsg.errorAt loc "Unexpected non-constant JavaScript code";
@@ -1021,10 +1021,10 @@
              case #1 e of
                  EPrim p =>
                  (case p of
-                      Prim.String s => if inString {needle = "<script", haystack = s} then
-                                           foundJavaScript := true
-                                       else
-                                           ()
+                      Prim.String (_, s) => if inString {needle = "<script", haystack = s} then
+                                                foundJavaScript := true
+                                            else
+                                                ()
                     | _ => ();
                   (e, st))
                | ERel _ => (e, st)