comparison src/jscomp.sml @ 906:c270fb847dc2

Be careful in Jscomp to avoid interpreting non-boolean/reference types as booleans with ?:
author Adam Chlipala <adamc@hcoop.net>
date Tue, 11 Aug 2009 11:26:37 -0400
parents 7a4b026e45dd
children 8e540df3294d
comparison
equal deleted inserted replaced
905:7a4b026e45dd 906:c270fb847dc2
583 fail, 583 fail,
584 str ":", 584 str ":",
585 succ, 585 succ,
586 str ")"] 586 str ")"]
587 | PCon (Option, _, NONE) => 587 | PCon (Option, _, NONE) =>
588 strcat [str ("(d" ^ Int.toString depth ^ "?"), 588 strcat [str ("(d" ^ Int.toString depth ^ "!=null?"),
589 fail, 589 fail,
590 str ":", 590 str ":",
591 succ, 591 succ,
592 str ")"] 592 str ")"]
593 | PCon (Option, PConVar n, SOME p) => 593 | PCon (Option, PConVar n, SOME p) =>
594 (case IM.find (someTs, n) of 594 (case IM.find (someTs, n) of
595 NONE => raise Fail "Jscomp: Not in someTs" 595 NONE => raise Fail "Jscomp: Not in someTs"
596 | SOME t => 596 | SOME t =>
597 strcat [str ("(d" ^ Int.toString depth ^ "?(d" 597 strcat [str ("(d" ^ Int.toString depth ^ "!=null?(d"
598 ^ Int.toString (depth+1) ^ "=d" ^ Int.toString depth 598 ^ Int.toString (depth+1) ^ "=d" ^ Int.toString depth
599 ^ (if isNullable t then 599 ^ (if isNullable t then
600 ".v," 600 ".v,"
601 else 601 else
602 "") 602 "")
632 str ")"])) 632 str ")"]))
633 (inner, succ) xps 633 (inner, succ) xps
634 in 634 in
635 succ 635 succ
636 end 636 end
637 | PNone _ => strcat [str ("(d" ^ Int.toString depth ^ "?"), 637 | PNone _ => strcat [str ("(d" ^ Int.toString depth ^ "!=null?"),
638 fail, 638 fail,
639 str ":", 639 str ":",
640 succ, 640 succ,
641 str ")"] 641 str ")"]
642 | PSome (t, p) => strcat [str ("(d" ^ Int.toString depth ^ "?(d" ^ Int.toString (depth+1) 642 | PSome (t, p) => strcat [str ("(d" ^ Int.toString depth ^ "!=null?(d" ^ Int.toString (depth+1)
643 ^ "=d" ^ Int.toString depth 643 ^ "=d" ^ Int.toString depth
644 ^ (if isNullable t then 644 ^ (if isNullable t then
645 ".v" 645 ".v"
646 else 646 else
647 "") 647 "")