Commit 73a4f297 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Cleanup MemInitializerAST

parent 1dbdbbef
......@@ -527,10 +527,8 @@ unsigned CtorInitializerAST::firstToken() const
unsigned CtorInitializerAST::lastToken() const
{
for (MemInitializerAST *it = member_initializers; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
if (member_initializers)
return member_initializers->lastToken();
return colon_token + 1;
}
......@@ -697,10 +695,8 @@ unsigned EnumSpecifierAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
for (EnumeratorAST *it = enumerators; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
if (enumerators)
return enumerators->lastToken();
if (lbrace_token)
return lbrace_token + 1;
......
......@@ -686,7 +686,7 @@ class CPLUSPLUS_EXPORT CtorInitializerAST: public AST
{
public:
unsigned colon_token;
MemInitializerAST *member_initializers;
MemInitializerListAST *member_initializers;
public:
virtual CtorInitializerAST *asCtorInitializer() { return this; }
......@@ -862,7 +862,7 @@ public:
unsigned enum_token;
NameAST *name;
unsigned lbrace_token;
EnumeratorAST *enumerators;
EnumeratorListAST *enumerators;
unsigned rbrace_token;
public:
......@@ -881,7 +881,6 @@ public:
unsigned identifier_token;
unsigned equal_token;
ExpressionAST *expression;
EnumeratorAST *next;
public:
virtual EnumeratorAST *asEnumerator() { return this; }
......@@ -1134,7 +1133,6 @@ public:
unsigned lparen_token;
ExpressionAST *expression;
unsigned rparen_token;
MemInitializerAST *next;
public:
virtual MemInitializerAST *asMemInitializer() { return this; }
......
......@@ -220,8 +220,7 @@ void CppCastExpressionAST::accept0(ASTVisitor *visitor)
void CtorInitializerAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
for (MemInitializerAST *it = member_initializers; it; it = it->next)
accept(it, visitor);
accept(member_initializers, visitor);
}
visitor->endVisit(this);
}
......@@ -307,8 +306,7 @@ void EnumSpecifierAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(name, visitor);
for (EnumeratorAST *it = enumerators; it; it = it->next)
accept(it, visitor);
accept(enumerators, visitor);
}
visitor->endVisit(this);
}
......
......@@ -196,6 +196,8 @@ typedef List<DeclarationAST *> DeclarationListAST;
typedef List<StatementAST *> StatementListAST;
typedef List<DeclaratorAST *> DeclaratorListAST;
typedef List<BaseSpecifierAST *> BaseSpecifierListAST;
typedef List<EnumeratorAST *> EnumeratorListAST;
typedef List<MemInitializerAST *> MemInitializerListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
......
......@@ -387,8 +387,8 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
e->setVisibility(semantic()->currentVisibility());
_scope->enterSymbol(e);
_fullySpecifiedType.setType(e);
for (EnumeratorAST *enumerator = ast->enumerators; enumerator;
enumerator = enumerator->next) {
for (EnumeratorListAST *it = ast->enumerators; it; it = it->next) {
EnumeratorAST *enumerator = it->value;
Identifier *id = identifier(enumerator->identifier_token);
if (! id)
continue;
......
......@@ -1308,7 +1308,7 @@ bool Parser::parseEnumSpecifier(SpecifierAST *&node)
ast->name = name;
ast->lbrace_token = consumeToken();
unsigned comma_token = 0;
EnumeratorAST **enumerator_ptr = &ast->enumerators;
EnumeratorListAST **enumerator_ptr = &ast->enumerators;
while (int tk = LA()) {
if (tk == T_RBRACE)
break;
......@@ -1722,7 +1722,7 @@ bool Parser::parseExceptionSpecification(ExceptionSpecificationAST *&node)
return false;
}
bool Parser::parseEnumerator(EnumeratorAST *&node)
bool Parser::parseEnumerator(EnumeratorListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() == T_IDENTIFIER) {
......@@ -1733,7 +1733,9 @@ bool Parser::parseEnumerator(EnumeratorAST *&node)
ast->equal_token = consumeToken();
parseConstantExpression(ast->expression);
}
node = ast;
node = new (_pool) EnumeratorListAST;
node->value = ast;
return true;
}
return false;
......@@ -1820,10 +1822,10 @@ bool Parser::parseInitializer(ExpressionAST *&node, unsigned *equals_token)
return false;
}
bool Parser::parseMemInitializerList(MemInitializerAST *&node)
bool Parser::parseMemInitializerList(MemInitializerListAST *&node)
{
DEBUG_THIS_RULE();
MemInitializerAST **initializer = &node;
MemInitializerListAST **initializer = &node;
if (parseMemInitializer(*initializer)) {
initializer = &(*initializer)->next;
......@@ -1838,7 +1840,7 @@ bool Parser::parseMemInitializerList(MemInitializerAST *&node)
return false;
}
bool Parser::parseMemInitializer(MemInitializerAST *&node)
bool Parser::parseMemInitializer(MemInitializerListAST *&node)
{
DEBUG_THIS_RULE();
NameAST *name = 0;
......@@ -1849,7 +1851,9 @@ bool Parser::parseMemInitializer(MemInitializerAST *&node)
parseExpression(ast->expression);
if (LA() == T_RPAREN)
ast->rparen_token = consumeToken();
node = ast;
node = new (_pool) MemInitializerListAST;
node->value = ast;
return true;
}
return false;
......
......@@ -111,7 +111,7 @@ public:
bool parseDoStatement(StatementAST *&node);
bool parseElaboratedTypeSpecifier(SpecifierAST *&node);
bool parseEnumSpecifier(SpecifierAST *&node);
bool parseEnumerator(EnumeratorAST *&node);
bool parseEnumerator(EnumeratorListAST *&node);
bool parseEqualityExpression(ExpressionAST *&node);
bool parseExceptionDeclaration(ExceptionDeclarationAST *&node);
bool parseExceptionSpecification(ExceptionSpecificationAST *&node);
......@@ -134,8 +134,8 @@ public:
bool parseLinkageSpecification(DeclarationAST *&node);
bool parseLogicalAndExpression(ExpressionAST *&node);
bool parseLogicalOrExpression(ExpressionAST *&node);
bool parseMemInitializer(MemInitializerAST *&node);
bool parseMemInitializerList(MemInitializerAST *&node);
bool parseMemInitializer(MemInitializerListAST *&node);
bool parseMemInitializerList(MemInitializerListAST *&node);
bool parseMemberSpecification(DeclarationAST *&node);
bool parseMultiplicativeExpression(ExpressionAST *&node);
bool parseTemplateId(NameAST *&node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment