continuing to capture marks

This commit is contained in:
Danny Yoo 2011-08-30 12:20:24 -04:00
parent 8d9bddf129
commit 2d87115d2d
5 changed files with 39 additions and 35 deletions

9
broken-fact.rkt Normal file
View File

@ -0,0 +1,9 @@
#lang planet dyoo/whalesong
(define (f x)
(if (= x 0)
"one"
(* x (f (sub1 x)))))
(list (f 3)
(f 4))

View File

@ -121,10 +121,12 @@
var testArity = function (MACHINE, callerName, observed, minimum, maximum) { var testArity = function (MACHINE, callerName, observed, minimum, maximum) {
if (observed < minimum || observed > maximum) { if (observed < minimum || observed > maximum) {
baselib.exceptions.raise( baselib.exceptions.raise(
MACHINE, new Error(callerName + ": expected at least " + minimum MACHINE,
+ " arguments " baselib.exceptions.ExnFailContractArity.constructor(
+ " but received " + observed)); callerName + ": expected at least " + minimum
+ " arguments "
+ " but received " + observed,
MACHINE.captureContinuationMarks()));
} }
}; };

View File

@ -65,6 +65,8 @@
var raise = function(MACHINE, e) { var raise = function(MACHINE, e) {
if (isRacketError(e) && Exn.predicate(e.racketError)) { if (isRacketError(e) && Exn.predicate(e.racketError)) {
e.message = Exn.accessor(e.racketError, 0); e.message = Exn.accessor(e.racketError, 0);
} else if (Exn.predicate(e)) {
e = new RacketError(Exn.accessor(e, 0), e);
} }
if (typeof(window.console) !== 'undefined' && if (typeof(window.console) !== 'undefined' &&
@ -83,11 +85,9 @@
var message = baselib.format.format("Not bound: ~a", [name]); var message = baselib.format.format("Not bound: ~a", [name]);
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, raise(MACHINE,
new RacketError( ExnFailContractVariable.constructor(message,
message, contMarks,
ExnFailContractVariable.constructor(message, baselib.symbols.makeSymbol(name)));
contMarks,
baselib.symbols.makeSymbol(name))));
}; };
@ -105,16 +105,14 @@
expectedTypeName, expectedTypeName,
(argumentOffset + 1), (argumentOffset + 1),
actualValue]); actualValue]);
raise(MACHINE, new RacketError(message, raise(MACHINE, ExnFailContract.constructor(message, contMarks));
ExnFailContract.constructor(message, contMarks)));
} else { } else {
message = baselib.format.format( message = baselib.format.format(
"~a: expected ~a but received ~e", "~a: expected ~a but received ~e",
[callerName, [callerName,
expectedTypeName, expectedTypeName,
actualValue]); actualValue]);
raise(MACHINE, new RacketError(message, raise(MACHINE, ExnFailContract.constructor(message, contMarks));
ExnFailContract.constructor(message, contMarks)));
} }
}; };
@ -122,9 +120,7 @@
var message = baselib.format.format("expected ~e values, received ~e values", var message = baselib.format.format("expected ~e values, received ~e values",
[expected, MACHINE.argcount]); [expected, MACHINE.argcount]);
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, raise(MACHINE, ExnFailContract.constructor(message, contMarks));
new RacketError(message,
ExnFailContract.constructor(message, contMarks)));
}; };
var raiseArityMismatchError = function(MACHINE, proc, expected, received) { var raiseArityMismatchError = function(MACHINE, proc, expected, received) {
@ -133,8 +129,7 @@
expected, expected,
received]); received]);
raise(MACHINE, raise(MACHINE,
new RacketError(message, ExnFailContractArity.constructor(message, contMarks));
ExnFailContractArity.constructor(message, contMarks)));
}; };
var raiseOperatorApplicationError = function(MACHINE, operator) { var raiseOperatorApplicationError = function(MACHINE, operator) {
@ -142,8 +137,7 @@
[operator]); [operator]);
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, raise(MACHINE,
new RacketError(message, ExnFailContract.constructor(message, contMarks));
ExnFailContract.constructor(message, contMarks)));
}; };
var raiseOperatorIsNotClosure = function(MACHINE, operator) { var raiseOperatorIsNotClosure = function(MACHINE, operator) {
@ -151,8 +145,7 @@
[operator]); [operator]);
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, raise(MACHINE,
new RacketError(message, ExnFailContract.constructor(message, contMarks));
ExnFailContract.constructor(message, contMarks)));
}; };
var raiseOperatorIsNotPrimitiveProcedure = function(MACHINE, operator) { var raiseOperatorIsNotPrimitiveProcedure = function(MACHINE, operator) {
@ -160,16 +153,15 @@
[operator]); [operator]);
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, raise(MACHINE,
new RacketError(message, ExnFailContract.constructor(message, contMarks));
ExnFailContract.constructor(message, contMarks)));
}; };
var raiseUnimplementedPrimitiveError = function(MACHINE, name) { var raiseUnimplementedPrimitiveError = function(MACHINE, name) {
var message = "unimplemented kernel procedure: " + name; var message = "unimplemented kernel procedure: " + name;
var contMarks = MACHINE.captureContinuationMarks(); var contMarks = MACHINE.captureContinuationMarks();
raise(MACHINE, new RacketError(message, raise(MACHINE,
ExnFailContract.constructor(message, contMarks))); ExnFailContract.constructor(message, contMarks));
}; };

View File

@ -212,10 +212,11 @@
return coerseClosureToJavaScript(v, MACHINE); return coerseClosureToJavaScript(v, MACHINE);
} else { } else {
baselib.exceptions.raise(MACHINE, baselib.exceptions.raise(MACHINE,
baselib.exceptions.makeExnFail( baselib.exceptions.makeExnFailContract(
baselib.format.format( baselib.format.format(
"Not a procedure: ~e", "Not a procedure: ~e",
v))); v),
MACHINE.captureContinuationMarks()));
} }
}; };

View File

@ -1465,8 +1465,8 @@
var i; var i;
if (MACHINE.argcount === 1) { if (MACHINE.argcount === 1) {
var sym = checkSymbol(MACHINE, 'error', 1); var sym = checkSymbol(MACHINE, 'error', 1);
// FIXME: we should collect the current continuation marks here... raise(MACHINE, baselib.exceptions.makeExnFail(String(sym),
raise(MACHINE, baselib.exceptions.makeExnFail(String(sym), undefined)); MACHINE.captureContinuationMarks()));
} }
if (isString(MACHINE.env[MACHINE.env.length - 1])) { if (isString(MACHINE.env[MACHINE.env.length - 1])) {
@ -1477,7 +1477,7 @@
raise(MACHINE, baselib.exceptions.makeExnFail(String(MACHINE.env[MACHINE.env.length - 1]) + raise(MACHINE, baselib.exceptions.makeExnFail(String(MACHINE.env[MACHINE.env.length - 1]) +
": " + ": " +
vs.join(' '), vs.join(' '),
undefined)); MACHINE.captureContinuationMarks()));
} }
if (isSymbol(MACHINE.env[MACHINE.env.length - 1])) { if (isSymbol(MACHINE.env[MACHINE.env.length - 1])) {
@ -1489,7 +1489,7 @@
raise(MACHINE, baselib.exceptions.makeExnFail( raise(MACHINE, baselib.exceptions.makeExnFail(
baselib.format.format('~s: ' + String(fmtString), baselib.format.format('~s: ' + String(fmtString),
args), args),
undefined)); MACHINE.captureContinuationMarks()));
} }
// Fall-through // Fall-through
@ -1509,7 +1509,7 @@
[name, [name,
message, message,
val]), val]),
undefined)); MACHINE.captureContinuationMarks()));
}); });