зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1271650 - Implement a C++ interface for DebuggerFrame.getEnvironment;r=fitzgen
This commit is contained in:
Родитель
d4e4255ecb
Коммит
38828ee358
|
@ -7067,26 +7067,6 @@ DebuggerFrame::getIsConstructing(JSContext* cx, Handle<DebuggerFrame*> frame, bo
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerFrame::getScriptFrameIter(JSContext* cx, Handle<DebuggerFrame*> frame,
|
||||
Maybe<ScriptFrameIter>& result)
|
||||
{
|
||||
AbstractFramePtr referent = AbstractFramePtr::FromRaw(frame->getPrivate());
|
||||
if (referent.isScriptFrameIterData()) {
|
||||
result.emplace(*reinterpret_cast<ScriptFrameIter::Data*>(referent.raw()));
|
||||
} else {
|
||||
result.emplace(cx, ScriptFrameIter::IGNORE_DEBUGGER_EVAL_PREV_LINK);
|
||||
ScriptFrameIter& iter = *result;
|
||||
while (!iter.hasUsableAbstractFramePtr() || iter.abstractFramePtr() != referent)
|
||||
++iter;
|
||||
AbstractFramePtr data = iter.copyDataAsAbstractFramePtr();
|
||||
if (!data)
|
||||
return false;
|
||||
frame->setPrivate(data.raw());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateFrameIterPc(FrameIter& iter)
|
||||
{
|
||||
|
@ -7124,6 +7104,49 @@ UpdateFrameIterPc(FrameIter& iter)
|
|||
iter.updatePcQuadratic();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerFrame::getEnvironment(JSContext* cx, Handle<DebuggerFrame*> frame,
|
||||
MutableHandle<DebuggerEnvironment*> result)
|
||||
{
|
||||
Debugger* dbg = frame->owner();
|
||||
|
||||
Maybe<ScriptFrameIter> maybeIter;
|
||||
if (!DebuggerFrame::getScriptFrameIter(cx, frame, maybeIter))
|
||||
return false;
|
||||
ScriptFrameIter& iter = *maybeIter;
|
||||
|
||||
Rooted<Env*> env(cx);
|
||||
{
|
||||
AutoCompartment ac(cx, iter.abstractFramePtr().scopeChain());
|
||||
UpdateFrameIterPc(iter);
|
||||
env = GetDebugScopeForFrame(cx, iter.abstractFramePtr(), iter.pc());
|
||||
if (!env)
|
||||
return false;
|
||||
}
|
||||
|
||||
return dbg->wrapEnvironment(cx, env, result);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
DebuggerFrame::getScriptFrameIter(JSContext* cx, Handle<DebuggerFrame*> frame,
|
||||
Maybe<ScriptFrameIter>& result)
|
||||
{
|
||||
AbstractFramePtr referent = AbstractFramePtr::FromRaw(frame->getPrivate());
|
||||
if (referent.isScriptFrameIterData()) {
|
||||
result.emplace(*reinterpret_cast<ScriptFrameIter::Data*>(referent.raw()));
|
||||
} else {
|
||||
result.emplace(cx, ScriptFrameIter::IGNORE_DEBUGGER_EVAL_PREV_LINK);
|
||||
ScriptFrameIter& iter = *result;
|
||||
while (!iter.hasUsableAbstractFramePtr() || iter.abstractFramePtr() != referent)
|
||||
++iter;
|
||||
AbstractFramePtr data = iter.copyDataAsAbstractFramePtr();
|
||||
if (!data)
|
||||
return false;
|
||||
frame->setPrivate(data.raw());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
DebuggerFrame_freeScriptFrameIterData(FreeOp* fop, JSObject* obj)
|
||||
{
|
||||
|
@ -7293,21 +7316,17 @@ DebuggerFrame_getImplementation(JSContext* cx, unsigned argc, Value* vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DebuggerFrame_getEnvironment(JSContext* cx, unsigned argc, Value* vp)
|
||||
/* static */ bool
|
||||
DebuggerFrame::environmentGetter(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_FRAME_OWNER_ITER(cx, argc, vp, "get environment", args, thisobj, _, iter, dbg);
|
||||
THIS_DEBUGGER_FRAME(cx, argc, vp, "get environment", args, frame);
|
||||
|
||||
Rooted<Env*> env(cx);
|
||||
{
|
||||
AutoCompartment ac(cx, iter.abstractFramePtr().scopeChain());
|
||||
UpdateFrameIterPc(iter);
|
||||
env = GetDebugScopeForFrame(cx, iter.abstractFramePtr(), iter.pc());
|
||||
if (!env)
|
||||
return false;
|
||||
}
|
||||
Rooted<DebuggerEnvironment*> result(cx);
|
||||
if (!DebuggerFrame::getEnvironment(cx, frame, &result))
|
||||
return false;
|
||||
|
||||
return dbg->wrapEnvironment(cx, env, args.rval());
|
||||
args.rval().setObject(*result);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
|
@ -7856,7 +7875,7 @@ const JSPropertySpec DebuggerFrame::properties_[] = {
|
|||
JS_PSG("arguments", DebuggerFrame_getArguments, 0),
|
||||
JS_PSG("callee", DebuggerFrame::calleeGetter, 0),
|
||||
JS_PSG("constructing", DebuggerFrame::constructingGetter, 0),
|
||||
JS_PSG("environment", DebuggerFrame_getEnvironment, 0),
|
||||
JS_PSG("environment", DebuggerFrame::environmentGetter, 0),
|
||||
JS_PSG("generator", DebuggerFrame_getGenerator, 0),
|
||||
JS_PSG("live", DebuggerFrame_getLive, 0),
|
||||
JS_PSG("offset", DebuggerFrame_getOffset, 0),
|
||||
|
|
|
@ -1151,6 +1151,8 @@ class DebuggerFrame : public NativeObject
|
|||
MutableHandle<DebuggerObject*> result);
|
||||
static MOZ_MUST_USE bool getIsConstructing(JSContext* cx, Handle<DebuggerFrame*> frame,
|
||||
bool& result);
|
||||
static MOZ_MUST_USE bool getEnvironment(JSContext* cx, Handle<DebuggerFrame*> frame,
|
||||
MutableHandle<DebuggerEnvironment*> result);
|
||||
|
||||
private:
|
||||
static const ClassOps classOps_;
|
||||
|
@ -1165,6 +1167,7 @@ class DebuggerFrame : public NativeObject
|
|||
|
||||
static MOZ_MUST_USE bool calleeGetter(JSContext* cx, unsigned argc, Value* vp);
|
||||
static MOZ_MUST_USE bool constructingGetter(JSContext* cx, unsigned argc, Value* vp);
|
||||
static MOZ_MUST_USE bool environmentGetter(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
AbstractFramePtr referent() const;
|
||||
Debugger* owner() const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче