forked from qt-creator/qt-creator
Removed StatementListAST
Done with Erik Verbruggen
This commit is contained in:
@@ -401,22 +401,6 @@ unsigned ClassSpecifierAST::lastToken() const
|
||||
return classkey_token + 1;
|
||||
}
|
||||
|
||||
|
||||
unsigned StatementListAST::firstToken() const
|
||||
{
|
||||
return statement->firstToken();
|
||||
}
|
||||
|
||||
unsigned StatementListAST::lastToken() const
|
||||
{
|
||||
for (const StatementListAST *it = this; it; it = it->next) {
|
||||
if (! it->next)
|
||||
return it->statement->lastToken();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned CompoundStatementAST::firstToken() const
|
||||
{
|
||||
return lbrace_token;
|
||||
@@ -429,7 +413,7 @@ unsigned CompoundStatementAST::lastToken() const
|
||||
|
||||
for (StatementListAST *it = statements; it; it = it->next) {
|
||||
if (! it->next)
|
||||
return it->statement->lastToken();
|
||||
return it->value->lastToken();
|
||||
}
|
||||
|
||||
return lbrace_token + 1;
|
||||
|
@@ -607,22 +607,6 @@ protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT StatementListAST: public AST
|
||||
{
|
||||
public:
|
||||
StatementAST *statement;
|
||||
StatementListAST *next;
|
||||
|
||||
public:
|
||||
virtual StatementListAST *asStatementList() { return this; }
|
||||
|
||||
virtual unsigned firstToken() const;
|
||||
virtual unsigned lastToken() const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(ASTVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT CompoundStatementAST: public StatementAST
|
||||
{
|
||||
public:
|
||||
|
@@ -180,14 +180,6 @@ void CaseStatementAST::accept0(ASTVisitor *visitor)
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
void StatementListAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(statement, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
void CompoundStatementAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
|
@@ -171,7 +171,6 @@ public:
|
||||
virtual bool visit(SimpleNameAST *) { return true; }
|
||||
virtual bool visit(SimpleSpecifierAST *) { return true; }
|
||||
virtual bool visit(SizeofExpressionAST *) { return true; }
|
||||
virtual bool visit(StatementListAST *) { return true; }
|
||||
virtual bool visit(StringLiteralAST *) { return true; }
|
||||
virtual bool visit(SwitchStatementAST *) { return true; }
|
||||
virtual bool visit(TemplateArgumentListAST *) { return true; }
|
||||
@@ -305,7 +304,6 @@ public:
|
||||
virtual void endVisit(SimpleNameAST *) { }
|
||||
virtual void endVisit(SimpleSpecifierAST *) { }
|
||||
virtual void endVisit(SizeofExpressionAST *) { }
|
||||
virtual void endVisit(StatementListAST *) { }
|
||||
virtual void endVisit(StringLiteralAST *) { }
|
||||
virtual void endVisit(SwitchStatementAST *) { }
|
||||
virtual void endVisit(TemplateArgumentListAST *) { }
|
||||
|
@@ -178,7 +178,6 @@ class SimpleSpecifierAST;
|
||||
class SizeofExpressionAST;
|
||||
class SpecifierAST;
|
||||
class StatementAST;
|
||||
class StatementListAST;
|
||||
class StringLiteralAST;
|
||||
class SwitchStatementAST;
|
||||
class TemplateArgumentListAST;
|
||||
@@ -202,6 +201,7 @@ class WhileStatementAST;
|
||||
|
||||
typedef List<ExpressionAST *> ExpressionListAST;
|
||||
typedef List<DeclarationAST *> DeclarationListAST;
|
||||
typedef List<StatementAST *> StatementListAST;
|
||||
|
||||
} // end of namespace CPlusPlus
|
||||
|
||||
|
@@ -105,7 +105,7 @@ bool CheckStatement::visit(CompoundStatementAST *ast)
|
||||
_scope->enterSymbol(block);
|
||||
Scope *previousScope = switchScope(block->members());
|
||||
for (StatementListAST *it = ast->statements; it; it = it->next) {
|
||||
semantic()->check(it->statement, _scope);
|
||||
semantic()->check(it->value, _scope);
|
||||
}
|
||||
(void) switchScope(previousScope);
|
||||
return false;
|
||||
|
@@ -2439,7 +2439,7 @@ bool Parser::parseCompoundStatement(StatementAST *&node)
|
||||
skipUntilStatement();
|
||||
} else {
|
||||
*statement_ptr = new (_pool) StatementListAST;
|
||||
(*statement_ptr)->statement = statement;
|
||||
(*statement_ptr)->value = statement;
|
||||
statement_ptr = &(*statement_ptr)->next;
|
||||
}
|
||||
}
|
||||
|
@@ -557,8 +557,8 @@ void tst_AST::normal_array_access()
|
||||
QVERIFY(bodyStatements);
|
||||
QVERIFY(bodyStatements->next);
|
||||
QVERIFY(bodyStatements->next->next);
|
||||
QVERIFY(bodyStatements->next->next->statement);
|
||||
ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression;
|
||||
QVERIFY(bodyStatements->next->next->value);
|
||||
ExpressionAST *expr = bodyStatements->next->next->value->asReturnStatement()->expression;
|
||||
QVERIFY(expr);
|
||||
|
||||
PostfixExpressionAST *postfixExpr = expr->asPostfixExpression();
|
||||
@@ -598,8 +598,8 @@ void tst_AST::array_access_with_nested_expression()
|
||||
QVERIFY(func);
|
||||
|
||||
StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements;
|
||||
QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->statement);
|
||||
ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression;
|
||||
QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->value);
|
||||
ExpressionAST *expr = bodyStatements->next->next->value->asReturnStatement()->expression;
|
||||
QVERIFY(expr);
|
||||
|
||||
CastExpressionAST *castExpr = expr->asCastExpression();
|
||||
@@ -643,10 +643,10 @@ void tst_AST::objc_msg_send_expression()
|
||||
QVERIFY(func);
|
||||
|
||||
StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements;
|
||||
QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->statement);
|
||||
QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->value);
|
||||
|
||||
{// check the NSObject declaration
|
||||
DeclarationStatementAST *firstStatement = bodyStatements->statement->asDeclarationStatement();
|
||||
DeclarationStatementAST *firstStatement = bodyStatements->value->asDeclarationStatement();
|
||||
QVERIFY(firstStatement);
|
||||
DeclarationAST *objDecl = firstStatement->declaration;
|
||||
QVERIFY(objDecl);
|
||||
@@ -692,7 +692,7 @@ void tst_AST::objc_msg_send_expression()
|
||||
}
|
||||
|
||||
{// check the return statement
|
||||
ExpressionAST *expr = bodyStatements->next->statement->asReturnStatement()->expression;
|
||||
ExpressionAST *expr = bodyStatements->next->value->asReturnStatement()->expression;
|
||||
QVERIFY(expr);
|
||||
|
||||
ObjCMessageExpressionAST *msgExpr = expr->asObjCMessageExpression();
|
||||
@@ -729,9 +729,9 @@ void tst_AST::objc_msg_send_expression_without_selector()
|
||||
|
||||
StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements;
|
||||
QVERIFY(bodyStatements && bodyStatements->next);
|
||||
QVERIFY(bodyStatements->next->statement);
|
||||
QVERIFY(bodyStatements->next->statement->asReturnStatement());
|
||||
QVERIFY(!bodyStatements->next->statement->asReturnStatement()->expression);
|
||||
QVERIFY(bodyStatements->next->value);
|
||||
QVERIFY(bodyStatements->next->value->asReturnStatement());
|
||||
QVERIFY(!bodyStatements->next->value->asReturnStatement()->expression);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_AST)
|
||||
|
Reference in New Issue
Block a user