diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-15 14:03:09 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-23 13:19:05 +0000 |
commit | df616013cabfe255398868ab742d54e8558bff12 (patch) | |
tree | bd9e1d8d29998760c5621c3e62d6b43cd9ee48bf /src/qml/compiler/qv4compilerscanfunctions.cpp | |
parent | 6f1e2722b9eef73a4fe19951b47c4b172642a2ba (diff) |
Cleanup handling of direct evals
There's no need to force lookups by name in an outer function
just because an inner function uses eval(). The lookup by name
is only required on the call context level, where eval() could
add new variables.
Change-Id: I8cad6d27524f496304342dfe1449ea913ef99fca
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index ef69706f5d..88fccc548d 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -552,19 +552,29 @@ void ScanFunctions::calcEscapingVariables() c = c->parent; } } - Context *c = inner->parent; - while (c) { - c->hasDirectEval |= inner->hasDirectEval; - c = c->parent; + if (inner->hasDirectEval) { + inner->hasDirectEval = false; + if (!inner->isStrict) { + Context *c = inner; + while (c->contextType == ContextType::Block) { + c = c->parent; + } + Q_ASSERT(c); + c->hasDirectEval = true; + } + Context *c = inner; + while (c) { + c->allVarsEscape = true; + c = c->parent; + } } } for (Context *c : qAsConst(m->contextMap)) { - bool allVarsEscape = c->hasDirectEval; - if (allVarsEscape && c->contextType == ContextType::Block && c->members.isEmpty()) - allVarsEscape = false; + if (c->allVarsEscape && c->contextType == ContextType::Block && c->members.isEmpty()) + c->allVarsEscape = false; if (!c->parent || m->debugMode) - allVarsEscape = true; - if (allVarsEscape) { + c->allVarsEscape = true; + if (c->allVarsEscape) { if (c->parent) { c->requiresExecutionContext = true; c->argumentsCanEscape = true; @@ -588,7 +598,7 @@ void ScanFunctions::calcEscapingVariables() // we don't really need this for bindings, but we do for signal handlers, and in this case, // we don't know if the code is a signal handler or not. c->requiresExecutionContext = true; - if (allVarsEscape) { + if (c->allVarsEscape) { for (auto &m : c->members) m.canEscape = true; } |