diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-01-20 13:57:16 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-01-21 14:49:43 +0000 |
commit | ce093497f2d4164fa8abc06cf976f9e36798e11e (patch) | |
tree | 98c3926f5a64b4bf8f8b3838b6fbcde8ad9152c7 /src/plugins | |
parent | ebb08ee84e8141042ed16dfc5892697ef96077c4 (diff) |
Clean up QV4DataCollector
We don't need to pass engines around as the data collector already has
all the necessary information. Also, the exception collect job is only
used in the test case, so we don't need to define it in the collector.
Change-Id: I9e9f092a10295e3dc970f7b5f440e8f242ea1d54
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins')
4 files changed, 13 insertions, 44 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index a3f59870a2..f85c7f704d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -58,9 +58,9 @@ QT_BEGIN_NAMESPACE const QV4DataCollector::Ref QV4DataCollector::s_invalidRef = std::numeric_limits<QV4DataCollector::Ref>::max(); -QV4::CallContext *QV4DataCollector::findContext(QV4::ExecutionEngine *engine, int frame) +QV4::CallContext *QV4DataCollector::findContext(int frame) { - QV4::ExecutionContext *ctx = engine->currentContext; + QV4::ExecutionContext *ctx = engine()->currentContext; while (ctx) { QV4::CallContext *cCtxt = ctx->asCallContext(); if (cCtxt && cCtxt->d()->function) { @@ -68,7 +68,7 @@ QV4::CallContext *QV4DataCollector::findContext(QV4::ExecutionEngine *engine, in return cCtxt; --frame; } - ctx = engine->parentContext(ctx); + ctx = engine()->parentContext(ctx); } return 0; @@ -87,13 +87,12 @@ QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::ExecutionContext *ctxt, return (ctx && ctx->d()) ? ctx->asCallContext()->d() : 0; } -QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes( - QV4::ExecutionEngine *engine, int frame) +QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes(int frame) { QVector<QV4::Heap::ExecutionContext::ContextType> types; - QV4::Scope scope(engine); - QV4::CallContext *sctxt = findContext(engine, frame); + QV4::Scope scope(engine()); + QV4::CallContext *sctxt = findContext(frame); if (!sctxt || sctxt->d()->type < QV4::Heap::ExecutionContext::Type_QmlContext) return types; @@ -254,7 +253,7 @@ bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) QStringList names; QV4::Scope scope(engine()); - QV4::Scoped<QV4::CallContext> ctxt(scope, findScope(findContext(engine(), frameNr), scopeNr)); + QV4::Scoped<QV4::CallContext> ctxt(scope, findScope(findContext(frameNr), scopeNr)); if (!ctxt) return false; @@ -314,7 +313,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int QJsonArray scopes; QV4::Scope scope(engine()); - QV4::ScopedContext ctxt(scope, findContext(engine(), frameNr)); + QV4::ScopedContext ctxt(scope, findContext(frameNr)); while (ctxt) { if (QV4::CallContext *cCtxt = ctxt->asCallContext()) { if (cCtxt->d()->activation) @@ -329,7 +328,7 @@ QJsonObject QV4DataCollector::buildFrame(const QV4::StackFrame &stackFrame, int } // Only type and index are used by Qt Creator, so we keep it easy: - QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(engine(), frameNr); + QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = getScopeTypes(frameNr); for (int i = 0, ei = scopeTypes.count(); i != ei; ++i) { int type = encodeScopeType(scopeTypes[i]); if (type == -1) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 1c3a05960c..aea03d2257 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -56,12 +56,12 @@ public: typedef QVector<uint> Refs; static const Ref s_invalidRef; - static QV4::CallContext *findContext(QV4::ExecutionEngine *engine, int frame); static QV4::Heap::CallContext *findScope(QV4::ExecutionContext *ctxt, int scope); - static QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes( - QV4::ExecutionEngine *engine, int frame); static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); + QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes(int frame); + QV4::CallContext *findContext(int frame); + QV4DataCollector(QV4::ExecutionEngine *engine); Ref collect(const QV4::ScopedValue &value); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index d60db6cf82..a2d2fff72b 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -173,7 +173,7 @@ void ScopeJob::run() if (success) { QVector<QV4::Heap::ExecutionContext::ContextType> scopeTypes = - QV4DataCollector::getScopeTypes(collector->engine(), frameNr); + collector->getScopeTypes(frameNr); result[QLatin1String("type")] = QV4DataCollector::encodeScopeType(scopeTypes[scopeNr]); } else { result[QLatin1String("type")] = -1; @@ -270,24 +270,6 @@ const QStringList &GatherSourcesJob::result() const return sources; } -ExceptionCollectJob::ExceptionCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector) - : engine(engine) - , collector(collector) - , exception(QV4DataCollector::s_invalidRef) -{} - -void ExceptionCollectJob::run() -{ - QV4::Scope scope(engine); - QV4::ScopedValue v(scope, *engine->exceptionValue); - exception = collector->collect(v); -} - -QV4DataCollector::Ref ExceptionCollectJob::exceptionValue() const -{ - return exception; -} - EvalJob::EvalJob(QV4::ExecutionEngine *engine, const QString &script) : JavaScriptJob(engine, /*frameNr*/-1, script), result(false) {} diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h index a1adbeff40..721f42b7c2 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h @@ -154,18 +154,6 @@ public: const QStringList &result() const; }; -class ExceptionCollectJob: public QV4DebugJob -{ - QV4::ExecutionEngine *engine; - QV4DataCollector *collector; - QV4DataCollector::Ref exception; - -public: - ExceptionCollectJob(QV4::ExecutionEngine *engine, QV4DataCollector *collector); - void run(); - QV4DataCollector::Ref exceptionValue() const; -}; - class EvalJob: public JavaScriptJob { bool result; |