From 26267c03445266233159b2f61bbc3a4d5864c01a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 28 Jul 2009 16:34:15 +0200 Subject: Improved ObjC parsing, and added semantic checks. --- src/shared/cplusplus/Symbols.cpp | 134 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) (limited to 'src/shared/cplusplus/Symbols.cpp') diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index dddc153928..d7446f9852 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -553,4 +553,138 @@ void Class::visitSymbol0(SymbolVisitor *visitor) } } +ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): + ScopedSymbol(translationUnit, sourceLocation, name) +{ +} + +ObjCClass::~ObjCClass() +{} + +FullySpecifiedType ObjCClass::type() const +{ return FullySpecifiedType(const_cast(this)); } + +bool ObjCClass::isEqualTo(const Type *other) const +{ + const ObjCClass *o = other->asObjCClassType(); + if (!o) + return false; + + Name *l = identity(); + Name *r = o->identity(); + if (l == r || (l && l->isEqualTo(r))) + return true; + else + return false; +} + +void ObjCClass::visitSymbol0(SymbolVisitor *visitor) +{ + if (visitor->visit(this)) { + for (unsigned i = 0; i < _baseClasses.size(); ++i) + visitSymbol(_baseClasses.at(i), visitor); + for (unsigned i = 0; i < _protocols.size(); ++i) + visitSymbol(_protocols.at(i), visitor); + } +} + +void ObjCClass::accept0(TypeVisitor *visitor) +{ visitor->visit(this); } + +ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): + ScopedSymbol(translationUnit, sourceLocation, name) +{ +} + +ObjCProtocol::~ObjCProtocol() +{} + +FullySpecifiedType ObjCProtocol::type() const +{ return FullySpecifiedType(const_cast(this)); } + +bool ObjCProtocol::isEqualTo(const Type *other) const +{ + const ObjCProtocol *o = other->asObjCProtocolType(); + if (!o) + return false; + + Name *l = identity(); + Name *r = o->identity(); + if (l == r || (l && l->isEqualTo(r))) + return true; + else + return false; +} + +void ObjCProtocol::visitSymbol0(SymbolVisitor *visitor) +{ + if (visitor->visit(this)) { + for (unsigned i = 0; i < _protocols.size(); ++i) + visitSymbol(_protocols.at(i), visitor); + } +} + +void ObjCProtocol::accept0(TypeVisitor *visitor) +{ visitor->visit(this); } + +ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): + Symbol(translationUnit, sourceLocation, name) +{ +} + +ObjCForwardClassDeclaration::~ObjCForwardClassDeclaration() +{} + +FullySpecifiedType ObjCForwardClassDeclaration::type() const +{ return FullySpecifiedType(const_cast(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; +} + +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) +{ +} + +ObjCForwardProtocolDeclaration::~ObjCForwardProtocolDeclaration() +{} + +FullySpecifiedType ObjCForwardProtocolDeclaration::type() const +{ return FullySpecifiedType(const_cast(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; +} + +void ObjCForwardProtocolDeclaration::visitSymbol0(SymbolVisitor *visitor) +{ visitor->visit(this); } + +void ObjCForwardProtocolDeclaration::accept0(TypeVisitor *visitor) +{ visitor->visit(this); } + CPLUSPLUS_END_NAMESPACE -- cgit v1.2.1