aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-05-10 22:25:46 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-11 07:17:26 +0000
commite203a868470ab2e435111127f00530f4d8cc581d (patch)
treeff7313f90b62b6953ac8369dbd93600bcbe437ff /src/qml/parser
parente3b9726483cb7336aa54ae7d9455becbd148b2b6 (diff)
Unify AST for the different 'for' statements
Change-Id: I70ca83b0ce933d64dad4984a236e48592e989742 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g3
-rw-r--r--src/qml/parser/qqmljsast.cpp11
-rw-r--r--src/qml/parser/qqmljsast_p.h33
-rw-r--r--src/qml/parser/qqmljsastfwd_p.h1
-rw-r--r--src/qml/parser/qqmljsastvisitor_p.h3
5 files changed, 5 insertions, 46 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 4b1dc437f4..ad19fbe0d9 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -3113,12 +3113,11 @@ IterationStatement: T_FOR T_LPAREN LexicalDeclaration T_SEMICOLON ExpressionOpt_
/.
case $rule_number: {
// ### get rid of the static_cast!
- AST::LocalForStatement *node = new (pool) AST::LocalForStatement(
+ AST::ForStatement *node = new (pool) AST::ForStatement(
static_cast<AST::VariableStatement *>(sym(3).Node)->declarations, sym(5).Expression,
sym(7).Expression, sym(9).Statement);
node->forToken = loc(1);
node->lparenToken = loc(2);
- node->varToken = loc(3);
node->firstSemicolonToken = loc(4);
node->secondSemicolonToken = loc(6);
node->rparenToken = loc(8);
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp
index bf3e193291..814262d98b 100644
--- a/src/qml/parser/qqmljsast.cpp
+++ b/src/qml/parser/qqmljsast.cpp
@@ -768,17 +768,6 @@ void ForStatement::accept0(Visitor *visitor)
{
if (visitor->visit(this)) {
accept(initialiser, visitor);
- accept(condition, visitor);
- accept(expression, visitor);
- accept(statement, visitor);
- }
-
- visitor->endVisit(this);
-}
-
-void LocalForStatement::accept0(Visitor *visitor)
-{
- if (visitor->visit(this)) {
accept(declarations, visitor);
accept(condition, visitor);
accept(expression, visitor);
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 9ed7ba79e5..91d6410132 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_LocalForStatement,
Kind_NewExpression,
Kind_NewMemberExpression,
Kind_NotExpression,
@@ -1650,35 +1649,11 @@ public:
initialiser (i), condition (c), 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 *condition;
- ExpressionNode *expression;
- Statement *statement;
- SourceLocation forToken;
- SourceLocation lparenToken;
- SourceLocation firstSemicolonToken;
- SourceLocation secondSemicolonToken;
- SourceLocation rparenToken;
-};
-
-class QML_PARSER_EXPORT LocalForStatement: public Statement
-{
-public:
- QQMLJS_DECLARE_AST_NODE(LocalForStatement)
-
- LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
+ ForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt):
declarations (vlist), condition (c), expression (e), statement (stmt)
{ kind = K; }
+
void accept0(Visitor *visitor) override;
SourceLocation firstSourceLocation() const override
@@ -1688,13 +1663,13 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- VariableDeclarationList *declarations;
+ ExpressionNode *initialiser = nullptr;
+ VariableDeclarationList *declarations = nullptr;
ExpressionNode *condition;
ExpressionNode *expression;
Statement *statement;
SourceLocation forToken;
SourceLocation lparenToken;
- SourceLocation varToken;
SourceLocation firstSemicolonToken;
SourceLocation secondSemicolonToken;
SourceLocation rparenToken;
diff --git a/src/qml/parser/qqmljsastfwd_p.h b/src/qml/parser/qqmljsastfwd_p.h
index 22cf88919d..196d23a9c4 100644
--- a/src/qml/parser/qqmljsastfwd_p.h
+++ b/src/qml/parser/qqmljsastfwd_p.h
@@ -140,7 +140,6 @@ class IfStatement;
class DoWhileStatement;
class WhileStatement;
class ForStatement;
-class LocalForStatement;
class ForEachStatement;
class ContinueStatement;
class BreakStatement;
diff --git a/src/qml/parser/qqmljsastvisitor_p.h b/src/qml/parser/qqmljsastvisitor_p.h
index 4dfc50d122..5fbdf4adff 100644
--- a/src/qml/parser/qqmljsastvisitor_p.h
+++ b/src/qml/parser/qqmljsastvisitor_p.h
@@ -266,9 +266,6 @@ public:
virtual bool visit(ForStatement *) { return true; }
virtual void endVisit(ForStatement *) {}
- virtual bool visit(LocalForStatement *) { return true; }
- virtual void endVisit(LocalForStatement *) {}
-
virtual bool visit(ForEachStatement *) { return true; }
virtual void endVisit(ForEachStatement *) {}