aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-08 15:21:27 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:16 +0000
commita8766dcd8c3a046aab1453ec3d28436bb75c895c (patch)
treea3ec1dd79c8a1604e0009b25aa01a9050c15cbb5 /src/qml/parser/qqmljsast_p.h
parent01a1ad296c2b8325476abd6d28c8cc2463c42eb6 (diff)
Unify ForeachStatement and LocalForeachStatement in the AST
This saves quite some duplicated code, but requires a bit of care when iterating over the AST. Change-Id: Ic530de4be8b36b4079c9d544b4b77982c3b8be60 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r--src/qml/parser/qqmljsast_p.h41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 36060f7358..83fcb6559c 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -174,7 +174,6 @@ public:
Kind_ComputedPropertyName,
Kind_IfStatement,
Kind_LabelledStatement,
- Kind_LocalForEachStatement,
Kind_LocalForStatement,
Kind_NewExpression,
Kind_NewMemberExpression,
@@ -1711,37 +1710,12 @@ class QML_PARSER_EXPORT ForEachStatement: public Statement
public:
QQMLJS_DECLARE_AST_NODE(ForEachStatement)
- ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt):
- initialiser (i), expression (e), statement (stmt)
- { kind = K; }
-
- void accept0(Visitor *visitor) override;
-
- SourceLocation firstSourceLocation() const override
- { return forToken; }
-
- SourceLocation lastSourceLocation() const override
- { return statement->lastSourceLocation(); }
-
-// attributes
- ExpressionNode *initialiser;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation inOfToken;
- SourceLocation rparenToken;
- ForEachType type;
-};
-
-class QML_PARSER_EXPORT LocalForEachStatement: public Statement
-{
-public:
- QQMLJS_DECLARE_AST_NODE(LocalForEachStatement)
-
- LocalForEachStatement(PatternElement *v, ExpressionNode *e, Statement *stmt):
- declaration (v), expression (e), statement (stmt)
- { kind = K; }
+ ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt)
+ : lhs(i), expression(e), statement(stmt)
+ { kind = K; }
+ ForEachStatement(PatternElement *v, ExpressionNode *e, Statement *stmt)
+ : lhs(v), expression(e), statement(stmt)
+ { kind = K; }
void accept0(Visitor *visitor) override;
@@ -1752,12 +1726,11 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- PatternElement *declaration;
+ Node *lhs;
ExpressionNode *expression;
Statement *statement;
SourceLocation forToken;
SourceLocation lparenToken;
- SourceLocation varToken;
SourceLocation inOfToken;
SourceLocation rparenToken;
ForEachType type;