Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
285:e89076c41c39 | 286:ffe5b01908ae |
---|---|
53 "&#" ^ Int.toString (ord ch) ^ ";") | 53 "&#" ^ Int.toString (ord ch) ^ ";") |
54 | 54 |
55 val urlifyInt = attrifyInt | 55 val urlifyInt = attrifyInt |
56 val urlifyFloat = attrifyFloat | 56 val urlifyFloat = attrifyFloat |
57 | 57 |
58 val htmlifyInt = attrifyInt | |
59 val htmlifyFloat = attrifyFloat | |
58 val htmlifyString = String.translate (fn ch => case ch of | 60 val htmlifyString = String.translate (fn ch => case ch of |
59 #"<" => "<" | 61 #"<" => "<" |
60 | #"&" => "&" | 62 | #"&" => "&" |
61 | _ => | 63 | _ => |
62 if Char.isPrint ch orelse Char.isSpace ch then | 64 if Char.isPrint ch orelse Char.isSpace ch then |
147 (ESeq ((EWrite (EPrim (Prim.String s2), _), _), | 149 (ESeq ((EWrite (EPrim (Prim.String s2), _), _), |
148 e), _)) => | 150 e), _)) => |
149 ESeq ((EWrite (EPrim (Prim.String (s1 ^ s2)), loc), loc), | 151 ESeq ((EWrite (EPrim (Prim.String (s1 ^ s2)), loc), loc), |
150 e) | 152 e) |
151 | 153 |
154 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "intToString", [(EPrim (Prim.Int n), _)]), _)]) => | |
155 EPrim (Prim.String (htmlifyInt n)) | |
156 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "intToString", es), _)]) => | |
157 EFfiApp ("Basis", "htmlifyInt", es) | |
158 | EWrite (EFfiApp ("Basis", "htmlifyInt", [e]), _) => | |
159 EFfiApp ("Basis", "htmlifyInt_w", [e]) | |
160 | |
161 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "floatToString", [(EPrim (Prim.Float n), _)]), _)]) => | |
162 EPrim (Prim.String (htmlifyFloat n)) | |
163 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "floatToString", es), _)]) => | |
164 EFfiApp ("Basis", "htmlifyFloat", es) | |
165 | EWrite (EFfiApp ("Basis", "htmlifyFloat", [e]), _) => | |
166 EFfiApp ("Basis", "htmlifyFloat_w", [e]) | |
167 | |
168 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString", | |
169 [(ECon (Enum, PConFfi {con = "True", ...}, NONE), _)]), _)]) => | |
170 EPrim (Prim.String "True") | |
171 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString", | |
172 [(ECon (Enum, PConFfi {con = "False", ...}, NONE), _)]), _)]) => | |
173 EPrim (Prim.String "False") | |
174 | EFfiApp ("Basis", "htmlifyString", [(EFfiApp ("Basis", "boolToString", es), _)]) => | |
175 EFfiApp ("Basis", "htmlifyBool", es) | |
176 | EWrite (EFfiApp ("Basis", "htmlifyBool", [e]), _) => | |
177 EFfiApp ("Basis", "htmlifyBool_w", [e]) | |
178 | |
152 | EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]) => | 179 | EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]) => |
153 EPrim (Prim.String (htmlifyString s)) | 180 EPrim (Prim.String (htmlifyString s)) |
154 | EWrite (EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]), loc) => | 181 | EWrite (EFfiApp ("Basis", "htmlifyString", [(EPrim (Prim.String s), _)]), loc) => |
155 EWrite (EPrim (Prim.String (htmlifyString s)), loc) | 182 EWrite (EPrim (Prim.String (htmlifyString s)), loc) |
156 | EWrite (EFfiApp ("Basis", "htmlifyString", [e]), _) => | 183 | EWrite (EFfiApp ("Basis", "htmlifyString", [e]), _) => |