aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilerscanfunctions.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-09 14:03:39 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:22 +0000
commite3b9726483cb7336aa54ae7d9455becbd148b2b6 (patch)
treeba056c898a9a694179104e1fd4f4f32d91a6dd86 /src/qml/compiler/qv4compilerscanfunctions.cpp
parent541b8220cffbbae4b798ae8282d04ca145caccd1 (diff)
Improve for-in and for-of support
Create a Block scope per iteration as defined in the ES spec. So closures created inside the loop will remember the iteration variable at that loop iteration. Add support for destructuring of the left hand side expression or declaration. Change-Id: Id06ef94e2a4b93646827da4f6ce922eb436e5a31 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index eadbc3ae17..ccf7e49e25 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -342,6 +342,8 @@ bool ScanFunctions::visit(LocalForStatement *ast) {
}
bool ScanFunctions::visit(ForEachStatement *ast) {
+ enterEnvironment(ast, ContextType::Block);
+ _context->name = QLatin1String("Foreach");
Node::accept(ast->lhs, this);
Node::accept(ast->expression, this);
@@ -351,6 +353,11 @@ bool ScanFunctions::visit(ForEachStatement *ast) {
return false;
}
+void ScanFunctions::endVisit(ForEachStatement *)
+{
+ leaveEnvironment();
+}
+
bool ScanFunctions::visit(ThisExpression *)
{
_context->usesThis = true;