comparison src/jscomp.sml @ 1021:7a4a55e05081

Use call/cc for recv and sleep
author Adam Chlipala <adamc@hcoop.net>
date Sun, 25 Oct 2009 15:29:21 -0400
parents dfe34fad749d
children 7facf72aaf0a
comparison
equal deleted inserted replaced
1020:dfe34fad749d 1021:7a4a55e05081
916 | _ => "false") 916 | _ => "false")
917 ^ "},null)))))}")], 917 ^ "},null)))))}")],
918 st) 918 st)
919 end 919 end
920 920
921 | ERecv (e, ek, t) => 921 | ERecv (e, t) =>
922 let 922 let
923 val (e, st) = jsE inner (e, st) 923 val (e, st) = jsE inner (e, st)
924 val (ek, st) = jsE inner (ek, st)
925 val (unurl, st) = unurlifyExp loc (t, st) 924 val (unurl, st) = unurlifyExp loc (t, st)
926 in 925 in
927 (strcat [str ("{c:\"f\",f:rv,a:cons("), 926 (strcat [str ("{c:\"f\",f:rv,a:cons("),
928 e, 927 e,
929 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return " 928 str (",cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
930 ^ unurl ^ "}},cons("), 929 ^ unurl ^ "}},cons({c:\"K\"},null)))}")],
931 ek,
932 str (",null)))}")],
933 st) 930 st)
934 end 931 end
935 932
936 | ESleep (e, ek) => 933 | ESleep e =>
937 let 934 let
938 val (e, st) = jsE inner (e, st) 935 val (e, st) = jsE inner (e, st)
939 val (ek, st) = jsE inner (ek, st)
940 in 936 in
941 (strcat [str "{c:\"f\",f:sl,a:cons(", 937 (strcat [str "{c:\"f\",f:sl,a:cons(",
942 e, 938 e,
943 str ",cons(", 939 str ",cons({c:\"K\"},null))}"],
944 ek, 940 st)
945 str ",null))}"], 941 end
942
943 | ESpawn e =>
944 let
945 val (e, st) = jsE inner (e, st)
946 in
947 (strcat [str "{c:\"f\",f:sp,a:cons(",
948 e,
949 str ",null)}"],
946 st) 950 st)
947 end 951 end
948 end 952 end
949 in 953 in
950 jsE 0 954 jsE 0
1166 let 1170 let
1167 val (e1, st) = exp outer (e1, st) 1171 val (e1, st) = exp outer (e1, st)
1168 in 1172 in
1169 ((EServerCall (e1, t, ef), loc), st) 1173 ((EServerCall (e1, t, ef), loc), st)
1170 end 1174 end
1171 | ERecv (e1, e2, t) => 1175 | ERecv (e1, t) =>
1172 let 1176 let
1173 val (e1, st) = exp outer (e1, st) 1177 val (e1, st) = exp outer (e1, st)
1174 val (e2, st) = exp outer (e2, st) 1178 in
1175 in 1179 ((ERecv (e1, t), loc), st)
1176 ((ERecv (e1, e2, t), loc), st) 1180 end
1177 end 1181 | ESleep e1 =>
1178 | ESleep (e1, e2) =>
1179 let 1182 let
1180 val (e1, st) = exp outer (e1, st) 1183 val (e1, st) = exp outer (e1, st)
1181 val (e2, st) = exp outer (e2, st) 1184 in
1182 in 1185 ((ESleep e1, loc), st)
1183 ((ESleep (e1, e2), loc), st) 1186 end
1187 | ESpawn e1 =>
1188 let
1189 val (e1, st) = exp outer (e1, st)
1190 in
1191 ((ESpawn e1, loc), st)
1184 end) 1192 end)
1185 1193
1186 fun decl (d as (_, loc), st) = 1194 fun decl (d as (_, loc), st) =
1187 case #1 d of 1195 case #1 d of
1188 DVal (x, n, t, e, s) => 1196 DVal (x, n, t, e, s) =>