Commit 496ff15d authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Removed ObjCIdentifierListAST

Done with Erik Verbruggen
parent 8efb73f5
......@@ -498,8 +498,8 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast)
bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
{
for (IdentifierListAST *iter = ast->identifier_list; iter; iter = iter->next) {
if (NameAST *nameAST = iter->name) {
for (ObjCIdentifierListAST *iter = ast->identifier_list; iter; iter = iter->next) {
if (NameAST *nameAST = iter->value) {
bool resolvedProtocolName = false;
if (Name *name = nameAST->name) {
......
......@@ -1816,26 +1816,6 @@ unsigned WhileStatementAST::lastToken() const
}
// ObjC++
unsigned IdentifierListAST::firstToken() const
{
if (name)
return name->firstToken();
// ### assert?
return 0;
}
unsigned IdentifierListAST::lastToken() const
{
for (const IdentifierListAST *it = this; it; it = it->next) {
if (! it->next && it->name) {
return it->name->lastToken();
}
}
// ### assert?
return 0;
}
unsigned ObjCClassForwardDeclarationAST::firstToken() const
{
if (attributes)
......@@ -1848,9 +1828,9 @@ unsigned ObjCClassForwardDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
for (IdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->name)
return it->name->lastToken();
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->value)
return it->value->lastToken();
}
return class_token + 1;
......@@ -1868,9 +1848,9 @@ unsigned ObjCProtocolForwardDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
for (IdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->name)
return it->name->lastToken();
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->value)
return it->value->lastToken();
}
return protocol_token + 1;
......@@ -1949,9 +1929,9 @@ unsigned ObjCProtocolRefsAST::lastToken() const
{
if (greater_token) return greater_token + 1;
for (IdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->name)
return it->name->lastToken();
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) {
if (! it->next && it->value)
return it->value->lastToken();
}
return less_token + 1;
......
......@@ -164,7 +164,7 @@ public:
virtual FunctionDeclaratorAST *asFunctionDeclarator() { return 0; }
virtual FunctionDefinitionAST *asFunctionDefinition() { return 0; }
virtual GotoStatementAST *asGotoStatement() { return 0; }
virtual IdentifierListAST *asIdentifierList() { return 0; }
virtual ObjCIdentifierListAST *asIdentifierList() { return 0; }
virtual IfStatementAST *asIfStatement() { return 0; }
virtual LabeledStatementAST *asLabeledStatement() { return 0; }
virtual LinkageBodyAST *asLinkageBody() { return 0; }
......@@ -2084,30 +2084,12 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
// ObjC++
class CPLUSPLUS_EXPORT IdentifierListAST: public AST
{
public:
NameAST *name;
IdentifierListAST *next;
public:
virtual IdentifierListAST *asIdentifierList() { return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassForwardDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned class_token;
IdentifierListAST *identifier_list;
ObjCIdentifierListAST *identifier_list;
unsigned semicolon_token;
public: // annotations
......@@ -2158,7 +2140,7 @@ class CPLUSPLUS_EXPORT ObjCProtocolForwardDeclarationAST: public DeclarationAST
public:
SpecifierAST *attributes;
unsigned protocol_token;
IdentifierListAST *identifier_list;
ObjCIdentifierListAST *identifier_list;
unsigned semicolon_token;
public: // annotations
......@@ -2201,7 +2183,7 @@ class CPLUSPLUS_EXPORT ObjCProtocolRefsAST: public AST
{
public:
unsigned less_token;
IdentifierListAST *identifier_list;
ObjCIdentifierListAST *identifier_list;
unsigned greater_token;
public:
......@@ -2621,7 +2603,7 @@ class CPLUSPLUS_EXPORT ObjCDynamicPropertiesDeclarationAST: public DeclarationAS
{
public:
unsigned dynamic_token;
IdentifierListAST *property_identifiers;
ObjCIdentifierListAST *property_identifiers;
unsigned semicolon_token;
public:
......
......@@ -890,20 +890,12 @@ void WhileStatementAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void IdentifierListAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(name, visitor);
}
visitor->endVisit(this);
}
void ObjCClassForwardDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
for (IdentifierListAST *it = identifier_list; it; it = it->next)
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
accept(it, visitor);
}
visitor->endVisit(this);
......@@ -930,7 +922,7 @@ void ObjCProtocolForwardDeclarationAST::accept0(ASTVisitor *visitor)
if (visitor->visit(this)) {
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
for (IdentifierListAST *it = identifier_list; it; it = it->next)
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
accept(it, visitor);
}
visitor->endVisit(this);
......@@ -952,7 +944,7 @@ void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCProtocolRefsAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
for (IdentifierListAST *it = identifier_list; it; it = it->next)
for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
accept(it, visitor);
}
visitor->endVisit(this);
......@@ -1158,7 +1150,7 @@ void ObjCSynthesizedPropertiesDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCDynamicPropertiesDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
for (IdentifierListAST *it = property_identifiers; it; it = it->next)
for (ObjCIdentifierListAST *it = property_identifiers; it; it = it->next)
accept(it, visitor);
}
visitor->endVisit(this);
......
......@@ -192,7 +192,7 @@ public:
virtual bool visit(QtMethodAST *) { return true; }
// ObjC++
virtual bool visit(IdentifierListAST *) { return true; }
virtual bool visit(ObjCIdentifierListAST *) { return true; }
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
virtual bool visit(ObjCClassForwardDeclarationAST *) { return true; }
virtual bool visit(ObjCProtocolDeclarationAST *) { return true; }
......@@ -323,7 +323,7 @@ public:
virtual void endVisit(QtMethodAST *) { }
// ObjC++
virtual void endVisit(IdentifierListAST *) { }
virtual void endVisit(ObjCIdentifierListAST *) { }
virtual void endVisit(ObjCClassDeclarationAST *) { }
virtual void endVisit(ObjCClassForwardDeclarationAST *) { }
virtual void endVisit(ObjCProtocolDeclarationAST *) { }
......
......@@ -104,7 +104,6 @@ class ForeachStatementAST;
class FunctionDeclaratorAST;
class FunctionDefinitionAST;
class GotoStatementAST;
class IdentifierListAST;
class IfStatementAST;
class LabeledStatementAST;
class LinkageBodyAST;
......@@ -201,6 +200,8 @@ typedef List<ExpressionAST *> ExpressionListAST;
typedef List<DeclarationAST *> DeclarationListAST;
typedef List<StatementAST *> StatementListAST;
typedef List<DeclaratorAST *> DeclaratorListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef ExpressionListAST TemplateArgumentListAST;
} // end of namespace CPlusPlus
......
......@@ -501,14 +501,14 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
const unsigned sourceLocation = ast->firstToken();
List<ObjCForwardProtocolDeclaration *> **symbolIter = &ast->symbols;
for (IdentifierListAST *it = ast->identifier_list; it; it = it->next) {
for (ObjCIdentifierListAST *it = ast->identifier_list; it; it = it->next) {
unsigned declarationLocation;
if (it->name)
declarationLocation = it->name->firstToken();
if (it->value)
declarationLocation = it->value->firstToken();
else
declarationLocation = sourceLocation;
Name *protocolName = semantic()->check(it->name, _scope);
Name *protocolName = semantic()->check(it->value, _scope);
ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName);
fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset);
......@@ -537,8 +537,8 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
protocol->setEndOffset(tokenAt(ast->lastToken()).offset);
if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (IdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->name;
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value;
Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
protocol->addProtocol(baseProtocol);
......@@ -562,14 +562,14 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
const unsigned sourceLocation = ast->firstToken();
List<ObjCForwardClassDeclaration *> **symbolIter = &ast->symbols;
for (IdentifierListAST *it = ast->identifier_list; it; it = it->next) {
for (ObjCIdentifierListAST *it = ast->identifier_list; it; it = it->next) {
unsigned declarationLocation;
if (it->name)
declarationLocation = it->name->firstToken();
if (it->value)
declarationLocation = it->value->firstToken();
else
declarationLocation = sourceLocation;
Name *className = semantic()->check(it->name, _scope);
Name *className = semantic()->check(it->value, _scope);
ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className);
fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset);
......@@ -612,8 +612,8 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
}
if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (IdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->name;
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value;
Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
klass->addProtocol(baseProtocol);
......
......@@ -4297,20 +4297,20 @@ bool Parser::parseObjCClassForwardDeclaration(DeclarationAST *&node)
unsigned identifier_token = 0;
match(T_IDENTIFIER, &identifier_token);
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list = new (_pool) ObjCIdentifierListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
ast->identifier_list->value = name;
ObjCIdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
consumeToken(); // consume T_COMMA
match(T_IDENTIFIER, &identifier_token);
*nextId = new (_pool) IdentifierListAST;
*nextId = new (_pool) ObjCIdentifierListAST;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
(*nextId)->value = name;
nextId = &((*nextId)->next);
}
......@@ -4447,20 +4447,20 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
ObjCProtocolForwardDeclarationAST *ast = new (_pool) ObjCProtocolForwardDeclarationAST;
ast->attributes = attributes;
ast->protocol_token = protocol_token;
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list = new (_pool) ObjCIdentifierListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
ast->identifier_list->value = name;
ObjCIdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
consumeToken(); // consume T_COMMA
match(T_IDENTIFIER, &identifier_token);
*nextId = new (_pool) IdentifierListAST;
*nextId = new (_pool) ObjCIdentifierListAST;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
(*nextId)->value = name;
nextId = &((*nextId)->next);
}
......@@ -4611,20 +4611,20 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node)
case T_AT_DYNAMIC: {
ObjCDynamicPropertiesDeclarationAST *ast = new (_pool) ObjCDynamicPropertiesDeclarationAST;
ast->dynamic_token = consumeToken();
ast->property_identifiers = new (_pool) IdentifierListAST;
ast->property_identifiers = new (_pool) ObjCIdentifierListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(name->identifier_token));
ast->property_identifiers->name = name;
ast->property_identifiers->value = name;
IdentifierListAST *last = ast->property_identifiers;
ObjCIdentifierListAST *last = ast->property_identifiers;
while (LA() == T_COMMA) {
consumeToken(); // consume T_COMMA
last->next = new (_pool) IdentifierListAST;
last->next = new (_pool) ObjCIdentifierListAST;
last = last->next;
name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &name->identifier_token);
last->name = name;
last->value = name;
}
match(T_SEMICOLON, &(ast->semicolon_token));
......@@ -4696,20 +4696,20 @@ bool Parser::parseObjCProtocolRefs(ObjCProtocolRefsAST *&node)
unsigned identifier_token = 0;
match(T_IDENTIFIER, &identifier_token);
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list = new (_pool) ObjCIdentifierListAST;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
ast->identifier_list->value = name;
ObjCIdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
consumeToken(); // consume T_COMMA
match(T_IDENTIFIER, &identifier_token);
*nextId = new (_pool) IdentifierListAST;
*nextId = new (_pool) ObjCIdentifierListAST;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
(*nextId)->value = name;
nextId = &((*nextId)->next);
}
......
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