comparison src/jscomp.sml @ 1798:10a2cb93d175

Removed evaluation of js function name strings. (from Vladimir Shabanov)
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 Jul 2012 12:54:17 -0400
parents c414850f206f
children c1e3805e604e
comparison
equal deleted inserted replaced
1797:bb942416bf1c 1798:10a2cb93d175
1 (* Copyright (c) 2008-2011, Adam Chlipala 1 (* Copyright (c) 2008-2012, Adam Chlipala
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
656 str ")"], 656 str ")"],
657 st) 657 st)
658 end) 658 end)
659 (str "null", st) args 659 (str "null", st) args
660 in 660 in
661 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:"), 661 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:"),
662 e, 662 e,
663 str "}"], 663 str "}"],
664 st) 664 st)
665 end 665 end
666 666
691 | "-" => "neg" 691 | "-" => "neg"
692 | _ => raise Fail ("Jscomp: Unknown unary operator " ^ s) 692 | _ => raise Fail ("Jscomp: Unknown unary operator " ^ s)
693 693
694 val (e, st) = jsE inner (e, st) 694 val (e, st) = jsE inner (e, st)
695 in 695 in
696 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:cons("), 696 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:cons("),
697 e, 697 e,
698 str ",null)}"], 698 str ",null)}"],
699 st) 699 st)
700 end 700 end
701 | EBinop (bi, s, e1, e2) => 701 | EBinop (bi, s, e1, e2) =>
716 | _ => raise Fail ("Jscomp: Unknown binary operator " ^ s) 716 | _ => raise Fail ("Jscomp: Unknown binary operator " ^ s)
717 717
718 val (e1, st) = jsE inner (e1, st) 718 val (e1, st) = jsE inner (e1, st)
719 val (e2, st) = jsE inner (e2, st) 719 val (e2, st) = jsE inner (e2, st)
720 in 720 in
721 (strcat [str ("{c:\"f\",f:\"" ^ name ^ "\",a:cons("), 721 (strcat [str ("{c:\"f\",f:" ^ name ^ ",a:cons("),
722 e1, 722 e1,
723 str ",cons(", 723 str ",cons(",
724 e2, 724 e2,
725 str ",null))}"], 725 str ",null))}"],
726 st) 726 st)
820 | EStrcat (e1, e2) => 820 | EStrcat (e1, e2) =>
821 let 821 let
822 val (e1, st) = jsE inner (e1, st) 822 val (e1, st) = jsE inner (e1, st)
823 val (e2, st) = jsE inner (e2, st) 823 val (e2, st) = jsE inner (e2, st)
824 in 824 in
825 (strcat [str "{c:\"f\",f:\"cat\",a:cons(", e1, str ",cons(", e2, str ",null))}"], st) 825 (strcat [str "{c:\"f\",f:cat,a:cons(", e1, str ",cons(", e2, str ",null))}"], st)
826 end 826 end
827 827
828 | EError (e, _) => 828 | EError (e, _) =>
829 let 829 let
830 val (e, st) = jsE inner (e, st) 830 val (e, st) = jsE inner (e, st)
831 in 831 in
832 (strcat [str "{c:\"f\",f:\"er\",a:cons(", e, str ",null)}"], 832 (strcat [str "{c:\"f\",f:er,a:cons(", e, str ",null)}"],
833 st) 833 st)
834 end 834 end
835 835
836 | ESeq (e1, e2) => 836 | ESeq (e1, e2) =>
837 let 837 let
876 876
877 | ERedirect (e, _) => 877 | ERedirect (e, _) =>
878 let 878 let
879 val (e, st) = jsE inner (e, st) 879 val (e, st) = jsE inner (e, st)
880 in 880 in
881 (strcat [str "{c:\"f\",f:\"redirect\",a:cons(", 881 (strcat [str "{c:\"f\",f:redirect,a:cons(",
882 e, 882 e,
883 str ",null)}"], 883 str ",null)}"],
884 st) 884 st)
885 end 885 end
886 886
889 | EUnurlify (e, t, false) => 889 | EUnurlify (e, t, false) =>
890 let 890 let
891 val (e, st) = jsE inner (e, st) 891 val (e, st) = jsE inner (e, st)
892 val (e', st) = unurlifyExp loc (t, st) 892 val (e', st) = unurlifyExp loc (t, st)
893 in 893 in
894 (strcat [str ("{c:\"f\",f:\"unurlify\",a:cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 894 (strcat [str ("{c:\"f\",f:unurlify,a:cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
895 ^ e' ^ "}},cons("), 895 ^ e' ^ "}},cons("),
896 e, 896 e,
897 str ",null))}"], 897 str ",null))}"],
898 st) 898 st)
899 end 899 end
900 900
901 | ESignalReturn e => 901 | ESignalReturn e =>
902 let 902 let
903 val (e, st) = jsE inner (e, st) 903 val (e, st) = jsE inner (e, st)
904 in 904 in
905 (strcat [str "{c:\"f\",f:\"sr\",a:cons(", 905 (strcat [str "{c:\"f\",f:sr,a:cons(",
906 e, 906 e,
907 str ",null)}"], 907 str ",null)}"],
908 st) 908 st)
909 end 909 end
910 | ESignalBind (e1, e2) => 910 | ESignalBind (e1, e2) =>
911 let 911 let
912 val (e1, st) = jsE inner (e1, st) 912 val (e1, st) = jsE inner (e1, st)
913 val (e2, st) = jsE inner (e2, st) 913 val (e2, st) = jsE inner (e2, st)
914 in 914 in
915 (strcat [str "{c:\"f\",f:\"sb\",a:cons(", 915 (strcat [str "{c:\"f\",f:sb,a:cons(",
916 e1, 916 e1,
917 str ",cons(", 917 str ",cons(",
918 e2, 918 e2,
919 str ",null))}"], 919 str ",null))}"],
920 st) 920 st)
921 end 921 end
922 | ESignalSource e => 922 | ESignalSource e =>
923 let 923 let
924 val (e, st) = jsE inner (e, st) 924 val (e, st) = jsE inner (e, st)
925 in 925 in
926 (strcat [str "{c:\"f\",f:\"ss\",a:cons(", 926 (strcat [str "{c:\"f\",f:ss,a:cons(",
927 e, 927 e,
928 str ",null)}"], 928 str ",null)}"],
929 st) 929 st)
930 end 930 end
931 931
932 | EServerCall (e, t, eff) => 932 | EServerCall (e, t, eff) =>
933 let 933 let
934 val (e, st) = jsE inner (e, st) 934 val (e, st) = jsE inner (e, st)
935 val (unurl, st) = unurlifyExp loc (t, st) 935 val (unurl, st) = unurlifyExp loc (t, st)
936 in 936 in
937 (strcat [str ("{c:\"f\",f:\"rc\",a:cons({c:\"c\",v:\"" 937 (strcat [str ("{c:\"f\",f:rc,a:cons({c:\"c\",v:\""
938 ^ Settings.getUrlPrefix () 938 ^ Settings.getUrlPrefix ()
939 ^ "\"},cons("), 939 ^ "\"},cons("),
940 e, 940 e,
941 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 941 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
942 ^ unurl ^ "}},cons({c:\"K\"},cons({c:\"c\",v:" 942 ^ unurl ^ "}},cons({c:\"K\"},cons({c:\"c\",v:"
950 | ERecv (e, t) => 950 | ERecv (e, t) =>
951 let 951 let
952 val (e, st) = jsE inner (e, st) 952 val (e, st) = jsE inner (e, st)
953 val (unurl, st) = unurlifyExp loc (t, st) 953 val (unurl, st) = unurlifyExp loc (t, st)
954 in 954 in
955 (strcat [str ("{c:\"f\",f:\"rv\",a:cons("), 955 (strcat [str ("{c:\"f\",f:rv,a:cons("),
956 e, 956 e,
957 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 957 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
958 ^ unurl ^ "}},cons({c:\"K\"},null)))}")], 958 ^ unurl ^ "}},cons({c:\"K\"},null)))}")],
959 st) 959 st)
960 end 960 end
961 961
962 | ESleep e => 962 | ESleep e =>
963 let 963 let
964 val (e, st) = jsE inner (e, st) 964 val (e, st) = jsE inner (e, st)
965 in 965 in
966 (strcat [str "{c:\"f\",f:\"sl\",a:cons(", 966 (strcat [str "{c:\"f\",f:sl,a:cons(",
967 e, 967 e,
968 str ",cons({c:\"K\"},null))}"], 968 str ",cons({c:\"K\"},null))}"],
969 st) 969 st)
970 end 970 end
971 971
972 | ESpawn e => 972 | ESpawn e =>
973 let 973 let
974 val (e, st) = jsE inner (e, st) 974 val (e, st) = jsE inner (e, st)
975 in 975 in
976 (strcat [str "{c:\"f\",f:\"sp\",a:cons(", 976 (strcat [str "{c:\"f\",f:sp,a:cons(",
977 e, 977 e,
978 str ",null)}"], 978 str ",null)}"],
979 st) 979 st)
980 end 980 end
981 end 981 end