Mercurial > urweb
comparison src/jscomp.sml @ 1323:0d8bd8ae8417
Fix JavaScript unit unurlification; URL blessing client-side
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Fri, 26 Nov 2010 11:57:04 -0500 |
parents | c17e6144510b |
children | 02fc16faecf3 |
comparison
equal
deleted
inserted
replaced
1322:80bff6449f41 | 1323:0d8bd8ae8417 |
---|---|
276 | _ => ((*Print.prefaces "Can't embed" [("t", MonoPrint.p_typ MonoEnv.empty t)];*) | 276 | _ => ((*Print.prefaces "Can't embed" [("t", MonoPrint.p_typ MonoEnv.empty t)];*) |
277 raise CantEmbed t) | 277 raise CantEmbed t) |
278 | 278 |
279 fun unurlifyExp loc (t : typ, st) = | 279 fun unurlifyExp loc (t : typ, st) = |
280 case #1 t of | 280 case #1 t of |
281 TRecord [] => ("null", st) | 281 TRecord [] => ("(i++,null)", st) |
282 | TFfi ("Basis", "unit") => ("null", st) | 282 | TFfi ("Basis", "unit") => ("(i++,null)", st) |
283 | TRecord [(x, t)] => | 283 | TRecord [(x, t)] => |
284 let | 284 let |
285 val (e, st) = unurlifyExp loc (t, st) | 285 val (e, st) = unurlifyExp loc (t, st) |
286 in | 286 in |
287 ("{_" ^ x ^ ":" ^ e ^ "}", | 287 ("{_" ^ x ^ ":" ^ e ^ "}", |
1283 case TextIO.inputLine inf of | 1283 case TextIO.inputLine inf of |
1284 NONE => String.concat (rev acc) | 1284 NONE => String.concat (rev acc) |
1285 | SOME line => lines (line :: acc) | 1285 | SOME line => lines (line :: acc) |
1286 val lines = lines [] | 1286 val lines = lines [] |
1287 | 1287 |
1288 val urlRules = foldr (fn (r, s) => | |
1289 "cons({allow:" | |
1290 ^ (if #action r = Settings.Allow then "true" else "false") | |
1291 ^ ",prefix:" | |
1292 ^ (if #kind r = Settings.Prefix then "true" else "false") | |
1293 ^ ",pattern:\"" | |
1294 ^ #pattern r | |
1295 ^ "\"}," | |
1296 ^ s | |
1297 ^ ")") "null" (Settings.getUrlRules ()) | |
1298 | |
1299 val urlRules = "urlRules = " ^ urlRules ^ ";\n\n" | |
1300 | |
1288 val script = | 1301 val script = |
1289 if !foundJavaScript then | 1302 if !foundJavaScript then |
1290 lines ^ String.concat (rev (#script st)) | 1303 lines ^ urlRules ^ String.concat (rev (#script st)) |
1291 else | 1304 else |
1292 "" | 1305 "" |
1293 in | 1306 in |
1294 TextIO.closeIn inf; | 1307 TextIO.closeIn inf; |
1295 (DJavaScript script, ErrorMsg.dummySpan) :: ds | 1308 (DJavaScript script, ErrorMsg.dummySpan) :: ds |