diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-04 15:16:08 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-11 07:17:05 +0000 |
commit | 4cf7e80c5740912804383e4d866ba12b2520d0e6 (patch) | |
tree | 143d960492aa166a7f3d7111b64151c42234a81f /src/plugins | |
parent | 2fc50421c86134b5b42a4ba68aa7f6b87cfd7d74 (diff) |
Ensure we have a lexical scope for global code
This requires a bit more work than simply pushing a
new BlockContext for the lexically declared variables,
as eval() and the Function constructor operate on the
global scope (including the lexically declared names).
To fix this introduce Push/PopScriptContext instructions,
that create a BlockContext for the lexically declared
vars and pushes that one as a global script context that
eval and friends use.
Change-Id: I0fd0b0f682f82e250545e874fe93978449fe5e46
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index a00454758e..70f71de6ca 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -65,7 +65,7 @@ void JavaScriptJob::run() QV4::Scope scope(engine); QV4::ScopedContext ctx(scope, engine->currentStackFrame ? engine->currentContext() - : engine->rootContext()); + : engine->scriptContext()); QObject scopeObject; QV4::CppStackFrame *frame = engine->currentStackFrame; diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 298608b63e..36390a3ea5 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -253,7 +253,7 @@ QV4::ReturnedValue NativeDebugger::evaluateExpression(const QString &expression) m_runningJob = true; QV4::ExecutionContext *ctx = m_engine->currentStackFrame ? m_engine->currentContext() - : m_engine->rootContext(); + : m_engine->scriptContext(); QV4::Script script(ctx, QV4::Compiler::ContextType::Eval, expression); if (const QV4::Function *function = m_engine->currentStackFrame |