diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-15 14:09:07 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-23 13:19:08 +0000 |
commit | 7a90818f3188ecd17fbbcc7207aaed50c00e82ee (patch) | |
tree | 0023e6b42a316f82e6a8c0e3f3165ce8b7cb5766 /src/qml/compiler/qv4compilerscanfunctions.cpp | |
parent | df616013cabfe255398868ab742d54e8558bff12 (diff) | |
download | qtdeclarative-7a90818f3188ecd17fbbcc7207aaed50c00e82ee.tar.gz |
Set the usesThis flag on the function context
While the old code was also leading to correct results,
it was less efficient, as we would have added the
ConvertThisToObject instruction multiple times (once
for each block that uses 'this'.
Change-Id: Ia1f99b681b4494110d189f1bb6dded18fa413b53
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 88fccc548d..9605b72b76 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -568,6 +568,17 @@ void ScanFunctions::calcEscapingVariables() c = c->parent; } } + if (inner->usesThis) { + inner->usesThis = false; + if (!inner->isStrict) { + Context *c = inner; + while (c->contextType == ContextType::Block) { + c = c->parent; + } + Q_ASSERT(c); + c->usesThis = true; + } + } } for (Context *c : qAsConst(m->contextMap)) { if (c->allVarsEscape && c->contextType == ContextType::Block && c->members.isEmpty()) |