Commit ca34b0ca authored by Erik Verbruggen's avatar Erik Verbruggen

Cleaned the ObjC AST up.

parent afd9fd82
......@@ -1924,14 +1924,14 @@ unsigned IdentifierListAST::lastToken() const
}
unsigned ObjCClassDeclarationAST::firstToken() const
unsigned ObjCClassForwardDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return class_token;
}
unsigned ObjCClassDeclarationAST::lastToken() const
unsigned ObjCClassForwardDeclarationAST::lastToken() const
{
if (semicolon_token)
return semicolon_token + 1;
......@@ -1941,22 +1941,17 @@ unsigned ObjCClassDeclarationAST::lastToken() const
return it->name->lastToken();
}
for (SpecifierAST *it = attributes; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
return class_token + 1;
}
unsigned ObjCProtocolDeclarationAST::firstToken() const
unsigned ObjCProtocolForwardDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return protocol_token;
}
unsigned ObjCProtocolDeclarationAST::lastToken() const
unsigned ObjCProtocolForwardDeclarationAST::lastToken() const
{
if (semicolon_token)
return semicolon_token + 1;
......@@ -1966,69 +1961,52 @@ unsigned ObjCProtocolDeclarationAST::lastToken() const
return it->name->lastToken();
}
for (SpecifierAST *it = attributes; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
return protocol_token + 1;
}
unsigned ObjCClassInterfaceDefinitionAST::firstToken() const
unsigned ObjCClassDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return interface_token;
if (interface_token)
return interface_token;
else
return implementation_token;
}
unsigned ObjCClassInterfaceDefinitionAST::lastToken() const
unsigned ObjCClassDeclarationAST::lastToken() const
{
if (end_token) return end_token + 1;
if (member_declarations) return member_declarations->lastToken();
if (inst_vars_decl) return inst_vars_decl->lastToken();
if (superclass_identifier_token) return superclass_identifier_token + 1;
if (protocol_refs)
return protocol_refs->lastToken();
if (superclass)
return superclass->lastToken();
if (colon_token) return colon_token + 1;
if (rparen_token)
return rparen_token + 1;
if (category_name)
return category_name->lastToken();
if (lparen_token)
return lparen_token + 1;
if (class_name) return class_name->lastToken();
for (SpecifierAST *it = attributes; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
return interface_token + 1;
}
unsigned ObjCCategoryInterfaceDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
if (interface_token)
return interface_token + 1;
else
return interface_token;
return implementation_token + 1;
}
unsigned ObjCCategoryInterfaceDeclarationAST::lastToken() const
{
if (end_token)
return end_token + 1;
if (member_declarations)
return member_declarations->lastToken();
if (rparen_token) return rparen_token + 1;
if (category_identifier_token) return category_identifier_token + 1;
if (lparen_token) return lparen_token + 1;
if (class_identifier_token) return class_identifier_token + 1;
return interface_token + 1;
}
unsigned ObjCProtocolDefinitionAST::firstToken() const
unsigned ObjCProtocolDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return protocol_token;
}
unsigned ObjCProtocolDefinitionAST::lastToken() const
unsigned ObjCProtocolDeclarationAST::lastToken() const
{
if (end_token)
return end_token + 1;
......@@ -2403,60 +2381,6 @@ unsigned ObjCMethodDeclarationAST::lastToken() const
return method_prototype->lastToken();
}
unsigned ObjCClassImplementationAST::firstToken() const
{
return implementation_token;
}
unsigned ObjCClassImplementationAST::lastToken() const
{
if (end_token)
return end_token + 1;
for (DeclarationListAST *it = declarations; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
if (inst_vars_decl)
return inst_vars_decl->lastToken();
if (super_class_identifier)
return super_class_identifier + 1;
if (colon_token)
return colon_token + 1;
if (class_identifier)
return class_identifier + 1;
return implementation_token + 1;
}
unsigned ObjCCategoryImplementationAST::firstToken() const
{
return implementation_token;
}
unsigned ObjCCategoryImplementationAST::lastToken() const
{
if (end_token)
return end_token + 1;
for (DeclarationListAST *it = declarations; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
if (rparen_token)
return rparen_token + 1;
if (category_name_token)
return category_name_token + 1;
if (lparen_token)
return lparen_token + 1;
if (class_identifier)
return class_identifier + 1;
return implementation_token + 1;
}
unsigned ObjCSynthesizedPropertyAST::firstToken() const
{
if (property_identifier)
......
......@@ -197,9 +197,10 @@ public:
virtual WhileStatementAST *asWhileStatement() { return 0; }
virtual IdentifierListAST *asIdentifierList() { return 0; }
virtual ObjCClassForwardDeclarationAST *asObjCClassForwarDeclaration() { return 0; }
virtual ObjCClassDeclarationAST *asObjCClassDeclaration() { return 0; }
virtual ObjCProtocolForwardDeclarationAST *asObjCProtocolForwardDeclaration() { return 0; }
virtual ObjCProtocolDeclarationAST *asObjCProtocolDeclaration() { return 0; }
virtual ObjCProtocolDefinitionAST *asObjCProtocolDefinition() { return 0; }
virtual ObjCProtocolRefsAST *asObjCProtocolRefs() { return 0; }
virtual ObjCMessageArgumentAST *asObjCMessageArgument() { return 0; }
virtual ObjCMessageArgumentListAST *asObjCMessageArgumentList() { return 0; }
......@@ -222,8 +223,6 @@ public:
virtual ObjCMessageArgumentDeclarationListAST *asObjCMessageArgumentDeclarationList() { return 0; }
virtual ObjCMethodPrototypeAST *asObjCMethodPrototype() { return 0; }
virtual ObjCMethodDeclarationAST *asObjCMethodDeclaration() { return 0; }
virtual ObjCClassImplementationAST *asObjCClassImplementation() { return 0; }
virtual ObjCCategoryImplementationAST *asObjCCategoryImplementation() { return 0; }
virtual ObjCSynthesizedPropertyAST *asObjCSynthesizedProperty() { return 0; }
virtual ObjCSynthesizedPropertyListAST *asObjCSynthesizedPropertyList() { return 0; }
virtual ObjCSynthesizedPropertiesDeclarationAST *asObjCSynthesizedPropertiesDeclaration() { return 0; }
......@@ -2474,7 +2473,7 @@ protected:
class CPLUSPLUS_EXPORT IdentifierListAST: public AST
{
public:
SimpleNameAST *name;
NameAST *name;
unsigned comma_token;
IdentifierListAST *next;
......@@ -2491,7 +2490,7 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassDeclarationAST: public DeclarationAST
class CPLUSPLUS_EXPORT ObjCClassForwardDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
......@@ -2503,26 +2502,30 @@ public: // annotations
List<ObjCForwardClassDeclaration *> *symbols;
public:
virtual ObjCClassDeclarationAST *asObjCClassDeclaration()
virtual ObjCClassForwardDeclarationAST *asObjCClassForwardDeclaration()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCClassDeclarationAST *clone(MemoryPool *pool) const;
virtual ObjCClassForwardDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassInterfaceDefinitionAST: public DeclarationAST
class CPLUSPLUS_EXPORT ObjCClassDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned interface_token;
SimpleNameAST *class_name;
unsigned implementation_token;
NameAST *class_name;
unsigned lparen_token;
NameAST *category_name;
unsigned rparen_token;
unsigned colon_token;
unsigned superclass_identifier_token;
NameAST *superclass;
ObjCProtocolRefsAST *protocol_refs;
ObjCInstanceVariablesDeclarationAST *inst_vars_decl;
DeclarationListAST *member_declarations;
......@@ -2532,45 +2535,19 @@ public: // annotations
ObjCClass *symbol;
public:
virtual ObjCClassInterfaceDefinitionAST *asObjCClassInterfaceDefinition()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCClassInterfaceDefinitionAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCCategoryInterfaceDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned interface_token;
unsigned class_identifier_token;
unsigned lparen_token;
unsigned category_identifier_token;
unsigned rparen_token;
ObjCProtocolRefsAST *protocol_refs;
DeclarationListAST *member_declarations;
unsigned end_token;
public:
virtual ObjCCategoryInterfaceDeclarationAST *asObjCCategoryInterfaceDeclaration()
virtual ObjCClassDeclarationAST *asObjCClassDeclaration()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCCategoryInterfaceDeclarationAST *clone(MemoryPool *pool) const;
virtual ObjCClassDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCProtocolDeclarationAST: public DeclarationAST
class CPLUSPLUS_EXPORT ObjCProtocolForwardDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
......@@ -2582,24 +2559,24 @@ public: // annotations
List<ObjCForwardProtocolDeclaration *> *symbols;
public:
virtual ObjCProtocolDeclarationAST *asObjCProtocolDeclaration()
virtual ObjCProtocolForwardDeclarationAST *asObjCProtocolForwardDeclaration()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCProtocolDeclarationAST *clone(MemoryPool *pool) const;
virtual ObjCProtocolForwardDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCProtocolDefinitionAST: public DeclarationAST
class CPLUSPLUS_EXPORT ObjCProtocolDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned protocol_token;
SimpleNameAST *name;
NameAST *name;
ObjCProtocolRefsAST *protocol_refs;
DeclarationListAST *member_declarations;
unsigned end_token;
......@@ -2608,13 +2585,13 @@ public: // annotations
ObjCProtocol *symbol;
public:
virtual ObjCProtocolDefinitionAST *asObjCProtocolDefinition()
virtual ObjCProtocolDeclarationAST *asObjCProtocolDeclaration()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCProtocolDefinitionAST *clone(MemoryPool *pool) const;
virtual ObjCProtocolDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
......@@ -3055,54 +3032,6 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassImplementationAST: public DeclarationAST
{
public:
unsigned implementation_token;
unsigned class_identifier;
unsigned colon_token;
unsigned super_class_identifier;
ObjCInstanceVariablesDeclarationAST *inst_vars_decl;
DeclarationListAST *declarations;
unsigned end_token;
public:
virtual ObjCClassImplementationAST *asObjCClassImplementation()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCClassImplementationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCCategoryImplementationAST: public DeclarationAST
{
public:
unsigned implementation_token;
unsigned class_identifier;
unsigned lparen_token;
unsigned category_name_token;
unsigned rparen_token;
DeclarationListAST *declarations;
unsigned end_token;
public:
virtual ObjCCategoryImplementationAST *asObjCCategoryImplementation()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCCategoryImplementationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCSynthesizedPropertyAST: public AST
{
public:
......
......@@ -1213,11 +1213,11 @@ IdentifierListAST *IdentifierListAST::clone(MemoryPool *pool) const
return ast;
}
ObjCClassDeclarationAST *ObjCClassDeclarationAST::clone(MemoryPool *pool) const
ObjCClassForwardDeclarationAST *ObjCClassForwardDeclarationAST::clone(MemoryPool *pool) const
{
ObjCClassDeclarationAST *ast = new (pool) ObjCClassDeclarationAST;
ObjCClassForwardDeclarationAST *ast = new (pool) ObjCClassForwardDeclarationAST;
// copy DeclarationAST
// copy ObjCClassDeclarationAST
// copy ObjCClassForwardDeclarationAST
if (attributes) ast->attributes = attributes->clone(pool);
ast->class_token = class_token;
if (identifier_list) ast->identifier_list = identifier_list->clone(pool);
......@@ -1225,16 +1225,20 @@ ObjCClassDeclarationAST *ObjCClassDeclarationAST::clone(MemoryPool *pool) const
return ast;
}
ObjCClassInterfaceDefinitionAST *ObjCClassInterfaceDefinitionAST::clone(MemoryPool *pool) const
ObjCClassDeclarationAST *ObjCClassDeclarationAST::clone(MemoryPool *pool) const
{
ObjCClassInterfaceDefinitionAST *ast = new (pool) ObjCClassInterfaceDefinitionAST;
ObjCClassDeclarationAST *ast = new (pool) ObjCClassDeclarationAST;
// copy DeclarationAST
// copy ObjCClassInterfaceDeclarationAST
// copy ObjCClassDeclarationAST
if (attributes) ast->attributes = attributes->clone(pool);
ast->interface_token = interface_token;
ast->implementation_token = implementation_token;
if (class_name) ast->class_name = class_name->clone(pool);
ast->lparen_token = lparen_token;
if (category_name) ast->category_name = category_name->clone(pool);
ast->rparen_token = rparen_token;
ast->colon_token = colon_token;
ast->superclass_identifier_token = superclass_identifier_token;
if (superclass) ast->superclass = superclass->clone(pool);
if (protocol_refs) ast->protocol_refs = protocol_refs->clone(pool);
if (inst_vars_decl) ast->inst_vars_decl = inst_vars_decl->clone(pool);
if (member_declarations) ast->member_declarations = member_declarations->clone(pool);
......@@ -1242,26 +1246,9 @@ ObjCClassInterfaceDefinitionAST *ObjCClassInterfaceDefinitionAST::clone(MemoryPo
return ast;
}
ObjCCategoryInterfaceDeclarationAST *ObjCCategoryInterfaceDeclarationAST::clone(MemoryPool *pool) const
ObjCProtocolForwardDeclarationAST *ObjCProtocolForwardDeclarationAST::clone(MemoryPool *pool) const
{
ObjCCategoryInterfaceDeclarationAST *ast = new (pool) ObjCCategoryInterfaceDeclarationAST;
// copy DeclarationAST
// copy ObjCCategoryInterfaceDeclarationAST
if (attributes) ast->attributes = attributes->clone(pool);
ast->interface_token = interface_token;
ast->class_identifier_token = class_identifier_token;
if (protocol_refs) ast->protocol_refs = protocol_refs->clone(pool);
ast->lparen_token = lparen_token;
ast->category_identifier_token = category_identifier_token;
ast->rparen_token = rparen_token;
if (member_declarations) ast->member_declarations = member_declarations->clone(pool);
ast->end_token = end_token;
return ast;
}
ObjCProtocolDeclarationAST *ObjCProtocolDeclarationAST::clone(MemoryPool *pool) const
{
ObjCProtocolDeclarationAST *ast = new (pool) ObjCProtocolDeclarationAST;
ObjCProtocolForwardDeclarationAST *ast = new (pool) ObjCProtocolForwardDeclarationAST;
if (attributes) ast->attributes = attributes->clone(pool);
ast->protocol_token = protocol_token;
if (identifier_list) ast->identifier_list = identifier_list;
......@@ -1269,9 +1256,9 @@ ObjCProtocolDeclarationAST *ObjCProtocolDeclarationAST::clone(MemoryPool *pool)
return ast;
}
ObjCProtocolDefinitionAST *ObjCProtocolDefinitionAST::clone(MemoryPool *pool) const
ObjCProtocolDeclarationAST *ObjCProtocolDeclarationAST::clone(MemoryPool *pool) const
{
ObjCProtocolDefinitionAST *ast = new (pool) ObjCProtocolDefinitionAST;
ObjCProtocolDeclarationAST *ast = new (pool) ObjCProtocolDeclarationAST;
if (attributes) ast->attributes = attributes->clone(pool);
ast->protocol_token = protocol_token;
if (name) ast->name = name->clone(pool);
......@@ -1466,32 +1453,6 @@ ObjCMethodDeclarationAST *ObjCMethodDeclarationAST::clone(MemoryPool *pool) cons
return ast;
}
ObjCClassImplementationAST *ObjCClassImplementationAST::clone(MemoryPool *pool) const
{
ObjCClassImplementationAST *ast = new (pool) ObjCClassImplementationAST;
ast->implementation_token = implementation_token;
ast->class_identifier = class_identifier;
ast->colon_token = colon_token;
ast->super_class_identifier = super_class_identifier;
if (inst_vars_decl) ast->inst_vars_decl = inst_vars_decl->clone(pool);
if (declarations) ast->declarations = declarations->clone(pool);
ast->end_token = end_token;
return ast;
}
ObjCCategoryImplementationAST *ObjCCategoryImplementationAST::clone(MemoryPool *pool) const
{
ObjCCategoryImplementationAST *ast = new (pool) ObjCCategoryImplementationAST;
ast->implementation_token = implementation_token;
ast->class_identifier = class_identifier;
ast->lparen_token = lparen_token;
ast->category_name_token = category_name_token;
ast->rparen_token = rparen_token;
if (declarations) ast->declarations = declarations->clone(pool);
ast->end_token = end_token;
return ast;
}
ObjCSynthesizedPropertyAST *ObjCSynthesizedPropertyAST::clone(MemoryPool *pool) const
{
ObjCSynthesizedPropertyAST *ast = new (pool) ObjCSynthesizedPropertyAST;
......
......@@ -1127,10 +1127,10 @@ void IdentifierListAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCClassForwardDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCClassDeclarationAST
// visit ObjCClassForwardDeclarationAST
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
for (IdentifierListAST *it = identifier_list; it; it = it->next)
......@@ -1140,13 +1140,15 @@ void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void ObjCClassInterfaceDefinitionAST::accept0(ASTVisitor *visitor)
void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCClassInterfaceDefinitionAST
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
accept(class_name, visitor);
accept(category_name, visitor);
accept(superclass, visitor);
accept(protocol_refs, visitor);
accept(inst_vars_decl, visitor);
for (DeclarationListAST *it = member_declarations; it; it = it->next)
......@@ -1156,21 +1158,7 @@ void ObjCClassInterfaceDefinitionAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void ObjCCategoryInterfaceDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCCategoryInterfaceDeclarationAST
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
accept(protocol_refs, visitor);
for (DeclarationListAST *it = member_declarations; it; it = it->next)
accept(it, visitor);
// visit DeclarationAST
}
visitor->endVisit(this);
}
void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCProtocolForwardDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCProtocolDeclarationAST
......@@ -1183,10 +1171,10 @@ void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void ObjCProtocolDefinitionAST::accept0(ASTVisitor *visitor)
void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCProtocolDefinitionAST
// visit ObjCProtocolDeclarationAST
for (SpecifierAST *it = attributes; it; it = it->next)
accept(it, visitor);
accept(name, visitor);
......@@ -1412,29 +1400,6 @@ void ObjCMethodDeclarationAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void ObjCClassImplementationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCClassImplementationAST
accept(inst_vars_decl, visitor);
for (DeclarationListAST *it = declarations; it; it = it->next)
accept(it, visitor);
// visit DeclarationAST
}
visitor->endVisit(this);
}
void ObjCCategoryImplementationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
// visit ObjCCategoryImplementationAST
for (DeclarationListAST *it = declarations; it; it = it->next)
accept(it, visitor);
// visit DeclarationAST
}
visitor->endVisit(this);
}
void ObjCSynthesizedPropertyAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
......
......@@ -198,10 +198,9 @@ public:
// ObjC++
virtual bool visit(IdentifierListAST *) { return true; }
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
virtual bool visit(ObjCClassInterfaceDefinitionAST *) { return true; }