From 7a90818f3188ecd17fbbcc7207aaed50c00e82ee Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 15 May 2018 14:09:07 +0200 Subject: 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 --- src/qml/compiler/qv4compilerscanfunctions.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') 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()) -- cgit v1.2.3