Cleaned the ObjC AST up.

This commit is contained in:
Erik Verbruggen
2009-08-05 17:14:08 +02:00
parent afd9fd824d
commit ca34b0ca1c
15 changed files with 207 additions and 476 deletions

View File

@@ -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,12 +1941,62 @@ 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 ObjCProtocolForwardDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return protocol_token;
}
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();
}
return class_token + 1;
return protocol_token + 1;
}
unsigned ObjCClassDeclarationAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
if (interface_token)
return interface_token;
else
return implementation_token;
}
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 (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();
if (interface_token)
return interface_token + 1;
else
return implementation_token + 1;
}
unsigned ObjCProtocolDeclarationAST::firstToken() const
@@ -1957,78 +2007,6 @@ unsigned ObjCProtocolDeclarationAST::firstToken() const
}
unsigned ObjCProtocolDeclarationAST::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 (SpecifierAST *it = attributes; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
return protocol_token + 1;
}
unsigned ObjCClassInterfaceDefinitionAST::firstToken() const
{
if (attributes)
return attributes->firstToken();
return interface_token;
}
unsigned ObjCClassInterfaceDefinitionAST::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 (colon_token) return colon_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();
else
return interface_token;
}
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
{
if (attributes)
return attributes->firstToken();
return protocol_token;
}
unsigned ObjCProtocolDefinitionAST::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)

View File

@@ -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;
@@ -2502,6 +2501,39 @@ public:
public: // annotations
List<ObjCForwardClassDeclaration *> *symbols;
public:
virtual ObjCClassForwardDeclarationAST *asObjCClassForwardDeclaration()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCClassForwardDeclarationAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassDeclarationAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned interface_token;
unsigned implementation_token;
NameAST *class_name;
unsigned lparen_token;
NameAST *category_name;
unsigned rparen_token;
unsigned colon_token;
NameAST *superclass;
ObjCProtocolRefsAST *protocol_refs;
ObjCInstanceVariablesDeclarationAST *inst_vars_decl;
DeclarationListAST *member_declarations;
unsigned end_token;
public: // annotations
ObjCClass *symbol;
public:
virtual ObjCClassDeclarationAST *asObjCClassDeclaration()
{ return this; }
@@ -2515,62 +2547,7 @@ protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT ObjCClassInterfaceDefinitionAST: public DeclarationAST
{
public:
SpecifierAST *attributes;
unsigned interface_token;
SimpleNameAST *class_name;
unsigned colon_token;
unsigned superclass_identifier_token;
ObjCProtocolRefsAST *protocol_refs;
ObjCInstanceVariablesDeclarationAST *inst_vars_decl;
DeclarationListAST *member_declarations;
unsigned end_token;
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()
{ return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
virtual ObjCCategoryInterfaceDeclarationAST *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:

View File

@@ -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;

View File

@@ -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)) {

View File

@@ -198,10 +198,9 @@ public:
// ObjC++
virtual bool visit(IdentifierListAST *) { return true; }
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
virtual bool visit(ObjCClassInterfaceDefinitionAST *) { return true; }
virtual bool visit(ObjCCategoryInterfaceDeclarationAST *) { return true; }
virtual bool visit(ObjCClassForwardDeclarationAST *) { return true; }
virtual bool visit(ObjCProtocolDeclarationAST *) { return true; }
virtual bool visit(ObjCProtocolDefinitionAST *) { return true; }
virtual bool visit(ObjCProtocolForwardDeclarationAST *) { return true; }
virtual bool visit(ObjCProtocolRefsAST *) { return true; }
virtual bool visit(ObjCMessageExpressionAST *) { return true; }
virtual bool visit(ObjCMessageArgumentListAST *) { return true; }
@@ -223,8 +222,6 @@ public:
virtual bool visit(ObjCMethodDeclarationAST *) { return true; }
virtual bool visit(ObjCMessageArgumentDeclarationListAST *) { return true; }
virtual bool visit(ObjCMessageArgumentDeclarationAST *) { return true; }
virtual bool visit(ObjCClassImplementationAST *) { return true; }
virtual bool visit(ObjCCategoryImplementationAST *) { return true; }
virtual bool visit(ObjCSynthesizedPropertyAST *) { return true; }
virtual bool visit(ObjCSynthesizedPropertyListAST *) { return true; }
virtual bool visit(ObjCSynthesizedPropertiesDeclarationAST *) { return true; }
@@ -339,10 +336,9 @@ public:
// ObjC++
virtual void endVisit(IdentifierListAST *) { }
virtual void endVisit(ObjCClassDeclarationAST *) { }
virtual void endVisit(ObjCClassInterfaceDefinitionAST *) { }
virtual void endVisit(ObjCCategoryInterfaceDeclarationAST *) { }
virtual void endVisit(ObjCClassForwardDeclarationAST *) { }
virtual void endVisit(ObjCProtocolDeclarationAST *) { }
virtual void endVisit(ObjCProtocolDefinitionAST *) { }
virtual void endVisit(ObjCProtocolForwardDeclarationAST *) { }
virtual void endVisit(ObjCProtocolRefsAST *) { }
virtual void endVisit(ObjCMessageExpressionAST *) { }
virtual void endVisit(ObjCMessageArgumentListAST *) { }
@@ -364,8 +360,6 @@ public:
virtual void endVisit(ObjCMethodDeclarationAST *) { }
virtual void endVisit(ObjCMessageArgumentDeclarationListAST *) { }
virtual void endVisit(ObjCMessageArgumentDeclarationAST *) { }
virtual void endVisit(ObjCClassImplementationAST *) { }
virtual void endVisit(ObjCCategoryImplementationAST *) { }
virtual void endVisit(ObjCSynthesizedPropertyAST *) { }
virtual void endVisit(ObjCSynthesizedPropertyListAST *) { }
virtual void endVisit(ObjCSynthesizedPropertiesDeclarationAST *) { }

View File

@@ -170,11 +170,10 @@ class QtMethodAST;
// ObjC++
class IdentifierListAST;
class ObjCClassForwardDeclarationAST;
class ObjCClassDeclarationAST;
class ObjCProtocolForwardDeclarationAST;
class ObjCProtocolDeclarationAST;
class ObjCProtocolDefinitionAST;
class ObjCClassInterfaceDefinitionAST;
class ObjCCategoryInterfaceDeclarationAST;
class ObjCProtocolRefsAST;
class ObjCMessageExpressionAST;
class ObjCMessageArgumentListAST;
@@ -197,8 +196,6 @@ class ObjCMethodPrototypeAST;
class ObjCMethodDeclarationAST;
class ObjCMessageArgumentDeclarationListAST;
class ObjCMessageArgumentDeclarationAST;
class ObjCCategoryImplementationAST;
class ObjCClassImplementationAST;
class ObjCSynthesizedPropertyAST;
class ObjCSynthesizedPropertyListAST;
class ObjCSynthesizedPropertiesDeclarationAST;

View File

@@ -464,7 +464,7 @@ bool CheckDeclaration::visit(UsingDirectiveAST *ast)
return false;
}
bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
{
const unsigned sourceLocation = ast->firstToken();
@@ -491,7 +491,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
return false;
}
bool CheckDeclaration::visit(ObjCProtocolDefinitionAST *ast)
bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
{
unsigned sourceLocation;
if (ast->name)
@@ -511,7 +511,7 @@ bool CheckDeclaration::visit(ObjCProtocolDefinitionAST *ast)
return false;
}
bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
{
const unsigned sourceLocation = ast->firstToken();
@@ -538,7 +538,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
return false;
}
bool CheckDeclaration::visit(ObjCClassInterfaceDefinitionAST *ast)
bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
{
unsigned sourceLocation;
if (ast->class_name)
@@ -552,7 +552,7 @@ bool CheckDeclaration::visit(ObjCClassInterfaceDefinitionAST *ast)
klass->setEndOffset(tokenAt(ast->lastToken()).offset);
ast->symbol = klass;
// TODO: walk super-class, and protocols (EV)
// TODO: walk category name, super-class, and protocols (EV)
_scope->enterSymbol(klass);
int previousObjCVisibility = semantic()->switchObjCVisibility(Function::Protected);
@@ -563,6 +563,8 @@ bool CheckDeclaration::visit(ObjCClassInterfaceDefinitionAST *ast)
}
}
(void) semantic()->switchObjCVisibility(Function::Public);
for (DeclarationListAST *it = ast->member_declarations; it; it = it->next) {
semantic()->check(it->declaration, klass->members());
}

View File

@@ -92,9 +92,9 @@ protected:
virtual bool visit(UsingDirectiveAST *ast);
virtual bool visit(ObjCProtocolDeclarationAST *ast);
virtual bool visit(ObjCProtocolDefinitionAST *ast);
virtual bool visit(ObjCProtocolForwardDeclarationAST *ast);
virtual bool visit(ObjCClassDeclarationAST *ast);
virtual bool visit(ObjCClassInterfaceDefinitionAST *ast);
virtual bool visit(ObjCClassForwardDeclarationAST *ast);
virtual bool visit(ObjCMethodDeclarationAST *ast);
virtual bool visit(ObjCVisibilityDeclarationAST *ast);

View File

@@ -414,7 +414,7 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
// ObjcC++
case T_AT_CLASS:
return parseObjCClassDeclaration(node);
return parseObjCClassForwardDeclaration(node);
case T_AT_INTERFACE:
return parseObjCInterface(node);
@@ -3971,20 +3971,21 @@ bool Parser::lookAtObjCSelector() const
// objc-class-declaraton ::= T_AT_CLASS (T_IDENTIFIER @ T_COMMA) T_SEMICOLON
//
bool Parser::parseObjCClassDeclaration(DeclarationAST *&node)
bool Parser::parseObjCClassForwardDeclaration(DeclarationAST *&node)
{
if (LA() != T_AT_CLASS)
return false;
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
ObjCClassForwardDeclarationAST *ast = new (_pool) ObjCClassForwardDeclarationAST;
ast->class_token = consumeToken();
unsigned identifier_token = 0;
match(T_IDENTIFIER, &identifier_token);
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list->name = new (_pool) SimpleNameAST;
ast->identifier_list->name->identifier_token = identifier_token;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
@@ -3993,8 +3994,9 @@ bool Parser::parseObjCClassDeclaration(DeclarationAST *&node)
*nextId = new (_pool) IdentifierListAST;
(*nextId)->comma_token = comma_token;
(*nextId)->name = new (_pool) SimpleNameAST;
(*nextId)->name->identifier_token = identifier_token;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
nextId = &((*nextId)->next);
}
@@ -4041,14 +4043,19 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
_translationUnit->error(attributes->firstToken(),
"invalid attributes for category interface declaration");
ObjCCategoryInterfaceDeclarationAST *ast = new (_pool) ObjCCategoryInterfaceDeclarationAST;
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
ast->attributes = attributes;
ast->interface_token = objc_interface_token;
ast->class_identifier_token = identifier_token;
SimpleNameAST *class_name = new (_pool) SimpleNameAST;
class_name->identifier_token= identifier_token;
ast->class_name = class_name;
match(T_LPAREN, &(ast->lparen_token));
if (LA() == T_IDENTIFIER)
ast->category_identifier_token = consumeToken();
if (LA() == T_IDENTIFIER) {
SimpleNameAST *category_name = new (_pool) SimpleNameAST;
category_name->identifier_token = consumeToken();
ast->category_name = category_name;
}
match(T_RPAREN, &(ast->rparen_token));
@@ -4068,15 +4075,18 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
return true;
} else {
// a class interface declaration
ObjCClassInterfaceDefinitionAST *ast = new (_pool) ObjCClassInterfaceDefinitionAST;
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
ast->attributes = attributes;
ast->interface_token = objc_interface_token;
ast->class_name = new (_pool) SimpleNameAST;
ast->class_name->identifier_token = identifier_token;
SimpleNameAST* class_name = new (_pool) SimpleNameAST;
class_name->identifier_token = identifier_token;
ast->class_name = class_name;
if (LA() == T_COLON) {
ast->colon_token = consumeToken();
match(T_IDENTIFIER, &(ast->superclass_identifier_token));
SimpleNameAST *superclass = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(superclass->identifier_token));
ast->superclass = superclass;
}
parseObjCProtocolRefs(ast->protocol_refs);
@@ -4118,12 +4128,13 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
if (LA() == T_COMMA || LA() == T_SEMICOLON) {
// a protocol forward declaration
ObjCProtocolDeclarationAST *ast = new (_pool) ObjCProtocolDeclarationAST;
ObjCProtocolForwardDeclarationAST *ast = new (_pool) ObjCProtocolForwardDeclarationAST;
ast->attributes = attributes;
ast->protocol_token = protocol_token;
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list->name = new (_pool) SimpleNameAST;
ast->identifier_list->name->identifier_token = identifier_token;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
@@ -4132,8 +4143,9 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
*nextId = new (_pool) IdentifierListAST;
(*nextId)->comma_token = comma_token;
(*nextId)->name = new (_pool) SimpleNameAST;
(*nextId)->name->identifier_token = identifier_token;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
nextId = &((*nextId)->next);
}
@@ -4142,11 +4154,12 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
return true;
} else {
// a protocol definition
ObjCProtocolDefinitionAST *ast = new (_pool) ObjCProtocolDefinitionAST;
ObjCProtocolDeclarationAST *ast = new (_pool) ObjCProtocolDeclarationAST;
ast->attributes = attributes;
ast->protocol_token = protocol_token;
ast->name = new (_pool) SimpleNameAST;
ast->name->identifier_token = identifier_token;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->name = name;
parseObjCProtocolRefs(ast->protocol_refs);
@@ -4180,31 +4193,39 @@ bool Parser::parseObjCImplementation(DeclarationAST *&node)
if (LA() == T_LPAREN) {
// a category implementation
ObjCCategoryImplementationAST *ast = new (_pool) ObjCCategoryImplementationAST;
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
ast->implementation_token = implementation_token;
ast->class_identifier = identifier_token;
SimpleNameAST *class_name = new (_pool) SimpleNameAST;
class_name->identifier_token = identifier_token;
ast->class_name = class_name;
match(T_LPAREN, &(ast->lparen_token));
match(T_IDENTIFIER, &(ast->category_name_token));
SimpleNameAST *category_name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(category_name->identifier_token));
ast->category_name = category_name;
match(T_RPAREN, &(ast->rparen_token));
parseObjCMethodDefinitionList(ast->declarations);
parseObjCMethodDefinitionList(ast->member_declarations);
match(T_AT_END, &(ast->end_token));
node = ast;
} else {
// a class implementation
ObjCClassImplementationAST *ast = new (_pool) ObjCClassImplementationAST;
ObjCClassDeclarationAST *ast = new (_pool) ObjCClassDeclarationAST;
ast->implementation_token = implementation_token;
ast->class_identifier = identifier_token;
SimpleNameAST *class_name = new (_pool) SimpleNameAST;
class_name->identifier_token = identifier_token;
ast->class_name = class_name;
if (LA() == T_COLON) {
ast->colon_token = consumeToken();
match(T_IDENTIFIER, &(ast->super_class_identifier));
SimpleNameAST *superclass = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(superclass->identifier_token));
ast->superclass = superclass;
}
parseObjClassInstanceVariables(ast->inst_vars_decl);
parseObjCMethodDefinitionList(ast->declarations);
parseObjCMethodDefinitionList(ast->member_declarations);
match(T_AT_END, &(ast->end_token));
node = ast;
@@ -4272,16 +4293,18 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node)
ObjCDynamicPropertiesDeclarationAST *ast = new (_pool) ObjCDynamicPropertiesDeclarationAST;
ast->dynamic_token = consumeToken();
ast->property_identifiers = new (_pool) IdentifierListAST;
ast->property_identifiers->name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(ast->property_identifiers->name->identifier_token));
SimpleNameAST *name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(name->identifier_token));
ast->property_identifiers->name = name;
IdentifierListAST *last = ast->property_identifiers;
while (LA() == T_COMMA) {
last->comma_token = consumeToken();
last->next = new (_pool) IdentifierListAST;
last = last->next;
last->name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(last->name->identifier_token));
name = new (_pool) SimpleNameAST;
match(T_IDENTIFIER, &(name->identifier_token));
last->name = name;
}
match(T_SEMICOLON, &(ast->semicolon_token));
@@ -4350,8 +4373,9 @@ bool Parser::parseObjCProtocolRefs(ObjCProtocolRefsAST *&node)
unsigned identifier_token = 0;
match(T_IDENTIFIER, &identifier_token);
ast->identifier_list = new (_pool) IdentifierListAST;
ast->identifier_list->name = new (_pool) SimpleNameAST;
ast->identifier_list->name->identifier_token = identifier_token;
SimpleNameAST *name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
ast->identifier_list->name = name;
IdentifierListAST **nextId = &(ast->identifier_list->next);
while (LA() == T_COMMA) {
@@ -4360,8 +4384,9 @@ bool Parser::parseObjCProtocolRefs(ObjCProtocolRefsAST *&node)
*nextId = new (_pool) IdentifierListAST;
(*nextId)->comma_token = comma_token;
(*nextId)->name = new (_pool) SimpleNameAST;
(*nextId)->name->identifier_token = identifier_token;
name = new (_pool) SimpleNameAST;
name->identifier_token = identifier_token;
(*nextId)->name = name;
nextId = &((*nextId)->next);
}

View File

@@ -213,7 +213,7 @@ public:
// ObjC++
bool parseObjCExpression(ExpressionAST *&node);
bool parseObjCClassDeclaration(DeclarationAST *&node);
bool parseObjCClassForwardDeclaration(DeclarationAST *&node);
bool parseObjCInterface(DeclarationAST *&node,
SpecifierAST *attributes = 0);
bool parseObjCProtocol(DeclarationAST *&node,

View File

@@ -636,27 +636,11 @@ ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration()
{}
FullySpecifiedType ObjCForwardClassDeclaration::type() const
{ return FullySpecifiedType(const_cast<ObjCForwardClassDeclaration *>(this)); }
bool ObjCForwardClassDeclaration::isEqualTo(const Type *other) const
{
if (const ObjCForwardClassDeclaration *otherForward = other->asObjCForwardClassDeclarationType()) {
if (name() == otherForward->name())
return true;
else if (name() && otherForward->name())
return name()->isEqualTo(otherForward->name());
return false;
}
return false;
}
{ return FullySpecifiedType(); }
void ObjCForwardClassDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
void ObjCForwardClassDeclaration::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name):
Symbol(translationUnit, sourceLocation, name)
{
@@ -666,25 +650,9 @@ ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration()
{}
FullySpecifiedType ObjCForwardProtocolDeclaration::type() const
{ return FullySpecifiedType(const_cast<ObjCForwardProtocolDeclaration *>(this)); }
bool ObjCForwardProtocolDeclaration::isEqualTo(const Type *other) const
{
if (const ObjCForwardProtocolDeclaration *otherForward = other->asObjCForwardProtocolDeclarationType()) {
if (name() == otherForward->name())
return true;
else if (name() && otherForward->name())
return name()->isEqualTo(otherForward->name());
return false;
}
return false;
}
{ return FullySpecifiedType(); }
void ObjCForwardProtocolDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
void ObjCForwardProtocolDeclaration::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
CPLUSPLUS_END_NAMESPACE

View File

@@ -463,7 +463,7 @@ private:
Array<BaseClass *> _baseClasses;
};
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol
{
public:
ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
@@ -472,24 +472,14 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
// Type's interface
virtual bool isEqualTo(const Type *other) const;
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const
{ return this; }
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration()
{ return this; }
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const
{ return this; }
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
virtual void accept0(TypeVisitor *visitor);
private:
};
@@ -526,7 +516,7 @@ private:
Array<ObjCProtocol *> _protocols;
};
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol
{
public:
ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
@@ -535,24 +525,14 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
// Type's interface
virtual bool isEqualTo(const Type *other) const;
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const
{ return this; }
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration()
{ return this; }
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const
{ return this; }
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
virtual void accept0(TypeVisitor *visitor);
private:
};

View File

@@ -104,15 +104,9 @@ bool Type::isForwardClassDeclarationType() const
bool Type::isObjCClassType() const
{ return asObjCClassType() != 0; }
bool Type::isObjCForwardClassDeclarationType() const
{ return asObjCForwardClassDeclarationType() != 0; }
bool Type::isObjCProtocolType() const
{ return asObjCProtocolType() != 0; }
bool Type::isObjCForwardProtocolDeclarationType() const
{ return asObjCForwardProtocolDeclarationType() != 0; }
void Type::accept(TypeVisitor *visitor)
{
if (visitor->preVisit(this))

View File

@@ -78,9 +78,7 @@ public:
bool isEnumType() const;
bool isForwardClassDeclarationType() const;
bool isObjCClassType() const;
bool isObjCForwardClassDeclarationType() const;
bool isObjCProtocolType() const;
bool isObjCForwardProtocolDeclarationType() const;
virtual const VoidType *asVoidType() const { return 0; }
virtual const IntegerType *asIntegerType() const { return 0; }
@@ -96,9 +94,7 @@ public:
virtual const Enum *asEnumType() const { return 0; }
virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const { return 0; }
virtual const ObjCClass *asObjCClassType() const { return 0; }
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const { return 0; }
virtual const ObjCProtocol *asObjCProtocolType() const { return 0; }
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const { return 0; }
virtual VoidType *asVoidType() { return 0; }
virtual IntegerType *asIntegerType() { return 0; }
@@ -114,9 +110,7 @@ public:
virtual Enum *asEnumType() { return 0; }
virtual ForwardClassDeclaration *asForwardClassDeclarationType() { return 0; }
virtual ObjCClass *asObjCClassType() { return 0; }
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() { return 0; }
virtual ObjCProtocol *asObjCProtocoTypel() { return 0; }
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() { return 0; }
void accept(TypeVisitor *visitor);
static void accept(Type *type, TypeVisitor *visitor);

View File

@@ -83,8 +83,6 @@ public:
virtual void visit(ForwardClassDeclaration *) {}
virtual void visit(ObjCClass *) {}
virtual void visit(ObjCProtocol *) {}
virtual void visit(ObjCForwardClassDeclaration *) {}
virtual void visit(ObjCForwardProtocolDeclaration *) {}
};
CPLUSPLUS_END_NAMESPACE