forked from qt-creator/qt-creator
Improved ObjC parsing, and added semantic checks.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user