summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/Symbols.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@nokia.com>2009-07-28 16:34:15 +0200
committerErik Verbruggen <erik.verbruggen@nokia.com>2009-07-28 16:34:15 +0200
commit26267c03445266233159b2f61bbc3a4d5864c01a (patch)
tree8b7536d8f41fea63adc180d56830a73aae1192ad /src/shared/cplusplus/Symbols.cpp
parenta9b521f80af025ac11f9735fc070606952894b60 (diff)
downloadqt-creator-26267c03445266233159b2f61bbc3a4d5864c01a.tar.gz
Improved ObjC parsing, and added semantic checks.
Diffstat (limited to 'src/shared/cplusplus/Symbols.cpp')
-rw-r--r--src/shared/cplusplus/Symbols.cpp134
1 files changed, 134 insertions, 0 deletions
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<ObjCClass *>(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<ObjCProtocol *>(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<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;
+}
+
+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<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;
+}
+
+void ObjCForwardProtocolDeclaration::visitSymbol0(SymbolVisitor *visitor)
+{ visitor->visit(this); }
+
+void ObjCForwardProtocolDeclaration::accept0(TypeVisitor *visitor)
+{ visitor->visit(this); }
+
CPLUSPLUS_END_NAMESPACE