comparison src/jscomp.sml @ 1057:eaba663fd6aa

Represent FFI function names as strings, to deal with cross-file recursion
author Adam Chlipala <adamc@hcoop.net>
date Sat, 05 Dec 2009 14:01:34 -0500
parents 7facf72aaf0a
children 217eb87dde31
comparison
equal deleted inserted replaced
1056:c42bfbd75ca9 1057:eaba663fd6aa
655 str ")"], 655 str ")"],
656 st) 656 st)
657 end) 657 end)
658 (str "null", st) args 658 (str "null", st) args
659 in 659 in
660 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:"), 660 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:"),
661 e, 661 e,
662 str "}"], 662 str "}"],
663 st) 663 st)
664 end 664 end
665 665
690 | "-" => "neg" 690 | "-" => "neg"
691 | _ => raise Fail ("Jscomp: Unknown unary operator " ^ s) 691 | _ => raise Fail ("Jscomp: Unknown unary operator " ^ s)
692 692
693 val (e, st) = jsE inner (e, st) 693 val (e, st) = jsE inner (e, st)
694 in 694 in
695 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:cons("), 695 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:cons("),
696 e, 696 e,
697 str ",null)}"], 697 str ",null)}"],
698 st) 698 st)
699 end 699 end
700 | EBinop (s, e1, e2) => 700 | EBinop (s, e1, e2) =>
713 | _ => raise Fail ("Jscomp: Unknown binary operator " ^ s) 713 | _ => raise Fail ("Jscomp: Unknown binary operator " ^ s)
714 714
715 val (e1, st) = jsE inner (e1, st) 715 val (e1, st) = jsE inner (e1, st)
716 val (e2, st) = jsE inner (e2, st) 716 val (e2, st) = jsE inner (e2, st)
717 in 717 in
718 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:cons("), 718 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:cons("),
719 e1, 719 e1,
720 str ",cons(", 720 str ",cons(",
721 e2, 721 e2,
722 str ",null))}"], 722 str ",null))}"],
723 st) 723 st)
817 | EStrcat (e1, e2) => 817 | EStrcat (e1, e2) =>
818 let 818 let
819 val (e1, st) = jsE inner (e1, st) 819 val (e1, st) = jsE inner (e1, st)
820 val (e2, st) = jsE inner (e2, st) 820 val (e2, st) = jsE inner (e2, st)
821 in 821 in
822 (strcat [str "{c:\"f\",f:cat,a:cons(", e1, str ",cons(", e2, str ",null))}"], st) 822 (strcat [str "{c:\"f\",f:\"cat\",a:cons(", e1, str ",cons(", e2, str ",null))}"], st)
823 end 823 end
824 824
825 | EError (e, _) => 825 | EError (e, _) =>
826 let 826 let
827 val (e, st) = jsE inner (e, st) 827 val (e, st) = jsE inner (e, st)
828 in 828 in
829 (strcat [str "{c:\"f\",f:er,a:cons(", e, str ",null)}"], 829 (strcat [str "{c:\"f\",f:\"er\",a:cons(", e, str ",null)}"],
830 st) 830 st)
831 end 831 end
832 832
833 | ESeq (e1, e2) => 833 | ESeq (e1, e2) =>
834 let 834 let
873 873
874 | ESignalReturn e => 874 | ESignalReturn e =>
875 let 875 let
876 val (e, st) = jsE inner (e, st) 876 val (e, st) = jsE inner (e, st)
877 in 877 in
878 (strcat [str "{c:\"f\",f:sr,a:cons(", 878 (strcat [str "{c:\"f\",f:\"sr\",a:cons(",
879 e, 879 e,
880 str ",null)}"], 880 str ",null)}"],
881 st) 881 st)
882 end 882 end
883 | ESignalBind (e1, e2) => 883 | ESignalBind (e1, e2) =>
884 let 884 let
885 val (e1, st) = jsE inner (e1, st) 885 val (e1, st) = jsE inner (e1, st)
886 val (e2, st) = jsE inner (e2, st) 886 val (e2, st) = jsE inner (e2, st)
887 in 887 in
888 (strcat [str "{c:\"f\",f:sb,a:cons(", 888 (strcat [str "{c:\"f\",f:\"sb\",a:cons(",
889 e1, 889 e1,
890 str ",cons(", 890 str ",cons(",
891 e2, 891 e2,
892 str ",null))}"], 892 str ",null))}"],
893 st) 893 st)
894 end 894 end
895 | ESignalSource e => 895 | ESignalSource e =>
896 let 896 let
897 val (e, st) = jsE inner (e, st) 897 val (e, st) = jsE inner (e, st)
898 in 898 in
899 (strcat [str "{c:\"f\",f:ss,a:cons(", 899 (strcat [str "{c:\"f\",f:\"ss\",a:cons(",
900 e, 900 e,
901 str ",null)}"], 901 str ",null)}"],
902 st) 902 st)
903 end 903 end
904 904
905 | EServerCall (e, t, eff) => 905 | EServerCall (e, t, eff) =>
906 let 906 let
907 val (e, st) = jsE inner (e, st) 907 val (e, st) = jsE inner (e, st)
908 val (unurl, st) = unurlifyExp loc (t, st) 908 val (unurl, st) = unurlifyExp loc (t, st)
909 in 909 in
910 (strcat [str ("{c:\"f\",f:rc,a:cons({c:\"c\",v:\"" 910 (strcat [str ("{c:\"f\",f:\"rc\",a:cons({c:\"c\",v:\""
911 ^ Settings.getUrlPrefix () 911 ^ Settings.getUrlPrefix ()
912 ^ "\"},cons("), 912 ^ "\"},cons("),
913 e, 913 e,
914 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 914 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
915 ^ unurl ^ "}},cons({c:\"K\"},cons({c:\"c\",v:" 915 ^ unurl ^ "}},cons({c:\"K\"},cons({c:\"c\",v:"
923 | ERecv (e, t) => 923 | ERecv (e, t) =>
924 let 924 let
925 val (e, st) = jsE inner (e, st) 925 val (e, st) = jsE inner (e, st)
926 val (unurl, st) = unurlifyExp loc (t, st) 926 val (unurl, st) = unurlifyExp loc (t, st)
927 in 927 in
928 (strcat [str ("{c:\"f\",f:rv,a:cons("), 928 (strcat [str ("{c:\"f\",f:\"rv\",a:cons("),
929 e, 929 e,
930 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 930 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
931 ^ unurl ^ "}},cons({c:\"K\"},null)))}")], 931 ^ unurl ^ "}},cons({c:\"K\"},null)))}")],
932 st) 932 st)
933 end 933 end
934 934
935 | ESleep e => 935 | ESleep e =>
936 let 936 let
937 val (e, st) = jsE inner (e, st) 937 val (e, st) = jsE inner (e, st)
938 in 938 in
939 (strcat [str "{c:\"f\",f:sl,a:cons(", 939 (strcat [str "{c:\"f\",f:\"sl\",a:cons(",
940 e, 940 e,
941 str ",cons({c:\"K\"},null))}"], 941 str ",cons({c:\"K\"},null))}"],
942 st) 942 st)
943 end 943 end
944 944
945 | ESpawn e => 945 | ESpawn e =>
946 let 946 let
947 val (e, st) = jsE inner (e, st) 947 val (e, st) = jsE inner (e, st)
948 in 948 in
949 (strcat [str "{c:\"f\",f:sp,a:cons(", 949 (strcat [str "{c:\"f\",f:\"sp\",a:cons(",
950 e, 950 e,
951 str ",null)}"], 951 str ",null)}"],
952 st) 952 st)
953 end 953 end
954 end 954 end