diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-11-30 16:20:32 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-12-06 13:01:44 +0000 |
commit | b4ccdf004af8ab5b9e327abf7f87d0bd34ee13c0 (patch) | |
tree | d8152287ce8401d4725ad4d0ba6b84a71e1e4f3e /src/plugins/qmltooling | |
parent | 54c79346f1929ff14673e1ab40a1bfd66ba6e2c5 (diff) |
Change ExecutionContext::getFunctionObject() to getFunction()
And return a QV4::Function from now on. This simplifies code in
other places and provides all the info required for stack traces
and debugging.
Change-Id: I512a8ac3932268d8cfc60675e75c4661d1f16fd8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins/qmltooling')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp | 24 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp | 5 |
2 files changed, 11 insertions, 18 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index 5b96163b48..14dfc5356e 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -336,18 +336,16 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a QJsonArray frameArray; QV4::ExecutionContext *executionContext = m_engine->currentContext; for (int i = 0; i < limit && executionContext; ++i) { - QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject(); - if (heapFunctionObject) { + if (QV4::Function *function = executionContext->getFunction()) { QJsonObject frame; frame[QStringLiteral("language")] = QStringLiteral("js"); frame[QStringLiteral("context")] = encodeContext(executionContext); - if (QV4::Function *function = heapFunctionObject->function) { - if (QV4::Heap::String *functionName = function->name()) - frame[QStringLiteral("function")] = functionName->toQString(); - frame[QStringLiteral("file")] = function->sourceFile(); - } + if (QV4::Heap::String *functionName = function->name()) + frame[QStringLiteral("function")] = functionName->toQString(); + frame[QStringLiteral("file")] = function->sourceFile(); + int line = executionContext->d()->lineNumber; frame[QStringLiteral("line")] = (line < 0 ? -line : line); @@ -667,11 +665,9 @@ void NativeDebugger::aboutToThrow() QV4::Function *NativeDebugger::getFunction() const { - QV4::Scope scope(m_engine); QV4::ExecutionContext *context = m_engine->currentContext; - QV4::ScopedFunctionObject function(scope, context->getFunctionObject()); - if (function) - return function->function(); + if (QV4::Function *function = context->getFunction()) + return function; else return context->d()->engine->globalCode; } @@ -683,10 +679,8 @@ void NativeDebugger::pauseAndWait() event.insert(QStringLiteral("event"), QStringLiteral("break")); event.insert(QStringLiteral("language"), QStringLiteral("js")); if (QV4::ExecutionContext *executionContext = m_engine->currentContext) { - QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject(); - if (heapFunctionObject) { - if (QV4::Function *function = heapFunctionObject->function) - event.insert(QStringLiteral("file"), function->sourceFile()); + if (QV4::Function *function = executionContext->getFunction()) { + event.insert(QStringLiteral("file"), function->sourceFile()); int line = executionContext->d()->lineNumber; event.insert(QStringLiteral("line"), (line < 0 ? -line : line)); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 44810dd4cb..5cc2043cb1 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -252,9 +252,8 @@ QV4::Function *QV4Debugger::getFunction() const { QV4::Scope scope(m_engine); QV4::ExecutionContext *context = m_engine->currentContext; - QV4::ScopedFunctionObject function(scope, context->getFunctionObject()); - if (function) - return function->function(); + if (QV4::Function *function = context->getFunction()) + return function; else return context->d()->engine->globalCode; } |