comparison src/compiler.sml @ 1183:9d3ccb8b39ac

safeGet
author Adam Chlipala <adamc@hcoop.net>
date Tue, 09 Mar 2010 18:28:44 -0500
parents 618f9f458da9
children d6f0e972b706
comparison
equal deleted inserted replaced
1182:0b1d666bddb4 1183:9d3ccb8b39ac
55 rewrites : Settings.rewrite list, 55 rewrites : Settings.rewrite list,
56 filterUrl : Settings.rule list, 56 filterUrl : Settings.rule list,
57 filterMime : Settings.rule list, 57 filterMime : Settings.rule list,
58 protocol : string option, 58 protocol : string option,
59 dbms : string option, 59 dbms : string option,
60 sigFile : string option 60 sigFile : string option,
61 safeGets : string list
61 } 62 }
62 63
63 type ('src, 'dst) phase = { 64 type ('src, 'dst) phase = {
64 func : 'src -> 'dst, 65 func : 'src -> 'dst,
65 print : 'dst -> Print.PD.pp_desc 66 print : 'dst -> Print.PD.pp_desc
383 val mime = ref [] 384 val mime = ref []
384 val libs = ref [] 385 val libs = ref []
385 val protocol = ref NONE 386 val protocol = ref NONE
386 val dbms = ref NONE 387 val dbms = ref NONE
387 val sigFile = ref (Settings.getSigFile ()) 388 val sigFile = ref (Settings.getSigFile ())
389 val safeGets = ref []
388 390
389 fun finish sources = 391 fun finish sources =
390 let 392 let
391 val job = { 393 val job = {
392 prefix = Option.getOpt (!prefix, "/"), 394 prefix = Option.getOpt (!prefix, "/"),
411 filterUrl = rev (!url), 413 filterUrl = rev (!url),
412 filterMime = rev (!mime), 414 filterMime = rev (!mime),
413 sources = sources, 415 sources = sources,
414 protocol = !protocol, 416 protocol = !protocol,
415 dbms = !dbms, 417 dbms = !dbms,
416 sigFile = !sigFile 418 sigFile = !sigFile,
419 safeGets = rev (!safeGets)
417 } 420 }
418 421
419 fun mergeO f (old, new) = 422 fun mergeO f (old, new) =
420 case (old, new) of 423 case (old, new) of
421 (NONE, _) => new 424 (NONE, _) => new
454 sources = #sources new 457 sources = #sources new
455 @ List.filter (fn s => List.all (fn s' => s' <> s) (#sources new)) 458 @ List.filter (fn s => List.all (fn s' => s' <> s) (#sources new))
456 (#sources old), 459 (#sources old),
457 protocol = mergeO #2 (#protocol old, #protocol new), 460 protocol = mergeO #2 (#protocol old, #protocol new),
458 dbms = mergeO #2 (#dbms old, #dbms new), 461 dbms = mergeO #2 (#dbms old, #dbms new),
459 sigFile = mergeO #2 (#sigFile old, #sigFile new) 462 sigFile = mergeO #2 (#sigFile old, #sigFile new),
463 safeGets = #safeGets old @ #safeGets new
460 } 464 }
461 in 465 in
462 if accLibs then 466 if accLibs then
463 foldr (fn (job', job) => merge (job, job')) job (!libs) 467 foldr (fn (job', job) => merge (job, job')) job (!libs)
464 else 468 else
567 link := arg :: !link 571 link := arg :: !link
568 end 572 end
569 | "include" => headers := relifyA arg :: !headers 573 | "include" => headers := relifyA arg :: !headers
570 | "script" => scripts := arg :: !scripts 574 | "script" => scripts := arg :: !scripts
571 | "clientToServer" => clientToServer := ffiS () :: !clientToServer 575 | "clientToServer" => clientToServer := ffiS () :: !clientToServer
572 | "effectful" => effectful := ffiS () :: !effectful 576 | "safeGet" => safeGets := arg :: !safeGets
573 | "benignEffectful" => benignEffectful := ffiS () :: !benignEffectful 577 | "benignEffectful" => benignEffectful := ffiS () :: !benignEffectful
574 | "clientOnly" => clientOnly := ffiS () :: !clientOnly 578 | "clientOnly" => clientOnly := ffiS () :: !clientOnly
575 | "serverOnly" => serverOnly := ffiS () :: !serverOnly 579 | "serverOnly" => serverOnly := ffiS () :: !serverOnly
576 | "jsFunc" => jsFuncs := ffiM () :: !jsFuncs 580 | "jsFunc" => jsFuncs := ffiM () :: !jsFuncs
577 | "rewrite" => 581 | "rewrite" =>
640 Settings.setRewriteRules (#rewrites job); 644 Settings.setRewriteRules (#rewrites job);
641 Settings.setUrlRules (#filterUrl job); 645 Settings.setUrlRules (#filterUrl job);
642 Settings.setMimeRules (#filterMime job); 646 Settings.setMimeRules (#filterMime job);
643 Option.app Settings.setProtocol (#protocol job); 647 Option.app Settings.setProtocol (#protocol job);
644 Option.app Settings.setDbms (#dbms job); 648 Option.app Settings.setDbms (#dbms job);
649 Settings.setSafeGets (#safeGets job);
645 job 650 job
646 end 651 end
647 in 652 in
648 {Job = pu fname, Libs = !bigLibs} 653 {Job = pu fname, Libs = !bigLibs}
649 end 654 end