mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1470558: Delete Debugger::{resultToCompletion,newCompletionValue,receiveCompletionValue}. r=jorendorff
All uses of these have been rewritten to use the Completion type. Differential Revision: https://phabricator.services.mozilla.com/D33079 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
53b25d6db0
commit
40b709bc47
@ -2129,87 +2129,6 @@ void Completion::toResumeMode(ResumeMode& resumeMode, MutableHandleValue value,
|
||||
resumeMode = variant.match(ToResumeModeMatcher(value, exnStack));
|
||||
}
|
||||
|
||||
/* static */
|
||||
void Debugger::resultToCompletion(JSContext* cx, bool ok, const Value& rv,
|
||||
ResumeMode* resumeMode,
|
||||
MutableHandleValue value,
|
||||
MutableHandleSavedFrame exnStack) {
|
||||
MOZ_ASSERT_IF(ok, !cx->isExceptionPending());
|
||||
|
||||
if (ok) {
|
||||
*resumeMode = ResumeMode::Return;
|
||||
value.set(rv);
|
||||
} else if (cx->isExceptionPending()) {
|
||||
*resumeMode = ResumeMode::Throw;
|
||||
if (!cx->getPendingException(value)) {
|
||||
*resumeMode = ResumeMode::Terminate;
|
||||
}
|
||||
exnStack.set(cx->getPendingExceptionStack());
|
||||
cx->clearPendingException();
|
||||
} else {
|
||||
*resumeMode = ResumeMode::Terminate;
|
||||
value.setUndefined();
|
||||
}
|
||||
}
|
||||
|
||||
bool Debugger::newCompletionValue(JSContext* cx, ResumeMode resumeMode,
|
||||
const Value& value_, SavedFrame* exnStack_,
|
||||
MutableHandleValue result) {
|
||||
// We must be in the debugger's compartment, since that's where we want
|
||||
// to construct the completion value.
|
||||
cx->check(object.get());
|
||||
cx->check(value_);
|
||||
|
||||
RootedId key(cx);
|
||||
RootedValue value(cx, value_);
|
||||
RootedSavedFrame exnStack(cx, exnStack_);
|
||||
|
||||
switch (resumeMode) {
|
||||
case ResumeMode::Return:
|
||||
key = NameToId(cx->names().return_);
|
||||
break;
|
||||
|
||||
case ResumeMode::Throw:
|
||||
key = NameToId(cx->names().throw_);
|
||||
break;
|
||||
|
||||
case ResumeMode::Terminate:
|
||||
result.setNull();
|
||||
return true;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("bad resume mode passed to Debugger::newCompletionValue");
|
||||
}
|
||||
|
||||
// Common tail for ResumeMode::Return and ResumeMode::Throw.
|
||||
RootedPlainObject obj(cx, NewBuiltinClassInstance<PlainObject>(cx));
|
||||
if (!obj ||
|
||||
!NativeDefineDataProperty(cx, obj, key, value, JSPROP_ENUMERATE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exnStack) {
|
||||
RootedId nkey(cx, NameToId(cx->names().stack));
|
||||
RootedValue nvalue(cx, ObjectValue(*exnStack));
|
||||
if (!cx->compartment()->wrap(cx, &nvalue) ||
|
||||
!NativeDefineDataProperty(cx, obj, nkey, nvalue, JSPROP_ENUMERATE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
result.setObject(*obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Debugger::receiveCompletionValue(Maybe<AutoRealm>& ar, bool ok,
|
||||
HandleValue val, MutableHandleValue vp) {
|
||||
JSContext* cx = ar->context();
|
||||
|
||||
Rooted<Completion> completion(cx, Completion::fromJSResult(cx, ok, val));
|
||||
ar.reset();
|
||||
return completion.get().buildCompletionValue(cx, this, vp);
|
||||
}
|
||||
|
||||
/*** Firing debugger hooks **************************************************/
|
||||
|
||||
static bool CallMethodIfPresent(JSContext* cx, HandleObject obj,
|
||||
|
@ -1313,46 +1313,6 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
MOZ_MUST_USE bool getFrame(JSContext* cx, const FrameIter& iter,
|
||||
MutableHandleDebuggerFrame result);
|
||||
|
||||
/*
|
||||
* Set |*resumeMode| and |*value| to a (ResumeMode, Value) pair reflecting a
|
||||
* standard SpiderMonkey call state: a boolean success value |ok|, a return
|
||||
* value |rv|, and a context |cx| that may or may not have an exception set.
|
||||
* If an exception was pending on |cx|, it is cleared (and |ok| is asserted
|
||||
* to be false). On exceptional returns, exnStack will be set to any stack
|
||||
* associated with the original throw, if available.
|
||||
*/
|
||||
static void resultToCompletion(JSContext* cx, bool ok, const Value& rv,
|
||||
ResumeMode* resumeMode,
|
||||
MutableHandleValue value,
|
||||
MutableHandleSavedFrame exnStack);
|
||||
|
||||
/*
|
||||
* Set |*result| to a JavaScript completion value corresponding to
|
||||
* |resumeMode| and |value|. |value| should be the return value or exception
|
||||
* value, not wrapped as a debuggee value. When throwing an exception,
|
||||
* |exnStack| may be set to the stack when the value was thrown. |cx| must be
|
||||
* in the debugger compartment.
|
||||
*/
|
||||
MOZ_MUST_USE bool newCompletionValue(JSContext* cx, ResumeMode resumeMode,
|
||||
const Value& value, SavedFrame* exnStack,
|
||||
MutableHandleValue result);
|
||||
|
||||
/*
|
||||
* Precondition: we are in the debuggee realm (ar is entered) and ok is true
|
||||
* if the operation in the debuggee realm succeeded, false on error or
|
||||
* exception.
|
||||
*
|
||||
* Postcondition: we are in the debugger realm, having called `ar.reset()`
|
||||
* even if an error occurred.
|
||||
*
|
||||
* On success, a completion value is in vp and ar.context does not have a
|
||||
* pending exception. (This ordinarily returns true even if the ok argument
|
||||
* is false.)
|
||||
*/
|
||||
MOZ_MUST_USE bool receiveCompletionValue(mozilla::Maybe<AutoRealm>& ar,
|
||||
bool ok, HandleValue val,
|
||||
MutableHandleValue vp);
|
||||
|
||||
/*
|
||||
* Return the Debugger.Script object for |script|, or create a new one if
|
||||
* needed. The context |cx| must be in the debugger realm; |script| must be
|
||||
|
Loading…
Reference in New Issue
Block a user