diff src/mono_opt.sml @ 286:ffe5b01908ae

'show' type class; htmlification optimizations
author Adam Chlipala <adamc@hcoop.net>
date Sun, 07 Sep 2008 10:48:51 -0400
parents 7d5860add50f
children 132416711463
line wrap: on
line diff
--- a/src/mono_opt.sml	Sun Sep 07 10:20:42 2008 -0400
+++ b/src/mono_opt.sml	Sun Sep 07 10:48:51 2008 -0400
@@ -55,6 +55,8 @@
 val urlifyInt = attrifyInt
 val urlifyFloat = attrifyFloat
 
+val htmlifyInt = attrifyInt
+val htmlifyFloat = attrifyFloat
 val htmlifyString = String.translate (fn ch => case ch of
                                                    #"<" => "&lt;"
                                                  | #"&" => "&amp;"
@@ -149,6 +151,31 @@
         ESeq ((EWrite (EPrim (Prim.String (s1 ^ s2)), loc), loc),
               e)
 
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "intToString", [(EPrim (Prim.Int n), _)]), _)]) =>
+        EPrim (Prim.String (htmlifyInt n))
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "intToString", es), _)]) =>
+        EFfiApp ("Basis", "htmlifyInt", es)
+      | EWrite (EFfiApp ("Basis", "htmlifyInt", [e]), _) =>
+        EFfiApp ("Basis", "htmlifyInt_w", [e])
+
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "floatToString", [(EPrim (Prim.Float n), _)]), _)]) =>
+        EPrim (Prim.String (htmlifyFloat n))
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "floatToString", es), _)]) =>
+        EFfiApp ("Basis", "htmlifyFloat", es)
+      | EWrite (EFfiApp ("Basis", "htmlifyFloat", [e]), _) =>
+        EFfiApp ("Basis", "htmlifyFloat_w", [e])
+
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString",
+                                                      [(ECon (Enum, PConFfi {con = "True", ...}, NONE), _)]), _)]) =>
+        EPrim (Prim.String "True")
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString",
+                                                      [(ECon (Enum, PConFfi {con = "False", ...}, NONE), _)]), _)]) =>
+        EPrim (Prim.String "False")
+      | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString", es), _)]) =>
+        EFfiApp ("Basis", "htmlifyBool", es)
+      | EWrite (EFfiApp ("Basis", "htmlifyBool", [e]), _) =>
+        EFfiApp ("Basis", "htmlifyBool_w", [e])
+
       | EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]) =>
         EPrim (Prim.String (htmlifyString s))
       | EWrite (EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]), loc) =>