diff options
Diffstat (limited to 'Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp')
-rw-r--r-- | Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp index 0b0fc42e9..08fd618a8 100644 --- a/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp +++ b/Source/JavaScriptCore/inspector/JSJavaScriptCallFrame.cpp @@ -26,7 +26,8 @@ #include "config.h" #include "JSJavaScriptCallFrame.h" -#include "DebuggerScope.h" +#if ENABLE(INSPECTOR) + #include "Error.h" #include "JSCJSValue.h" #include "JSCellInlines.h" @@ -37,7 +38,7 @@ using namespace JSC; namespace Inspector { -const ClassInfo JSJavaScriptCallFrame::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFrame) }; +const ClassInfo JSJavaScriptCallFrame::s_info = { "JavaScriptCallFrame", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSJavaScriptCallFrame) }; JSJavaScriptCallFrame::JSJavaScriptCallFrame(VM& vm, Structure* structure, PassRefPtr<JavaScriptCallFrame> impl) : JSDestructibleObject(vm, structure) @@ -64,8 +65,10 @@ void JSJavaScriptCallFrame::destroy(JSC::JSCell* cell) void JSJavaScriptCallFrame::releaseImpl() { - if (auto impl = std::exchange(m_impl, nullptr)) - impl->deref(); + if (m_impl) { + m_impl->deref(); + m_impl = nullptr; + } } JSJavaScriptCallFrame::~JSJavaScriptCallFrame() @@ -75,7 +78,7 @@ JSJavaScriptCallFrame::~JSJavaScriptCallFrame() JSValue JSJavaScriptCallFrame::evaluate(ExecState* exec) { - NakedPtr<Exception> exception; + JSValue exception; JSValue result = impl().evaluate(exec->argument(0).toString(exec)->value(exec), exception); if (exception) exec->vm().throwException(exec, exception); @@ -92,29 +95,29 @@ JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec) return jsUndefined(); int index = exec->argument(0).asInt32(); - DebuggerScope* scopeChain = impl().scopeChain(); - DebuggerScope::iterator end = scopeChain->end(); - - for (DebuggerScope::iterator iter = scopeChain->begin(); iter != end; ++iter) { - DebuggerScope* scope = iter.get(); + JSScope* scopeChain = impl().scopeChain(); + ScopeChainIterator end = scopeChain->end(); + + // FIXME: We should be identifying and returning CATCH_SCOPE appropriately. + + bool foundLocalScope = false; + for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) { + JSObject* scope = iter.get(); + if (scope->isActivationObject()) { + if (!foundLocalScope) { + // First activation object is local scope, each successive activation object is closure. + if (!index) + return jsNumber(JSJavaScriptCallFrame::LOCAL_SCOPE); + foundLocalScope = true; + } else if (!index) + return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE); + } if (!index) { - if (scope->isCatchScope()) - return jsNumber(JSJavaScriptCallFrame::CATCH_SCOPE); - if (scope->isFunctionNameScope()) - return jsNumber(JSJavaScriptCallFrame::FUNCTION_NAME_SCOPE); - if (scope->isWithScope()) - return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE); - if (scope->isNestedLexicalScope()) - return jsNumber(JSJavaScriptCallFrame::NESTED_LEXICAL_SCOPE); - if (scope->isGlobalLexicalEnvironment()) - return jsNumber(JSJavaScriptCallFrame::GLOBAL_LEXICAL_ENVIRONMENT_SCOPE); - if (scope->isGlobalScope()) { - ASSERT(++iter == end); + // Last in the chain is global scope. + if (++iter == end) return jsNumber(JSJavaScriptCallFrame::GLOBAL_SCOPE); - } - ASSERT(scope->isClosureScope()); - return jsNumber(JSJavaScriptCallFrame::CLOSURE_SCOPE); + return jsNumber(JSJavaScriptCallFrame::WITH_SCOPE); } --index; @@ -154,9 +157,9 @@ JSValue JSJavaScriptCallFrame::scopeChain(ExecState* exec) const if (!impl().scopeChain()) return jsNull(); - DebuggerScope* scopeChain = impl().scopeChain(); - DebuggerScope::iterator iter = scopeChain->begin(); - DebuggerScope::iterator end = scopeChain->end(); + JSScope* scopeChain = impl().scopeChain(); + ScopeChainIterator iter = scopeChain->begin(); + ScopeChainIterator end = scopeChain->end(); // We must always have something in the scope chain. ASSERT(iter != end); @@ -207,3 +210,4 @@ JSJavaScriptCallFrame* toJSJavaScriptCallFrame(JSValue value) } // namespace Inspector +#endif // ENABLE(INSPECTOR) |