trying to get in abort-current-continuation
This commit is contained in:
parent
d76e622bd8
commit
8798ab96a7
|
@ -559,8 +559,7 @@ EOF
|
||||||
(assemble-label (make-Label (LinkedLabel-label label)))])))]
|
(assemble-label (make-Label (LinkedLabel-label label)))])))]
|
||||||
|
|
||||||
[(PushControlFrame/Prompt? stmt)
|
[(PushControlFrame/Prompt? stmt)
|
||||||
;; fixme: use a different frame structure
|
(format "M.c.push(new RT.PromptFrame(~a,~a,M.e.length,false));"
|
||||||
(format "M.c.push(new RT.PromptFrame(~a,~a));"
|
|
||||||
(let: ([label : (U Symbol LinkedLabel) (PushControlFrame/Prompt-label stmt)])
|
(let: ([label : (U Symbol LinkedLabel) (PushControlFrame/Prompt-label stmt)])
|
||||||
(cond
|
(cond
|
||||||
[(symbol? label)
|
[(symbol? label)
|
||||||
|
|
|
@ -40,11 +40,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// A prompt frame includes a return address, as well as a prompt tag
|
// A prompt frame includes a return address, as well as a prompt
|
||||||
// for supporting delimited continuations.
|
// tag for supporting delimited continuations. To support abort,
|
||||||
var PromptFrame = function(label, tag) {
|
// we also keep the size of the environment, and the handler
|
||||||
|
// to call if an abort happens.
|
||||||
|
var PromptFrame = function(label, tag, envLength, handler) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.tag = tag; // ContinuationPromptTag
|
this.tag = tag; // ContinuationPromptTag
|
||||||
|
this.envLength = envLength;
|
||||||
|
this.handler = handler;
|
||||||
};
|
};
|
||||||
PromptFrame.prototype = baselib.heir(Frame.prototype);
|
PromptFrame.prototype = baselib.heir(Frame.prototype);
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,19 @@
|
||||||
var checkHash = baselib.check.checkHash;
|
var checkHash = baselib.check.checkHash;
|
||||||
var checkMutableHash = baselib.check.checkMutableHash;
|
var checkMutableHash = baselib.check.checkMutableHash;
|
||||||
var checkImmutableHash = baselib.check.checkImmutableHash;
|
var checkImmutableHash = baselib.check.checkImmutableHash;
|
||||||
var checkAny = baselib.check.makeCheckArgumentType(
|
|
||||||
function(x) { return true; },
|
// Just for consistency with the other names, we provide checkAny, which
|
||||||
'any');
|
// doesn't really do any checking.
|
||||||
|
var checkAny = function(M, name, offset) {
|
||||||
|
return M.e[M.e.length-1-offset];
|
||||||
|
};
|
||||||
|
|
||||||
|
var checkPromptTag = baselib.check.makeCheckArgumentType(
|
||||||
|
baselib.contmarks.isContinuationPromptTag,
|
||||||
|
'prompt tag');
|
||||||
|
|
||||||
|
var PromptFrame = baselib.frames.PromptFrame;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -3135,6 +3145,45 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
installPrimitiveClosure(
|
||||||
|
'abort-current-continuation',
|
||||||
|
2, //baselib.arity.makeArityAtLeast(1),
|
||||||
|
function(M) {
|
||||||
|
var promptTag = checkPromptTag(M, 'abort-current-continuation', 0);
|
||||||
|
var vals = [];
|
||||||
|
var frame;
|
||||||
|
for(i = 1; i < M.a; i++) {
|
||||||
|
vals.push(M.e[M.e.length-1-i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// First, find the continuation prompt.
|
||||||
|
while(true) {
|
||||||
|
frame = M.c.pop();
|
||||||
|
if (frame instanceof PromptFrame) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Shrink the environment to what was observed when the PromptFrame was installed.
|
||||||
|
M.e.length = frame.envLength;
|
||||||
|
|
||||||
|
// Default behavior:
|
||||||
|
// Re-establish the prompt frame and call the thunk.
|
||||||
|
// FIXME: generalize to different handlers!
|
||||||
|
M.e.push(c);
|
||||||
|
if (isProcedure(vals[0])) {
|
||||||
|
M.p = vals[0];
|
||||||
|
M.a = 0;
|
||||||
|
baselib.functions.rawApply(M);
|
||||||
|
} else {
|
||||||
|
raiseArgumentTypeError(M,
|
||||||
|
'abort-current-continuation',
|
||||||
|
'thunk',
|
||||||
|
1,
|
||||||
|
vals[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports['Primitives'] = Primitives;
|
exports['Primitives'] = Primitives;
|
||||||
|
|
|
@ -229,6 +229,8 @@
|
||||||
current-seconds
|
current-seconds
|
||||||
|
|
||||||
|
|
||||||
|
abort-current-continuation
|
||||||
|
|
||||||
;; needed for cs019-local
|
;; needed for cs019-local
|
||||||
#%stratified-body
|
#%stratified-body
|
||||||
)
|
)
|
||||||
|
|
13
web-world/google-maps/google-maps.rkt
Normal file
13
web-world/google-maps/google-maps.rkt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#lang s-exp "../../lang/base.rkt"
|
||||||
|
|
||||||
|
(require "../../js.rkt")
|
||||||
|
|
||||||
|
(provide load-gmaps-library)
|
||||||
|
|
||||||
|
|
||||||
|
(define (load-gmaps-library api-key with-sensor)
|
||||||
|
(load-script (string-append
|
||||||
|
"http://maps.googleapis.com/maps/api/js?key="
|
||||||
|
api-key
|
||||||
|
"&sensor="
|
||||||
|
(if with-sensor "true" "false"))))
|
Loading…
Reference in New Issue
Block a user