diff --git a/whalesong/js-assembler/runtime-src/baselib-primitives.js b/whalesong/js-assembler/runtime-src/baselib-primitives.js index bf70cea..6df9911 100644 --- a/whalesong/js-assembler/runtime-src/baselib-primitives.js +++ b/whalesong/js-assembler/runtime-src/baselib-primitives.js @@ -3146,18 +3146,22 @@ - // The default prompt handler consumes a thunk and applies it. + // The default abort prompt handler consumes a thunk and applies + // it, in a context where a new prompt has been initialized. var defaultPromptHandler = - makeClosure("default-prompt-handler", - 1, - function(M) { - var proc = checkProcedure(M, 'apply', 0); - M.e.pop(); - M.p = proc; - M.a = 0; - baselib.functions.rawApply(M); - }, - []); + makeClosure( + "default-prompt-handler", + 1, + function(M) { + var proc = checkProcedure(M, 'apply', 0); + M.e.pop(); + M.p = proc; + M.a = 0; + M.addPrompt(baselib.contmarks.DEFAULT_CONTINUATION_PROMPT_TAG, + false); + baselib.functions.rawApply(M); + }, + []); installPrimitiveClosure( diff --git a/whalesong/js-assembler/runtime-src/runtime.js b/whalesong/js-assembler/runtime-src/runtime.js index 842e730..809b37c 100644 --- a/whalesong/js-assembler/runtime-src/runtime.js +++ b/whalesong/js-assembler/runtime-src/runtime.js @@ -488,6 +488,24 @@ return new baselib.contmarks.ContinuationMarkSet(kvLists); }; + + var justReturn = function(M) { + M.p=M.c[M.c.length-1].label; + M.c.pop(); + return(M.p)(M); + }; + justReturn.mvr = function(M) { + M.p=M.c[M.c.length-1].label; + M.c.pop(); + return(M.p.mvr)(M); + }; + Machine.prototype.addPrompt = function(promptTag, abortHandlerClosure) { + this.c.push(new PromptFrame(justReturn, + DEFAULT_CONTINUATION_PROMPT_TAG, + this.e.length, + abortHandlerClosure)); + }; +