summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-10-25 14:07:10 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-10-25 14:07:10 -0400
commitad7be9f6f9b4bfd6d6a4653b5eed4783a6ddb96e (patch)
tree95685ca6f24d0e3511588ae55bbdd8a121f97994 /lib
parentda76d63970055a475aafb8971e773d074878e21b (diff)
RPC uses VM support for call/cc
Diffstat (limited to 'lib')
-rw-r--r--lib/js/urweb.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 653f8d2f..6ca4becd 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -632,7 +632,7 @@ function rc(prefix, uri, parse, k, needsSig) {
if (isok) {
try {
- execF(k, parse(xhr.responseText));
+ k(parse(xhr.responseText));
} catch (v) {
doExn(v);
}
@@ -854,7 +854,11 @@ function execP(env, p, v) {
}
function exec0(env, e) {
- var stack = null;
+ return exec1(env, null, e);
+}
+
+function exec1(env, stack, e) {
+ var stack, usedK = false;
var saveEnv = function() {
if (stack.next != null && stack.next.data.c != "<")
@@ -883,8 +887,9 @@ function exec0(env, e) {
case "f":
fr.args[fr.pos++] = v;
if (fr.a == null) {
- e = {c: "c", v: fr.f.apply(null, fr.args)};
stack = stack.next;
+ e = {c: "c", v: fr.f.apply(null, fr.args)};
+ if (usedK) return null;
} else {
e = fr.a.data;
fr.a = fr.a.next;
@@ -1014,6 +1019,11 @@ function exec0(env, e) {
env = e.env;
e = e.body;
break;
+ case "K":
+ { var savedStack = stack.next, savedEnv = env;
+ e = {c: "c", v: function(v) { return exec1(savedEnv, savedStack, {c: "c", v: v}); } };}
+ usedK = true;
+ break;
default:
whine("Unknown Ur expression kind " + e.c);
}