diff src/jscomp.sml @ 592:a8be5a2068a5

Injecting strings and bools
author Adam Chlipala <adamc@hcoop.net>
date Thu, 01 Jan 2009 16:11:42 -0500
parents 8f8771f32909
children f277f5faebcd
line wrap: on
line diff
--- a/src/jscomp.sml	Thu Jan 01 15:59:02 2009 -0500
+++ b/src/jscomp.sml	Thu Jan 01 16:11:42 2009 -0500
@@ -162,10 +162,24 @@
                                    (EFfiApp ("Basis", "htmlifyInt", [e]), loc)]
               | TRecord [] => str loc "null"
 
-              | TFfi ("Basis", "string") => e
+              | TFfi ("Basis", "string") => (EFfiApp ("Basis", "jsifyString", [e]), loc)
               | TFfi ("Basis", "int") => (EFfiApp ("Basis", "htmlifyInt", [e]), loc)
               | TFfi ("Basis", "float") => (EFfiApp ("Basis", "htmlifyFloat", [e]), loc)
 
+              | TFfi ("Basis", "bool") => (ECase (e,
+                                                  [((PCon (Enum, PConFfi {mod = "Basis",
+                                                                          datatyp = "bool",
+                                                                          con = "True",
+                                                                          arg = NONE}, NONE), loc),
+                                                    str loc "true"),
+                                                   ((PCon (Enum, PConFfi {mod = "Basis",
+                                                                          datatyp = "bool",
+                                                                          con = "False",
+                                                                          arg = NONE}, NONE), loc),
+                                                    str loc "false")],
+                                                  {disc = (TFfi ("Basis", "bool"), loc),
+                                                   result = (TFfi ("Basis", "string"), loc)}), loc)
+
               | _ => (EM.errorAt loc "Don't know how to embed type in JavaScript";
                       Print.prefaces "Can't embed" [("t", MonoPrint.p_typ MonoEnv.empty t)];
                       str loc "ERROR")