Use const names.

This commit is contained in:
Roberto Raggi
2009-12-01 12:46:15 +01:00
parent f2e77fb8fd
commit 7c7ce13ac0
46 changed files with 577 additions and 642 deletions

View File

@@ -122,7 +122,7 @@ bool CheckUndefinedSymbols::isType(const Identifier *id) const
return isType(QByteArray::fromRawData(id->chars(), id->size())); return isType(QByteArray::fromRawData(id->chars(), id->size()));
} }
void CheckUndefinedSymbols::addType(Name *name) void CheckUndefinedSymbols::addType(const Name *name)
{ {
if (! name) if (! name)
return; return;
@@ -131,7 +131,7 @@ void CheckUndefinedSymbols::addType(Name *name)
_types.insert(QByteArray(id->chars(), id->size())); _types.insert(QByteArray(id->chars(), id->size()));
} }
void CheckUndefinedSymbols::addProtocol(Name *name) void CheckUndefinedSymbols::addProtocol(const Name *name)
{ {
if (!name) if (!name)
return; return;
@@ -294,7 +294,7 @@ bool CheckUndefinedSymbols::visit(ClassSpecifierAST *ast)
Symbol *symbol = klass->memberAt(i); Symbol *symbol = klass->memberAt(i);
if (symbol->name() && symbol->name()->isNameId()) { if (symbol->name() && symbol->name()->isNameId()) {
NameId *nameId = symbol->name()->asNameId(); const NameId *nameId = symbol->name()->asNameId();
if (! qstrcmp(nameId->identifier()->chars(), "qt_check_for_QOBJECT_macro")) { if (! qstrcmp(nameId->identifier()->chars(), "qt_check_for_QOBJECT_macro")) {
hasQ_OBJECT_CHECK = true; hasQ_OBJECT_CHECK = true;
@@ -367,7 +367,7 @@ bool CheckUndefinedSymbols::visit(BaseSpecifierAST *base)
if (NameAST *nameAST = base->name) { if (NameAST *nameAST = base->name) {
bool resolvedBaseClassName = false; bool resolvedBaseClassName = false;
if (Name *name = nameAST->name) { if (const Name *name = nameAST->name) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (isType(spell)) if (isType(spell))
@@ -403,9 +403,9 @@ bool CheckUndefinedSymbols::visit(UsingDirectiveAST *ast)
bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast) bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast)
{ {
if (ast->name) { if (ast->name) {
QualifiedNameId *q = ast->name->asQualifiedNameId(); const QualifiedNameId *q = ast->name->asQualifiedNameId();
for (unsigned i = 0; i < q->nameCount() - 1; ++i) { for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
Name *name = q->nameAt(i); const Name *name = q->nameAt(i);
if (const Identifier *id = name->identifier()) { if (const Identifier *id = name->identifier()) {
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (! (_namespaceNames.contains(spell) || isType(id))) { if (! (_namespaceNames.contains(spell) || isType(id))) {
@@ -474,7 +474,7 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast)
if (NameAST *nameAST = ast->superclass) { if (NameAST *nameAST = ast->superclass) {
bool resolvedSuperClassName = false; bool resolvedSuperClassName = false;
if (Name *name = nameAST->name) { if (const Name *name = nameAST->name) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (isType(spell)) if (isType(spell))
@@ -496,7 +496,7 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
if (NameAST *nameAST = iter->value) { if (NameAST *nameAST = iter->value) {
bool resolvedProtocolName = false; bool resolvedProtocolName = false;
if (Name *name = nameAST->name) { if (const Name *name = nameAST->name) {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size()); const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
if (isProtocol(spell)) if (isProtocol(spell))

View File

@@ -55,11 +55,11 @@ protected:
bool isType(const Identifier *id) const; bool isType(const Identifier *id) const;
bool isType(const QByteArray &name) const; bool isType(const QByteArray &name) const;
void addType(Name *name); void addType(const Name *name);
void buildTypeMap(Class *klass); void buildTypeMap(Class *klass);
void buildMemberTypeMap(Symbol *member); void buildMemberTypeMap(Symbol *member);
void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed); void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed);
void addProtocol(Name *name); void addProtocol(const Name *name);
bool isProtocol(const QByteArray &name) const; bool isProtocol(const QByteArray &name) const;
FunctionDeclaratorAST *currentFunctionDeclarator() const; FunctionDeclaratorAST *currentFunctionDeclarator() const;

View File

@@ -79,11 +79,11 @@ NamespaceBinding::~NamespaceBinding()
qDeleteAll(classBindings); qDeleteAll(classBindings);
} }
NameId *NamespaceBinding::name() const const NameId *NamespaceBinding::name() const
{ {
if (symbols.size()) { if (symbols.size()) {
if (Name *name = symbols.first()->name()) { if (const Name *name = symbols.first()->name()) {
NameId *nameId = name->asNameId(); const NameId *nameId = name->asNameId();
Q_ASSERT(nameId != 0); Q_ASSERT(nameId != 0);
return nameId; return nameId;
@@ -95,7 +95,7 @@ NameId *NamespaceBinding::name() const
const Identifier *NamespaceBinding::identifier() const const Identifier *NamespaceBinding::identifier() const
{ {
if (NameId *nameId = name()) if (const NameId *nameId = name())
return nameId->identifier(); return nameId->identifier();
return 0; return 0;
@@ -144,7 +144,7 @@ Binding *NamespaceBinding::findClassOrNamespaceBinding(const Identifier *id, QSe
return 0; return 0;
} }
ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *processed) ClassBinding *NamespaceBinding::findClassBinding(const Name *name, QSet<Binding *> *processed)
{ {
if (! name) if (! name)
return 0; return 0;
@@ -191,19 +191,19 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
return 0; return 0;
} }
NamespaceBinding *NamespaceBinding::findNamespaceBinding(Name *name) NamespaceBinding *NamespaceBinding::findNamespaceBinding(const Name *name)
{ {
if (! name) if (! name)
return anonymousNamespaceBinding; return anonymousNamespaceBinding;
else if (NameId *nameId = name->asNameId()) else if (const NameId *nameId = name->asNameId())
return findNamespaceBindingForNameId(nameId, /*lookAtParent = */ true); return findNamespaceBindingForNameId(nameId, /*lookAtParent = */ true);
else if (const QualifiedNameId *q = name->asQualifiedNameId()) { else if (const QualifiedNameId *q = name->asQualifiedNameId()) {
NamespaceBinding *current = this; NamespaceBinding *current = this;
for (unsigned i = 0; i < q->nameCount(); ++i) { for (unsigned i = 0; i < q->nameCount(); ++i) {
NameId *namespaceName = q->nameAt(i)->asNameId(); const NameId *namespaceName = q->nameAt(i)->asNameId();
if (! namespaceName) if (! namespaceName)
return 0; return 0;
@@ -225,14 +225,14 @@ NamespaceBinding *NamespaceBinding::findNamespaceBinding(Name *name)
return 0; return 0;
} }
NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId(NameId *name, NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId(const NameId *name,
bool lookAtParentNamespace) bool lookAtParentNamespace)
{ {
QSet<NamespaceBinding *> processed; QSet<NamespaceBinding *> processed;
return findNamespaceBindingForNameId_helper(name, lookAtParentNamespace, &processed); return findNamespaceBindingForNameId_helper(name, lookAtParentNamespace, &processed);
} }
NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(NameId *name, NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(const NameId *name,
bool lookAtParentNamespace, bool lookAtParentNamespace,
QSet<NamespaceBinding *> *processed) QSet<NamespaceBinding *> *processed)
{ {
@@ -242,12 +242,12 @@ NamespaceBinding *NamespaceBinding::findNamespaceBindingForNameId_helper(NameId
processed->insert(this); processed->insert(this);
foreach (NamespaceBinding *binding, children) { foreach (NamespaceBinding *binding, children) {
Name *bindingName = binding->name(); const Name *bindingName = binding->name();
if (! bindingName) if (! bindingName)
continue; continue;
if (NameId *bindingNameId = bindingName->asNameId()) { if (const NameId *bindingNameId = bindingName->asNameId()) {
if (name->isEqualTo(bindingNameId)) if (name->isEqualTo(bindingNameId))
return binding; return binding;
} }
@@ -296,7 +296,7 @@ NamespaceBinding *NamespaceBinding::findOrCreateNamespaceBinding(Namespace *symb
} }
static void closure(const Location &loc, static void closure(const Location &loc,
NamespaceBinding *binding, Name *name, NamespaceBinding *binding, const Name *name,
QList<NamespaceBinding *> *bindings) QList<NamespaceBinding *> *bindings)
{ {
if (bindings->contains(binding)) if (bindings->contains(binding))
@@ -334,13 +334,13 @@ static void closure(const Location &loc,
NamespaceBinding *NamespaceBinding::resolveNamespace(const Location &loc, NamespaceBinding *NamespaceBinding::resolveNamespace(const Location &loc,
Name *name, const Name *name,
bool lookAtParent) bool lookAtParent)
{ {
if (! name) if (! name)
return 0; return 0;
else if (NameId *nameId = name->asNameId()) { else if (const NameId *nameId = name->asNameId()) {
QList<NamespaceBinding *> bindings; QList<NamespaceBinding *> bindings;
closure(loc, this, nameId, &bindings); closure(loc, this, nameId, &bindings);
@@ -447,7 +447,7 @@ Binding *ClassBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Bi
return 0; return 0;
} }
ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *processed) ClassBinding *ClassBinding::findClassBinding(const Name *name, QSet<Binding *> *processed)
{ {
if (! name) if (! name)
return 0; return 0;
@@ -549,7 +549,7 @@ ClassBinding::ClassBinding(ClassBinding *parentClass)
ClassBinding::~ClassBinding() ClassBinding::~ClassBinding()
{ qDeleteAll(children); } { qDeleteAll(children); }
Name *ClassBinding::name() const const Name *ClassBinding::name() const
{ {
if (symbols.isEmpty()) if (symbols.isEmpty())
return 0; return 0;
@@ -559,7 +559,7 @@ Name *ClassBinding::name() const
const Identifier *ClassBinding::identifier() const const Identifier *ClassBinding::identifier() const
{ {
if (Name *n = name()) if (const Name *n = name())
return n->identifier(); return n->identifier();
return 0; return 0;
@@ -623,12 +623,12 @@ protected:
NamespaceBinding *bind(Symbol *symbol, NamespaceBinding *binding); NamespaceBinding *bind(Symbol *symbol, NamespaceBinding *binding);
NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol); NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol);
NamespaceBinding *resolveNamespace(const Location &loc, Name *name); NamespaceBinding *resolveNamespace(const Location &loc, const Name *name);
NamespaceBinding *switchNamespaceBinding(NamespaceBinding *binding); NamespaceBinding *switchNamespaceBinding(NamespaceBinding *binding);
ClassBinding *findOrCreateClassBinding(Class *classSymbol); ClassBinding *findOrCreateClassBinding(Class *classSymbol);
ClassBinding *findClassBinding(Name *name); ClassBinding *findClassBinding(const Name *name);
ClassBinding *switchClassBinding(ClassBinding *binding); ClassBinding *switchClassBinding(ClassBinding *binding);
@@ -665,7 +665,7 @@ NamespaceBinding *Binder::bind(Symbol *symbol, NamespaceBinding *binding)
NamespaceBinding *Binder::findOrCreateNamespaceBinding(Namespace *symbol) NamespaceBinding *Binder::findOrCreateNamespaceBinding(Namespace *symbol)
{ return namespaceBinding->findOrCreateNamespaceBinding(symbol); } { return namespaceBinding->findOrCreateNamespaceBinding(symbol); }
NamespaceBinding *Binder::resolveNamespace(const Location &loc, Name *name) NamespaceBinding *Binder::resolveNamespace(const Location &loc, const Name *name)
{ {
if (! namespaceBinding) if (! namespaceBinding)
return 0; return 0;
@@ -694,7 +694,7 @@ ClassBinding *Binder::findOrCreateClassBinding(Class *classSymbol)
return binding; return binding;
} }
ClassBinding *Binder::findClassBinding(Name *name) ClassBinding *Binder::findClassBinding(const Name *name)
{ {
QSet<Binding *> processed; QSet<Binding *> processed;

View File

@@ -84,7 +84,7 @@ public:
virtual NamespaceBinding *asNamespaceBinding() { return 0; } virtual NamespaceBinding *asNamespaceBinding() { return 0; }
virtual ClassBinding *asClassBinding() { return 0; } virtual ClassBinding *asClassBinding() { return 0; }
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed) = 0; virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed) = 0;
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) = 0; virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) = 0;
}; };
@@ -98,7 +98,7 @@ public:
virtual ~NamespaceBinding(); virtual ~NamespaceBinding();
/// Returns this binding's name. /// Returns this binding's name.
NameId *name() const; const NameId *name() const;
/// Returns this binding's identifier. /// Returns this binding's identifier.
const Identifier *identifier() const; const Identifier *identifier() const;
@@ -107,16 +107,16 @@ public:
NamespaceBinding *globalNamespaceBinding(); NamespaceBinding *globalNamespaceBinding();
/// Returns the binding for the given namespace symbol. /// Returns the binding for the given namespace symbol.
NamespaceBinding *findNamespaceBinding(Name *name); NamespaceBinding *findNamespaceBinding(const Name *name);
/// Returns the binding associated with the given symbol. /// Returns the binding associated with the given symbol.
NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol); NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol);
NamespaceBinding *resolveNamespace(const Location &loc, NamespaceBinding *resolveNamespace(const Location &loc,
Name *name, const Name *name,
bool lookAtParent = true); bool lookAtParent = true);
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed); virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed);
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed); virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
/// Helpers. /// Helpers.
@@ -129,10 +129,10 @@ public:
static ClassBinding *find(Class *symbol, NamespaceBinding *binding); static ClassBinding *find(Class *symbol, NamespaceBinding *binding);
private: private:
NamespaceBinding *findNamespaceBindingForNameId(NameId *name, NamespaceBinding *findNamespaceBindingForNameId(const NameId *name,
bool lookAtParentNamespace); bool lookAtParentNamespace);
NamespaceBinding *findNamespaceBindingForNameId_helper(NameId *name, NamespaceBinding *findNamespaceBindingForNameId_helper(const NameId *name,
bool lookAtParentNamespace, bool lookAtParentNamespace,
QSet<NamespaceBinding *> *processed); QSet<NamespaceBinding *> *processed);
@@ -165,13 +165,13 @@ public:
virtual ClassBinding *asClassBinding() { return this; } virtual ClassBinding *asClassBinding() { return this; }
/// Returns this binding's name. /// Returns this binding's name.
Name *name() const; const Name *name() const;
/// Returns this binding's identifier. /// Returns this binding's identifier.
const Identifier *identifier() const; const Identifier *identifier() const;
virtual QByteArray qualifiedId() const; virtual QByteArray qualifiedId() const;
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed); virtual ClassBinding *findClassBinding(const Name *name, QSet<Binding *> *processed);
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed); virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
void dump(); void dump();

View File

@@ -52,7 +52,7 @@ public:
Control *control() const { return context.control(); } Control *control() const { return context.control(); }
FullySpecifiedType apply(Name *name); FullySpecifiedType apply(const Name *name);
FullySpecifiedType apply(const FullySpecifiedType &type); FullySpecifiedType apply(const FullySpecifiedType &type);
int findSubstitution(const Identifier *id) const; int findSubstitution(const Identifier *id) const;
@@ -207,7 +207,7 @@ private:
public: public:
ApplyToName(ApplySubstitution *q): q(q) {} ApplyToName(ApplySubstitution *q): q(q) {}
FullySpecifiedType operator()(Name *name) FullySpecifiedType operator()(const Name *name)
{ {
FullySpecifiedType previousType = switchType(FullySpecifiedType()); FullySpecifiedType previousType = switchType(FullySpecifiedType());
accept(name); accept(name);
@@ -231,7 +231,7 @@ private:
return previousType; return previousType;
} }
virtual void visit(NameId *name) virtual void visit(const NameId *name)
{ {
int index = findSubstitution(name->identifier()); int index = findSubstitution(name->identifier());
@@ -242,7 +242,7 @@ private:
_type = control()->namedType(name); _type = control()->namedType(name);
} }
virtual void visit(TemplateNameId *name) virtual void visit(const TemplateNameId *name)
{ {
QVarLengthArray<FullySpecifiedType, 8> arguments(name->templateArgumentCount()); QVarLengthArray<FullySpecifiedType, 8> arguments(name->templateArgumentCount());
for (unsigned i = 0; i < name->templateArgumentCount(); ++i) { for (unsigned i = 0; i < name->templateArgumentCount(); ++i) {
@@ -250,17 +250,19 @@ private:
arguments[i] = q->apply(argTy); arguments[i] = q->apply(argTy);
} }
TemplateNameId *templId = control()->templateNameId(name->identifier(), arguments.data(), arguments.size()); const TemplateNameId *templId = control()->templateNameId(name->identifier(),
arguments.data(),
arguments.size());
_type = control()->namedType(templId); _type = control()->namedType(templId);
} }
virtual void visit(QualifiedNameId *name) virtual void visit(const QualifiedNameId *name)
{ {
QVarLengthArray<Name *, 8> names(name->nameCount()); QVarLengthArray<const Name *, 8> names(name->nameCount());
for (unsigned i = 0; i < name->nameCount(); ++i) { for (unsigned i = 0; i < name->nameCount(); ++i) {
Name *n = name->nameAt(i); const Name *n = name->nameAt(i);
if (TemplateNameId *templId = n->asTemplateNameId()) { if (const TemplateNameId *templId = n->asTemplateNameId()) {
QVarLengthArray<FullySpecifiedType, 8> arguments(templId->templateArgumentCount()); QVarLengthArray<FullySpecifiedType, 8> arguments(templId->templateArgumentCount());
for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) { for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) {
FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex); FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex);
@@ -273,29 +275,29 @@ private:
names[i] = n; names[i] = n;
} }
QualifiedNameId *q = control()->qualifiedNameId(names.data(), names.size(), name->isGlobal()); const QualifiedNameId *q = control()->qualifiedNameId(names.data(), names.size(), name->isGlobal());
_type = control()->namedType(q); _type = control()->namedType(q);
} }
virtual void visit(DestructorNameId *name) virtual void visit(const DestructorNameId *name)
{ {
Overview oo; Overview oo;
qWarning() << "ignored name:" << oo(name); qWarning() << "ignored name:" << oo(name);
} }
virtual void visit(OperatorNameId *name) virtual void visit(const OperatorNameId *name)
{ {
Overview oo; Overview oo;
qWarning() << "ignored name:" << oo(name); qWarning() << "ignored name:" << oo(name);
} }
virtual void visit(ConversionNameId *name) virtual void visit(const ConversionNameId *name)
{ {
Overview oo; Overview oo;
qWarning() << "ignored name:" << oo(name); qWarning() << "ignored name:" << oo(name);
} }
virtual void visit(SelectorNameId *name) virtual void visit(const SelectorNameId *name)
{ {
Overview oo; Overview oo;
qWarning() << "ignored name:" << oo(name); qWarning() << "ignored name:" << oo(name);
@@ -325,7 +327,7 @@ ApplySubstitution::~ApplySubstitution()
{ {
} }
FullySpecifiedType ApplySubstitution::apply(Name *name) FullySpecifiedType ApplySubstitution::apply(const Name *name)
{ {
FullySpecifiedType ty = applyToName(name); FullySpecifiedType ty = applyToName(name);
return ty; return ty;

View File

@@ -109,14 +109,14 @@ bool LookupContext::maybeValidSymbol(Symbol *symbol,
return false; return false;
} }
QList<Scope *> LookupContext::resolveNestedNameSpecifier(QualifiedNameId *q, QList<Scope *> LookupContext::resolveNestedNameSpecifier(const QualifiedNameId *q,
const QList<Scope *> &visibleScopes) const const QList<Scope *> &visibleScopes) const
{ {
QList<Symbol *> candidates; QList<Symbol *> candidates;
QList<Scope *> scopes = visibleScopes; QList<Scope *> scopes = visibleScopes;
for (unsigned i = 0; i < q->nameCount() - 1; ++i) { for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
Name *name = q->nameAt(i); const Name *name = q->nameAt(i);
candidates = resolveClassOrNamespace(name, scopes); candidates = resolveClassOrNamespace(name, scopes);
@@ -137,7 +137,7 @@ QList<Scope *> LookupContext::resolveNestedNameSpecifier(QualifiedNameId *q,
return scopes; return scopes;
} }
QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, QList<Symbol *> LookupContext::resolveQualifiedNameId(const QualifiedNameId *q,
const QList<Scope *> &visibleScopes, const QList<Scope *> &visibleScopes,
ResolveMode mode) const ResolveMode mode) const
{ {
@@ -153,7 +153,7 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
else if (! symbol->isClass()) else if (! symbol->isClass())
continue; continue;
QualifiedNameId *qq = symbol->name()->asQualifiedNameId(); const QualifiedNameId *qq = symbol->name()->asQualifiedNameId();
if (! qq) if (! qq)
continue; continue;
@@ -167,8 +167,8 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
unsigned j = 0; unsigned j = 0;
for (; j < q->nameCount(); ++j) { for (; j < q->nameCount(); ++j) {
Name *classOrNamespaceName1 = q->nameAt(j); const Name *classOrNamespaceName1 = q->nameAt(j);
Name *classOrNamespaceName2 = qq->nameAt(j); const Name *classOrNamespaceName2 = qq->nameAt(j);
if (! classOrNamespaceName1->isEqualTo(classOrNamespaceName2)) if (! classOrNamespaceName1->isEqualTo(classOrNamespaceName2))
break; break;
@@ -205,7 +205,7 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
return candidates; return candidates;
} }
QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId, QList<Symbol *> LookupContext::resolveOperatorNameId(const OperatorNameId *opId,
const QList<Scope *> &visibleScopes, const QList<Scope *> &visibleScopes,
ResolveMode) const ResolveMode) const
{ {
@@ -226,7 +226,7 @@ QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId,
return candidates; return candidates;
} }
QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes, QList<Symbol *> LookupContext::resolve(const Name *name, const QList<Scope *> &visibleScopes,
ResolveMode mode) const ResolveMode mode) const
{ {
QList<Symbol *> candidates; QList<Symbol *> candidates;
@@ -234,10 +234,10 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
if (!name) if (!name)
return candidates; // nothing to do, the symbol is anonymous. return candidates; // nothing to do, the symbol is anonymous.
else if (QualifiedNameId *q = name->asQualifiedNameId()) else if (const QualifiedNameId *q = name->asQualifiedNameId())
return resolveQualifiedNameId(q, visibleScopes, mode); return resolveQualifiedNameId(q, visibleScopes, mode);
else if (OperatorNameId *opId = name->asOperatorNameId()) else if (const OperatorNameId *opId = name->asOperatorNameId())
return resolveOperatorNameId(opId, visibleScopes, mode); return resolveOperatorNameId(opId, visibleScopes, mode);
else if (const Identifier *id = name->identifier()) { else if (const Identifier *id = name->identifier()) {
@@ -256,13 +256,13 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
continue; // skip it, the symbol's id is not compatible with this lookup. continue; // skip it, the symbol's id is not compatible with this lookup.
} }
if (QualifiedNameId *q = symbol->name()->asQualifiedNameId()) { if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) {
if (name->isDestructorNameId() != q->unqualifiedNameId()->isDestructorNameId()) if (name->isDestructorNameId() != q->unqualifiedNameId()->isDestructorNameId())
continue; continue;
else if (q->nameCount() > 1) { else if (q->nameCount() > 1) {
Name *classOrNamespaceName = control()->qualifiedNameId(q->names(), const Name *classOrNamespaceName = control()->qualifiedNameId(q->names(),
q->nameCount() - 1); q->nameCount() - 1);
if (const Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) { if (const Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) {
@@ -418,7 +418,7 @@ void LookupContext::expandNamespace(Namespace *ns,
if (Scope *encl = ns->enclosingNamespaceScope()) if (Scope *encl = ns->enclosingNamespaceScope())
expand(encl, visibleScopes, expandedScopes); expand(encl, visibleScopes, expandedScopes);
if (Name *nsName = ns->name()) { if (const Name *nsName = ns->name()) {
const QList<Symbol *> namespaceList = resolveNamespace(nsName, visibleScopes); const QList<Symbol *> namespaceList = resolveNamespace(nsName, visibleScopes);
foreach (Symbol *otherNs, namespaceList) { foreach (Symbol *otherNs, namespaceList) {
if (otherNs == ns) if (otherNs == ns)
@@ -478,7 +478,7 @@ void LookupContext::expandClass(Class *klass,
for (unsigned i = 0; i < klass->baseClassCount(); ++i) { for (unsigned i = 0; i < klass->baseClassCount(); ++i) {
BaseClass *baseClass = klass->baseClassAt(i); BaseClass *baseClass = klass->baseClassAt(i);
Name *baseClassName = baseClass->name(); const Name *baseClassName = baseClass->name();
const QList<Symbol *> baseClassCandidates = resolveClass(baseClassName, const QList<Symbol *> baseClassCandidates = resolveClass(baseClassName,
classVisibleScopes); classVisibleScopes);
@@ -515,8 +515,8 @@ void LookupContext::expandFunction(Function *function,
if (! expandedScopes->contains(function->arguments())) if (! expandedScopes->contains(function->arguments()))
expandedScopes->append(function->arguments()); expandedScopes->append(function->arguments());
if (QualifiedNameId *q = function->name()->asQualifiedNameId()) { if (const QualifiedNameId *q = function->name()->asQualifiedNameId()) {
Name *nestedNameSpec = 0; const Name *nestedNameSpec = 0;
if (q->nameCount() == 1) if (q->nameCount() == 1)
nestedNameSpec = q->nameAt(0); nestedNameSpec = q->nameAt(0);
else else
@@ -565,7 +565,7 @@ void LookupContext::expandObjCClass(ObjCClass *klass,
// expand the base class: // expand the base class:
if (ObjCBaseClass *baseClass = klass->baseClass()) { if (ObjCBaseClass *baseClass = klass->baseClass()) {
Name *baseClassName = baseClass->name(); const Name *baseClassName = baseClass->name();
const QList<Symbol *> baseClassCandidates = resolveObjCClass(baseClassName, const QList<Symbol *> baseClassCandidates = resolveObjCClass(baseClassName,
visibleScopes); visibleScopes);
@@ -577,7 +577,7 @@ void LookupContext::expandObjCClass(ObjCClass *klass,
// expand the protocols: // expand the protocols:
for (unsigned i = 0; i < klass->protocolCount(); ++i) { for (unsigned i = 0; i < klass->protocolCount(); ++i) {
Name *protocolName = klass->protocolAt(i)->name(); const Name *protocolName = klass->protocolAt(i)->name();
const QList<Symbol *> protocolCandidates = resolveObjCProtocol(protocolName, visibleScopes); const QList<Symbol *> protocolCandidates = resolveObjCProtocol(protocolName, visibleScopes);
for (int j = 0; j < protocolCandidates.size(); ++j) { for (int j = 0; j < protocolCandidates.size(); ++j) {
if (ObjCProtocol *protocolSymbol = protocolCandidates.at(j)->asObjCProtocol()) if (ObjCProtocol *protocolSymbol = protocolCandidates.at(j)->asObjCProtocol())

View File

@@ -94,22 +94,22 @@ public:
static Symbol *canonicalSymbol(const QList<LookupItem> &candidates, static Symbol *canonicalSymbol(const QList<LookupItem> &candidates,
NamespaceBinding *globalNamespaceBinding); NamespaceBinding *globalNamespaceBinding);
QList<Symbol *> resolve(Name *name) const QList<Symbol *> resolve(const Name *name) const
{ return resolve(name, visibleScopes()); } { return resolve(name, visibleScopes()); }
QList<Symbol *> resolveNamespace(Name *name) const QList<Symbol *> resolveNamespace(const Name *name) const
{ return resolveNamespace(name, visibleScopes()); } { return resolveNamespace(name, visibleScopes()); }
QList<Symbol *> resolveClass(Name *name) const QList<Symbol *> resolveClass(const Name *name) const
{ return resolveClass(name, visibleScopes()); } { return resolveClass(name, visibleScopes()); }
QList<Symbol *> resolveClassOrNamespace(Name *name) const QList<Symbol *> resolveClassOrNamespace(const Name *name) const
{ return resolveClassOrNamespace(name, visibleScopes()); } { return resolveClassOrNamespace(name, visibleScopes()); }
QList<Symbol *> resolveObjCClass(Name *name) const QList<Symbol *> resolveObjCClass(const Name *name) const
{ return resolveObjCClass(name, visibleScopes()); } { return resolveObjCClass(name, visibleScopes()); }
QList<Symbol *> resolveObjCProtocol(Name *name) const QList<Symbol *> resolveObjCProtocol(const Name *name) const
{ return resolveObjCProtocol(name, visibleScopes()); } { return resolveObjCProtocol(name, visibleScopes()); }
enum ResolveMode { enum ResolveMode {
@@ -122,22 +122,22 @@ public:
ResolveAll = ResolveSymbol | ResolveClassOrNamespace | ResolveObjCClass | ResolveObjCProtocol ResolveAll = ResolveSymbol | ResolveClassOrNamespace | ResolveObjCClass | ResolveObjCProtocol
}; };
QList<Symbol *> resolve(Name *name, const QList<Scope *> &visibleScopes, QList<Symbol *> resolve(const Name *name, const QList<Scope *> &visibleScopes,
ResolveMode mode = ResolveAll) const; ResolveMode mode = ResolveAll) const;
QList<Symbol *> resolveNamespace(Name *name, const QList<Scope *> &visibleScopes) const QList<Symbol *> resolveNamespace(const Name *name, const QList<Scope *> &visibleScopes) const
{ return resolve(name, visibleScopes, ResolveNamespace); } { return resolve(name, visibleScopes, ResolveNamespace); }
QList<Symbol *> resolveClass(Name *name, const QList<Scope *> &visibleScopes) const QList<Symbol *> resolveClass(const Name *name, const QList<Scope *> &visibleScopes) const
{ return resolve(name, visibleScopes, ResolveClass); } { return resolve(name, visibleScopes, ResolveClass); }
QList<Symbol *> resolveClassOrNamespace(Name *name, const QList<Scope *> &visibleScopes) const QList<Symbol *> resolveClassOrNamespace(const Name *name, const QList<Scope *> &visibleScopes) const
{ return resolve(name, visibleScopes, ResolveClassOrNamespace); } { return resolve(name, visibleScopes, ResolveClassOrNamespace); }
QList<Symbol *> resolveObjCClass(Name *name, const QList<Scope *> &visibleScopes) const QList<Symbol *> resolveObjCClass(const Name *name, const QList<Scope *> &visibleScopes) const
{ return resolve(name, visibleScopes, ResolveObjCClass); } { return resolve(name, visibleScopes, ResolveObjCClass); }
QList<Symbol *> resolveObjCProtocol(Name *name, const QList<Scope *> &visibleScopes) const QList<Symbol *> resolveObjCProtocol(const Name *name, const QList<Scope *> &visibleScopes) const
{ return resolve(name, visibleScopes, ResolveObjCProtocol); } { return resolve(name, visibleScopes, ResolveObjCProtocol); }
QList<Scope *> visibleScopes() const QList<Scope *> visibleScopes() const
@@ -187,15 +187,15 @@ public:
private: private:
static Symbol *canonicalSymbol(Symbol *symbol); static Symbol *canonicalSymbol(Symbol *symbol);
QList<Symbol *> resolveQualifiedNameId(QualifiedNameId *q, QList<Symbol *> resolveQualifiedNameId(const QualifiedNameId *q,
const QList<Scope *> &visibleScopes, const QList<Scope *> &visibleScopes,
ResolveMode mode) const; ResolveMode mode) const;
QList<Symbol *> resolveOperatorNameId(OperatorNameId *opId, QList<Symbol *> resolveOperatorNameId(const OperatorNameId *opId,
const QList<Scope *> &visibleScopes, const QList<Scope *> &visibleScopes,
ResolveMode mode) const; ResolveMode mode) const;
QList<Scope *> resolveNestedNameSpecifier(QualifiedNameId *q, QList<Scope *> resolveNestedNameSpecifier(const QualifiedNameId *q,
const QList<Scope *> &visibleScopes) const; const QList<Scope *> &visibleScopes) const;
const Identifier *identifier(const Name *name) const; const Identifier *identifier(const Name *name) const;

View File

@@ -48,7 +48,7 @@ const Overview *NamePrettyPrinter::overview() const
return _overview; return _overview;
} }
QString NamePrettyPrinter::operator()(Name *name) QString NamePrettyPrinter::operator()(const Name *name)
{ {
QString previousName = switchName(); QString previousName = switchName();
accept(name); accept(name);
@@ -62,7 +62,7 @@ QString NamePrettyPrinter::switchName(const QString &name)
return previousName; return previousName;
} }
void NamePrettyPrinter::visit(NameId *name) void NamePrettyPrinter::visit(const NameId *name)
{ {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
if (id) if (id)
@@ -71,7 +71,7 @@ void NamePrettyPrinter::visit(NameId *name)
_name = QLatin1String("anonymous"); _name = QLatin1String("anonymous");
} }
void NamePrettyPrinter::visit(TemplateNameId *name) void NamePrettyPrinter::visit(const TemplateNameId *name)
{ {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
if (id) if (id)
@@ -93,14 +93,14 @@ void NamePrettyPrinter::visit(TemplateNameId *name)
_name += QLatin1Char('>'); _name += QLatin1Char('>');
} }
void NamePrettyPrinter::visit(DestructorNameId *name) void NamePrettyPrinter::visit(const DestructorNameId *name)
{ {
const Identifier *id = name->identifier(); const Identifier *id = name->identifier();
_name += QLatin1Char('~'); _name += QLatin1Char('~');
_name += QString::fromLatin1(id->chars(), id->size()); _name += QString::fromLatin1(id->chars(), id->size());
} }
void NamePrettyPrinter::visit(OperatorNameId *name) void NamePrettyPrinter::visit(const OperatorNameId *name)
{ {
_name += QLatin1String("operator "); _name += QLatin1String("operator ");
switch (name->kind()) { // ### i should probably do this in OperatorNameId switch (name->kind()) { // ### i should probably do this in OperatorNameId
@@ -236,13 +236,13 @@ void NamePrettyPrinter::visit(OperatorNameId *name)
} // switch } // switch
} }
void NamePrettyPrinter::visit(ConversionNameId *name) void NamePrettyPrinter::visit(const ConversionNameId *name)
{ {
_name += QLatin1String("operator "); _name += QLatin1String("operator ");
_name += overview()->prettyType(name->type()); _name += overview()->prettyType(name->type());
} }
void NamePrettyPrinter::visit(QualifiedNameId *name) void NamePrettyPrinter::visit(const QualifiedNameId *name)
{ {
if (name->isGlobal()) if (name->isGlobal())
_name += QLatin1String("::"); _name += QLatin1String("::");
@@ -254,10 +254,10 @@ void NamePrettyPrinter::visit(QualifiedNameId *name)
} }
} }
void NamePrettyPrinter::visit(SelectorNameId *name) void NamePrettyPrinter::visit(const SelectorNameId *name)
{ {
for (unsigned i = 0; i < name->nameCount(); ++i) { for (unsigned i = 0; i < name->nameCount(); ++i) {
Name *n = name->nameAt(i); const Name *n = name->nameAt(i);
if (!n) if (!n)
continue; continue;

View File

@@ -44,18 +44,18 @@ public:
virtual ~NamePrettyPrinter(); virtual ~NamePrettyPrinter();
const Overview *overview() const; const Overview *overview() const;
QString operator()(Name *name); QString operator()(const Name *name);
protected: protected:
QString switchName(const QString &name = QString()); QString switchName(const QString &name = QString());
virtual void visit(NameId *name); virtual void visit(const NameId *name);
virtual void visit(TemplateNameId *name); virtual void visit(const TemplateNameId *name);
virtual void visit(DestructorNameId *name); virtual void visit(const DestructorNameId *name);
virtual void visit(OperatorNameId *name); virtual void visit(const OperatorNameId *name);
virtual void visit(ConversionNameId *name); virtual void visit(const ConversionNameId *name);
virtual void visit(QualifiedNameId *name); virtual void visit(const QualifiedNameId *name);
virtual void visit(SelectorNameId *name); virtual void visit(const SelectorNameId *name);
private: private:
const Overview *_overview; const Overview *_overview;

View File

@@ -117,13 +117,13 @@ void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames)
_showFullyQualifiedNames = showFullyQualifiedNames; _showFullyQualifiedNames = showFullyQualifiedNames;
} }
QString Overview::prettyName(Name *name) const QString Overview::prettyName(const Name *name) const
{ {
NamePrettyPrinter pp(this); NamePrettyPrinter pp(this);
return pp(name); return pp(name);
} }
QString Overview::prettyType(const FullySpecifiedType &ty, Name *name) const QString Overview::prettyType(const FullySpecifiedType &ty, const Name *name) const
{ {
return prettyType(ty, prettyName(name)); return prettyType(ty, prettyName(name));
} }

View File

@@ -66,14 +66,14 @@ public:
int markedArgumentEnd() const; int markedArgumentEnd() const;
void setMarkedArgumentEnd(int end); void setMarkedArgumentEnd(int end);
QString operator()(Name *name) const QString operator()(const Name *name) const
{ return prettyName(name); } { return prettyName(name); }
QString operator()(const FullySpecifiedType &type, Name *name = 0) const QString operator()(const FullySpecifiedType &type, const Name *name = 0) const
{ return prettyType(type, name); } { return prettyType(type, name); }
QString prettyName(Name *name) const; QString prettyName(const Name *name) const;
QString prettyType(const FullySpecifiedType &type, Name *name = 0) const; QString prettyType(const FullySpecifiedType &type, const Name *name = 0) const;
QString prettyType(const FullySpecifiedType &type, const QString &name) const; QString prettyType(const FullySpecifiedType &type, const QString &name) const;
private: private:

View File

@@ -181,11 +181,11 @@ bool ResolveExpression::visit(NewExpressionAST *ast)
bool ResolveExpression::visit(TypeidExpressionAST *) bool ResolveExpression::visit(TypeidExpressionAST *)
{ {
Name *std_type_info[2]; const Name *std_type_info[2];
std_type_info[0] = control()->nameId(control()->findOrInsertIdentifier("std")); std_type_info[0] = control()->nameId(control()->findOrInsertIdentifier("std"));
std_type_info[1] = control()->nameId(control()->findOrInsertIdentifier("type_info")); std_type_info[1] = control()->nameId(control()->findOrInsertIdentifier("type_info"));
Name *q = control()->qualifiedNameId(std_type_info, 2, /*global=*/ true); const Name *q = control()->qualifiedNameId(std_type_info, 2, /*global=*/ true);
FullySpecifiedType ty(control()->namedType(q)); FullySpecifiedType ty(control()->namedType(q));
addResult(ty); addResult(ty);
@@ -277,8 +277,8 @@ bool ResolveExpression::visit(ThisExpressionAST *)
FullySpecifiedType ptrTy(control()->pointerType(classTy)); FullySpecifiedType ptrTy(control()->pointerType(classTy));
addResult(ptrTy, fun); addResult(ptrTy, fun);
break; break;
} else if (QualifiedNameId *q = fun->name()->asQualifiedNameId()) { } else if (const QualifiedNameId *q = fun->name()->asQualifiedNameId()) {
Name *nestedNameSpecifier = 0; const Name *nestedNameSpecifier = 0;
if (q->nameCount() == 1 && q->isGlobal()) if (q->nameCount() == 1 && q->isGlobal())
nestedNameSpecifier = q->nameAt(0); nestedNameSpecifier = q->nameAt(0);
else else
@@ -355,7 +355,7 @@ bool ResolveExpression::visit(CompoundLiteralAST *ast)
bool ResolveExpression::visit(QualifiedNameAST *ast) bool ResolveExpression::visit(QualifiedNameAST *ast)
{ {
ResolveClass resolveClass; ResolveClass resolveClass;
Name *name = ast->name; const Name *name = ast->name;
QList<Symbol *> symbols = _context.resolve(name); QList<Symbol *> symbols = _context.resolve(name);
foreach (Symbol *symbol, symbols) { foreach (Symbol *symbol, symbols) {
@@ -451,7 +451,7 @@ bool ResolveExpression::visit(CallAST *ast)
++actualArgumentCount; ++actualArgumentCount;
} }
Name *functionCallOp = control()->operatorNameId(OperatorNameId::FunctionCallOp); const Name *functionCallOp = control()->operatorNameId(OperatorNameId::FunctionCallOp);
foreach (const LookupItem &result, baseResults) { foreach (const LookupItem &result, baseResults) {
FullySpecifiedType ty = result.type().simplified(); FullySpecifiedType ty = result.type().simplified();
@@ -495,7 +495,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
const QList<LookupItem> indexResults = operator()(ast->expression); const QList<LookupItem> indexResults = operator()(ast->expression);
ResolveClass resolveClass; ResolveClass resolveClass;
Name *arrayAccessOp = control()->operatorNameId(OperatorNameId::ArrayAccessOp); const Name *arrayAccessOp = control()->operatorNameId(OperatorNameId::ArrayAccessOp);
foreach (const LookupItem &result, baseResults) { foreach (const LookupItem &result, baseResults) {
FullySpecifiedType ty = result.type().simplified(); FullySpecifiedType ty = result.type().simplified();
@@ -537,7 +537,7 @@ bool ResolveExpression::visit(MemberAccessAST *ast)
QList<LookupItem> baseResults = _results; QList<LookupItem> baseResults = _results;
// Evaluate the expression-id that follows the access operator. // Evaluate the expression-id that follows the access operator.
Name *memberName = 0; const Name *memberName = 0;
if (ast->member_name) if (ast->member_name)
memberName = ast->member_name->name; memberName = ast->member_name->name;
@@ -594,7 +594,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i
if (NamedType *namedTy = ty->asNamedType()) { if (NamedType *namedTy = ty->asNamedType()) {
ResolveClass resolveClass; ResolveClass resolveClass;
Name *arrowAccessOp = control()->operatorNameId(OperatorNameId::ArrowOp); const Name *arrowAccessOp = control()->operatorNameId(OperatorNameId::ArrowOp);
const QList<Symbol *> candidates = resolveClass(namedTy->name(), result, _context); const QList<Symbol *> candidates = resolveClass(namedTy->name(), result, _context);
foreach (Symbol *classObject, candidates) { foreach (Symbol *classObject, candidates) {
@@ -663,7 +663,7 @@ ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, i
QList<LookupItem> QList<LookupItem>
ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults, ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults,
unsigned accessOp, unsigned accessOp,
Name *memberName, const Name *memberName,
bool *replacedDotOperator) const bool *replacedDotOperator) const
{ {
ResolveClass resolveClass; ResolveClass resolveClass;
@@ -677,7 +677,7 @@ ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults,
results += resolveMember(memberName, klass); results += resolveMember(memberName, klass);
else if (NamedType *namedTy = ty->asNamedType()) { else if (NamedType *namedTy = ty->asNamedType()) {
Name *className = namedTy->name(); const Name *className = namedTy->name();
const QList<Symbol *> classes = resolveClass(className, r, _context); const QList<Symbol *> classes = resolveClass(className, r, _context);
foreach (Symbol *c, classes) { foreach (Symbol *c, classes) {
@@ -691,8 +691,8 @@ ResolveExpression::resolveMemberExpression(const QList<LookupItem> &baseResults,
} }
QList<LookupItem> QList<LookupItem>
ResolveExpression::resolveMember(Name *memberName, Class *klass, ResolveExpression::resolveMember(const Name *memberName, Class *klass,
Name *className) const const Name *className) const
{ {
QList<LookupItem> results; QList<LookupItem> results;
@@ -709,19 +709,19 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass,
foreach (Symbol *candidate, candidates) { foreach (Symbol *candidate, candidates) {
FullySpecifiedType ty = candidate->type(); FullySpecifiedType ty = candidate->type();
Name *unqualifiedNameId = className; const Name *unqualifiedNameId = className;
if (QualifiedNameId *q = className->asQualifiedNameId()) if (const QualifiedNameId *q = className->asQualifiedNameId())
unqualifiedNameId = q->unqualifiedNameId(); unqualifiedNameId = q->unqualifiedNameId();
if (TemplateNameId *templId = unqualifiedNameId->asTemplateNameId()) { if (const TemplateNameId *templId = unqualifiedNameId->asTemplateNameId()) {
GenTemplateInstance::Substitution subst; GenTemplateInstance::Substitution subst;
for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) { for (unsigned i = 0; i < templId->templateArgumentCount(); ++i) {
FullySpecifiedType templArgTy = templId->templateArgumentAt(i); FullySpecifiedType templArgTy = templId->templateArgumentAt(i);
if (i < klass->templateParameterCount()) { if (i < klass->templateParameterCount()) {
Name *templArgName = klass->templateParameterAt(i)->name(); const Name *templArgName = klass->templateParameterAt(i)->name();
if (templArgName && templArgName->identifier()) { if (templArgName && templArgName->identifier()) {
const Identifier *templArgId = templArgName->identifier(); const Identifier *templArgId = templArgName->identifier();
subst.append(qMakePair(templArgId, templArgTy)); subst.append(qMakePair(templArgId, templArgTy));
@@ -741,7 +741,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass,
QList<LookupItem> QList<LookupItem>
ResolveExpression::resolveMember(Name *memberName, ObjCClass *klass) const ResolveExpression::resolveMember(const Name *memberName, ObjCClass *klass) const
{ {
QList<LookupItem> results; QList<LookupItem> results;
@@ -774,7 +774,7 @@ bool ResolveExpression::visit(ObjCMessageExpressionAST *ast)
if (!receiverResults.isEmpty()) { if (!receiverResults.isEmpty()) {
LookupItem result = receiverResults.first(); LookupItem result = receiverResults.first();
FullySpecifiedType ty = result.type().simplified(); FullySpecifiedType ty = result.type().simplified();
Name *klassName = 0; const Name *klassName = 0;
if (const ObjCClass *classTy = ty->asObjCClassType()) { if (const ObjCClass *classTy = ty->asObjCClassType()) {
// static access, e.g.: // static access, e.g.:
@@ -805,7 +805,7 @@ bool ResolveExpression::visit(ObjCMessageExpressionAST *ast)
ResolveClass::ResolveClass() ResolveClass::ResolveClass()
{ } { }
QList<Symbol *> ResolveClass::operator()(Name *name, QList<Symbol *> ResolveClass::operator()(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context) const LookupContext &context)
{ {
@@ -815,7 +815,7 @@ QList<Symbol *> ResolveClass::operator()(Name *name,
return symbols; return symbols;
} }
QList<Symbol *> ResolveClass::resolveClass(Name *name, QList<Symbol *> ResolveClass::resolveClass(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context) const LookupContext &context)
{ {
@@ -873,7 +873,7 @@ QList<Symbol *> ResolveClass::resolveClass(Name *name,
ResolveObjCClass::ResolveObjCClass() ResolveObjCClass::ResolveObjCClass()
{} {}
QList<Symbol *> ResolveObjCClass::operator ()(Name *name, QList<Symbol *> ResolveObjCClass::operator ()(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context) const LookupContext &context)
{ {

View File

@@ -48,17 +48,17 @@ public:
QList<LookupItem> resolveMemberExpression(const QList<LookupItem> &baseResults, QList<LookupItem> resolveMemberExpression(const QList<LookupItem> &baseResults,
unsigned accessOp, unsigned accessOp,
Name *memberName, const Name *memberName,
bool *replacedDotOperator = 0) const; bool *replacedDotOperator = 0) const;
QList<LookupItem> resolveBaseExpression(const QList<LookupItem> &baseResults, QList<LookupItem> resolveBaseExpression(const QList<LookupItem> &baseResults,
int accessOp, int accessOp,
bool *replacedDotOperator = 0) const; bool *replacedDotOperator = 0) const;
QList<LookupItem> resolveMember(Name *memberName, Class *klass, QList<LookupItem> resolveMember(const Name *memberName, Class *klass,
Name *className = 0) const; const Name *className = 0) const;
QList<LookupItem> resolveMember(Name *memberName, ObjCClass *klass) const; QList<LookupItem> resolveMember(const Name *memberName, ObjCClass *klass) const;
protected: protected:
QList<LookupItem> switchResults(const QList<LookupItem> &symbols); QList<LookupItem> switchResults(const QList<LookupItem> &symbols);
@@ -125,12 +125,12 @@ class CPLUSPLUS_EXPORT ResolveClass
public: public:
ResolveClass(); ResolveClass();
QList<Symbol *> operator()(Name *name, QList<Symbol *> operator()(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context); const LookupContext &context);
private: private:
QList<Symbol *> resolveClass(Name *name, QList<Symbol *> resolveClass(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context); const LookupContext &context);
@@ -143,7 +143,7 @@ class CPLUSPLUS_EXPORT ResolveObjCClass
public: public:
ResolveObjCClass(); ResolveObjCClass();
QList<Symbol *> operator()(Name *name, QList<Symbol *> operator()(const Name *name,
const LookupItem &p, const LookupItem &p,
const LookupContext &context); const LookupContext &context);
}; };

View File

@@ -327,7 +327,7 @@ void TypePrettyPrinter::visit(Function *type)
if (index + 1 == _overview->markedArgument()) if (index + 1 == _overview->markedArgument())
const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length()); const_cast<Overview*>(_overview)->setMarkedArgumentBegin(_text.length());
Name *name = 0; const Name *name = 0;
if (_overview->showArgumentNames()) if (_overview->showArgumentNames())
name = arg->name(); name = arg->name();

View File

@@ -477,7 +477,7 @@ protected:
class FindFunctionDefinitions: protected SymbolVisitor class FindFunctionDefinitions: protected SymbolVisitor
{ {
Name *_declarationName; const Name *_declarationName;
QList<Function *> *_functions; QList<Function *> *_functions;
public: public:
@@ -486,7 +486,7 @@ public:
_functions(0) _functions(0)
{ } { }
void operator()(Name *declarationName, Scope *globals, void operator()(const Name *declarationName, Scope *globals,
QList<Function *> *functions) QList<Function *> *functions)
{ {
_declarationName = declarationName; _declarationName = declarationName;
@@ -502,8 +502,8 @@ protected:
virtual bool visit(Function *function) virtual bool visit(Function *function)
{ {
Name *name = function->name(); const Name *name = function->name();
if (QualifiedNameId *q = name->asQualifiedNameId()) if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId(); name = q->unqualifiedNameId();
if (_declarationName->isEqualTo(name)) if (_declarationName->isEqualTo(name))
@@ -515,19 +515,19 @@ protected:
} // end of anonymous namespace } // end of anonymous namespace
static QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &context) static const QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext &context)
{ {
Name *symbolName = s->name(); const Name *symbolName = s->name();
if (! symbolName) if (! symbolName)
return 0; // nothing to do. return 0; // nothing to do.
QVector<Name *> names; QVector<const Name *> names;
for (Scope *scope = s->scope(); scope; scope = scope->enclosingScope()) { for (Scope *scope = s->scope(); scope; scope = scope->enclosingScope()) {
if (scope->isClassScope() || scope->isNamespaceScope()) { if (scope->isClassScope() || scope->isNamespaceScope()) {
if (scope->owner() && scope->owner()->name()) { if (scope->owner() && scope->owner()->name()) {
Name *ownerName = scope->owner()->name(); const Name *ownerName = scope->owner()->name();
if (QualifiedNameId *q = ownerName->asQualifiedNameId()) { if (const QualifiedNameId *q = ownerName->asQualifiedNameId()) {
for (unsigned i = 0; i < q->nameCount(); ++i) { for (unsigned i = 0; i < q->nameCount(); ++i) {
names.prepend(q->nameAt(i)); names.prepend(q->nameAt(i));
} }
@@ -538,7 +538,7 @@ static QualifiedNameId *qualifiedNameIdForSymbol(Symbol *s, const LookupContext
} }
} }
if (QualifiedNameId *q = symbolName->asQualifiedNameId()) { if (const QualifiedNameId *q = symbolName->asQualifiedNameId()) {
for (unsigned i = 0; i < q->nameCount(); ++i) { for (unsigned i = 0; i < q->nameCount(); ++i) {
names.append(q->nameAt(i)); names.append(q->nameAt(i));
} }
@@ -1021,27 +1021,28 @@ void CPPEditor::updateUsesNow()
semanticRehighlight(); semanticRehighlight();
} }
static bool isCompatible(Name *name, Name *otherName) static bool isCompatible(const Name *name, const Name *otherName)
{ {
if (NameId *nameId = name->asNameId()) { if (const NameId *nameId = name->asNameId()) {
if (TemplateNameId *otherTemplId = otherName->asTemplateNameId()) if (const TemplateNameId *otherTemplId = otherName->asTemplateNameId())
return nameId->identifier()->isEqualTo(otherTemplId->identifier()); return nameId->identifier()->isEqualTo(otherTemplId->identifier());
} else if (TemplateNameId *templId = name->asTemplateNameId()) { } else if (const TemplateNameId *templId = name->asTemplateNameId()) {
if (NameId *otherNameId = otherName->asNameId()) if (const NameId *otherNameId = otherName->asNameId())
return templId->identifier()->isEqualTo(otherNameId->identifier()); return templId->identifier()->isEqualTo(otherNameId->identifier());
} }
return name->isEqualTo(otherName); return name->isEqualTo(otherName);
} }
static bool isCompatible(Function *definition, Symbol *declaration, QualifiedNameId *declarationName) static bool isCompatible(Function *definition, Symbol *declaration,
const QualifiedNameId *declarationName)
{ {
Function *declTy = declaration->type()->asFunctionType(); Function *declTy = declaration->type()->asFunctionType();
if (! declTy) if (! declTy)
return false; return false;
Name *definitionName = definition->name(); const Name *definitionName = definition->name();
if (QualifiedNameId *q = definitionName->asQualifiedNameId()) { if (const QualifiedNameId *q = definitionName->asQualifiedNameId()) {
if (! isCompatible(q->unqualifiedNameId(), declaration->name())) if (! isCompatible(q->unqualifiedNameId(), declaration->name()))
return false; return false;
else if (q->nameCount() > declarationName->nameCount()) else if (q->nameCount() > declarationName->nameCount())
@@ -1061,8 +1062,8 @@ static bool isCompatible(Function *definition, Symbol *declaration, QualifiedNam
} }
for (unsigned i = 0; i != q->nameCount(); ++i) { for (unsigned i = 0; i != q->nameCount(); ++i) {
Name *n = q->nameAt(q->nameCount() - i - 1); const Name *n = q->nameAt(q->nameCount() - i - 1);
Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); const Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1);
if (! isCompatible(n, m)) if (! isCompatible(n, m))
return false; return false;
} }
@@ -1105,7 +1106,7 @@ void CPPEditor::switchDeclarationDefinition()
QList<LookupItem> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol); QList<LookupItem> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol);
const LookupContext &context = typeOfExpression.lookupContext(); const LookupContext &context = typeOfExpression.lookupContext();
QualifiedNameId *q = qualifiedNameIdForSymbol(f, context); const QualifiedNameId *q = qualifiedNameIdForSymbol(f, context);
QList<Symbol *> symbols = context.resolve(q); QList<Symbol *> symbols = context.resolve(q);
Symbol *declaration = 0; Symbol *declaration = 0;
@@ -1278,11 +1279,11 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
if (! funTy) if (! funTy)
return 0; // symbol does not have function type. return 0; // symbol does not have function type.
Name *name = symbol->name(); const Name *name = symbol->name();
if (! name) if (! name)
return 0; // skip anonymous functions! return 0; // skip anonymous functions!
if (QualifiedNameId *q = name->asQualifiedNameId()) if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId(); name = q->unqualifiedNameId();
// map from file names to function definitions. // map from file names to function definitions.

View File

@@ -138,7 +138,7 @@ void CppHoverHandler::showToolTip(TextEditor::ITextEditor *editor, const QPoint
} }
} }
static QString buildHelpId(Symbol *symbol, Name *name) static QString buildHelpId(Symbol *symbol, const Name *name)
{ {
Scope *scope = 0; Scope *scope = 0;
@@ -161,13 +161,13 @@ static QString buildHelpId(Symbol *symbol, Name *name)
Symbol *owner = scope->owner(); Symbol *owner = scope->owner();
if (owner && owner->name() && ! scope->isEnumScope()) { if (owner && owner->name() && ! scope->isEnumScope()) {
Name *name = owner->name(); const Name *name = owner->name();
const Identifier *id = 0; const Identifier *id = 0;
if (NameId *nameId = name->asNameId()) if (const NameId *nameId = name->asNameId())
id = nameId->identifier(); id = nameId->identifier();
else if (TemplateNameId *nameId = name->asTemplateNameId()) else if (const TemplateNameId *nameId = name->asTemplateNameId())
id = nameId->identifier(); id = nameId->identifier();
if (id) if (id)
@@ -182,7 +182,7 @@ static QString buildHelpId(Symbol *symbol, Name *name)
static FullySpecifiedType resolve(const FullySpecifiedType &ty, static FullySpecifiedType resolve(const FullySpecifiedType &ty,
const LookupContext &context, const LookupContext &context,
Symbol **resolvedSymbol, Symbol **resolvedSymbol,
Name **resolvedName) const Name **resolvedName)
{ {
Control *control = context.control(); Control *control = context.control();
@@ -334,7 +334,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
Symbol *lookupSymbol = result.lastVisibleSymbol(); // lookup symbol Symbol *lookupSymbol = result.lastVisibleSymbol(); // lookup symbol
Symbol *resolvedSymbol = lookupSymbol; Symbol *resolvedSymbol = lookupSymbol;
Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0; const Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0;
firstType = resolve(firstType, typeOfExpression.lookupContext(), firstType = resolve(firstType, typeOfExpression.lookupContext(),
&resolvedSymbol, &resolvedName); &resolvedSymbol, &resolvedName);

View File

@@ -192,7 +192,7 @@ protected:
return previousItem; return previousItem;
} }
TextEditor::CompletionItem newCompletionItem(Name *name) TextEditor::CompletionItem newCompletionItem(const Name *name)
{ {
TextEditor::CompletionItem item(_collector); TextEditor::CompletionItem item(_collector);
item.text = overview.prettyName(name); item.text = overview.prettyName(name);
@@ -200,25 +200,25 @@ protected:
return item; return item;
} }
virtual void visit(NameId *name) virtual void visit(const NameId *name)
{ _item = newCompletionItem(name); } { _item = newCompletionItem(name); }
virtual void visit(TemplateNameId *name) virtual void visit(const TemplateNameId *name)
{ {
_item = newCompletionItem(name); _item = newCompletionItem(name);
_item.text = QLatin1String(name->identifier()->chars()); _item.text = QLatin1String(name->identifier()->chars());
} }
virtual void visit(DestructorNameId *name) virtual void visit(const DestructorNameId *name)
{ _item = newCompletionItem(name); } { _item = newCompletionItem(name); }
virtual void visit(OperatorNameId *name) virtual void visit(const OperatorNameId *name)
{ _item = newCompletionItem(name); } { _item = newCompletionItem(name); }
virtual void visit(ConversionNameId *name) virtual void visit(const ConversionNameId *name)
{ _item = newCompletionItem(name); } { _item = newCompletionItem(name); }
virtual void visit(QualifiedNameId *name) virtual void visit(const QualifiedNameId *name)
{ _item = newCompletionItem(name->unqualifiedNameId()); } { _item = newCompletionItem(name->unqualifiedNameId()); }
}; };
@@ -890,13 +890,13 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r
FullySpecifiedType exprTy = result.type().simplified(); FullySpecifiedType exprTy = result.type().simplified();
if (Class *klass = exprTy->asClassType()) { if (Class *klass = exprTy->asClassType()) {
Name *className = klass->name(); const Name *className = klass->name();
if (! className) if (! className)
continue; // nothing to do for anonymoous classes. continue; // nothing to do for anonymoous classes.
for (unsigned i = 0; i < klass->memberCount(); ++i) { for (unsigned i = 0; i < klass->memberCount(); ++i) {
Symbol *member = klass->memberAt(i); Symbol *member = klass->memberAt(i);
Name *memberName = member->name(); const Name *memberName = member->name();
if (! memberName) if (! memberName)
continue; // skip anonymous member. continue; // skip anonymous member.
@@ -945,7 +945,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r
if (functions.isEmpty()) { if (functions.isEmpty()) {
ResolveExpression resolveExpression(context); ResolveExpression resolveExpression(context);
ResolveClass resolveClass; ResolveClass resolveClass;
Name *functionCallOp = context.control()->operatorNameId(OperatorNameId::FunctionCallOp); const Name *functionCallOp = context.control()->operatorNameId(OperatorNameId::FunctionCallOp);
foreach (const LookupItem &result, results) { foreach (const LookupItem &result, results) {
FullySpecifiedType ty = result.type().simplified(); FullySpecifiedType ty = result.type().simplified();
@@ -1092,7 +1092,7 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults,
classObjectCandidates.append(klass); classObjectCandidates.append(klass);
else if (NamedType *namedTy = ty->asNamedType()) { else if (NamedType *namedTy = ty->asNamedType()) {
Name *className = namedTy->name(); const Name *className = namedTy->name();
const QList<Symbol *> classes = resolveClass(className, r, context); const QList<Symbol *> classes = resolveClass(className, r, context);
foreach (Symbol *c, classes) { foreach (Symbol *c, classes) {

View File

@@ -95,8 +95,8 @@ bool SearchSymbols::visit(Function *symbol)
return false; return false;
QString extraScope; QString extraScope;
if (Name *name = symbol->name()) { if (const Name *name = symbol->name()) {
if (QualifiedNameId *nameId = name->asQualifiedNameId()) { if (const QualifiedNameId *nameId = name->asQualifiedNameId()) {
if (nameId->nameCount() > 1) { if (nameId->nameCount() > 1) {
extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2)); extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2));
} }

View File

@@ -251,8 +251,8 @@ static bool isCompatible(const Function *definition, const Symbol *declaration,
if (! declTy) if (! declTy)
return false; return false;
Name *definitionName = definition->name(); const Name *definitionName = definition->name();
if (QualifiedNameId *q = definitionName->asQualifiedNameId()) { if (const QualifiedNameId *q = definitionName->asQualifiedNameId()) {
if (! isCompatible(q->unqualifiedNameId(), declaration->name())) if (! isCompatible(q->unqualifiedNameId(), declaration->name()))
return false; return false;
else if (q->nameCount() > declarationName->nameCount()) else if (q->nameCount() > declarationName->nameCount())
@@ -272,8 +272,8 @@ static bool isCompatible(const Function *definition, const Symbol *declaration,
} }
for (unsigned i = 0; i != q->nameCount(); ++i) { for (unsigned i = 0; i != q->nameCount(); ++i) {
Name *n = q->nameAt(q->nameCount() - i - 1); const Name *n = q->nameAt(q->nameCount() - i - 1);
Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1); const Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1);
if (! isCompatible(n, m)) if (! isCompatible(n, m))
return false; return false;
} }
@@ -291,13 +291,13 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li
if (!cppModelManager) if (!cppModelManager)
return Document::Ptr(); return Document::Ptr();
QVector<Name *> qualifiedName; QVector<const Name *> qualifiedName;
Scope *scope = functionDeclaration->scope(); Scope *scope = functionDeclaration->scope();
for (; scope; scope = scope->enclosingScope()) { for (; scope; scope = scope->enclosingScope()) {
if (scope->isClassScope() || scope->isNamespaceScope()) { if (scope->isClassScope() || scope->isNamespaceScope()) {
if (scope->owner() && scope->owner()->name()) { if (scope->owner() && scope->owner()->name()) {
Name *scopeOwnerName = scope->owner()->name(); const Name *scopeOwnerName = scope->owner()->name();
if (QualifiedNameId *q = scopeOwnerName->asQualifiedNameId()) { if (const QualifiedNameId *q = scopeOwnerName->asQualifiedNameId()) {
for (unsigned i = 0; i < q->nameCount(); ++i) { for (unsigned i = 0; i < q->nameCount(); ++i) {
qualifiedName.prepend(q->nameAt(i)); qualifiedName.prepend(q->nameAt(i));
@@ -312,7 +312,7 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li
qualifiedName.append(functionDeclaration->name()); qualifiedName.append(functionDeclaration->name());
Control control; Control control;
QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size()); const QualifiedNameId *q = control.qualifiedNameId(&qualifiedName[0], qualifiedName.size());
LookupContext context(&control); LookupContext context(&control);
const Snapshot documents = cppModelManager->snapshot(); const Snapshot documents = cppModelManager->snapshot();
foreach (Document::Ptr doc, documents) { foreach (Document::Ptr doc, documents) {
@@ -321,13 +321,13 @@ static Document::Ptr findDefinition(const Function *functionDeclaration, int *li
visibleScopes = context.expand(visibleScopes); visibleScopes = context.expand(visibleScopes);
foreach (Scope *visibleScope, visibleScopes) { foreach (Scope *visibleScope, visibleScopes) {
Symbol *symbol = 0; Symbol *symbol = 0;
if (NameId *nameId = q->unqualifiedNameId()->asNameId()) if (const NameId *nameId = q->unqualifiedNameId()->asNameId())
symbol = visibleScope->lookat(nameId->identifier()); symbol = visibleScope->lookat(nameId->identifier());
else if (DestructorNameId *dtorId = q->unqualifiedNameId()->asDestructorNameId()) else if (const DestructorNameId *dtorId = q->unqualifiedNameId()->asDestructorNameId())
symbol = visibleScope->lookat(dtorId->identifier()); symbol = visibleScope->lookat(dtorId->identifier());
else if (TemplateNameId *templNameId = q->unqualifiedNameId()->asTemplateNameId()) else if (const TemplateNameId *templNameId = q->unqualifiedNameId()->asTemplateNameId())
symbol = visibleScope->lookat(templNameId->identifier()); symbol = visibleScope->lookat(templNameId->identifier());
else if (OperatorNameId *opId = q->unqualifiedNameId()->asOperatorNameId()) else if (const OperatorNameId *opId = q->unqualifiedNameId()->asOperatorNameId())
symbol = visibleScope->lookat(opId->kind()); symbol = visibleScope->lookat(opId->kind());
// ### cast operators // ### cast operators
for (; symbol; symbol = symbol->next()) { for (; symbol; symbol = symbol->next()) {

View File

@@ -303,7 +303,7 @@ public:
class CPLUSPLUS_EXPORT NameAST: public ExpressionAST class CPLUSPLUS_EXPORT NameAST: public ExpressionAST
{ {
public: // annotations public: // annotations
Name *name; const Name *name;
public: public:
virtual NameAST *asName() { return this; } virtual NameAST *asName() { return this; }
@@ -342,7 +342,7 @@ public:
class CPLUSPLUS_EXPORT ObjCSelectorAST: public AST class CPLUSPLUS_EXPORT ObjCSelectorAST: public AST
{ {
public: // annotation public: // annotation
Name *selector_name; const Name *selector_name;
public: public:
virtual ObjCSelectorAST *asObjCSelector() { return this; } virtual ObjCSelectorAST *asObjCSelector() { return this; }

View File

@@ -153,7 +153,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
if (elab_type_spec->name) if (elab_type_spec->name)
sourceLocation = elab_type_spec->name->firstToken(); sourceLocation = elab_type_spec->name->firstToken();
Name *name = semantic()->check(elab_type_spec->name, _scope); const Name *name = semantic()->check(elab_type_spec->name, _scope);
ForwardClassDeclaration *symbol = ForwardClassDeclaration *symbol =
control()->newForwardClassDeclaration(sourceLocation, name); control()->newForwardClassDeclaration(sourceLocation, name);
@@ -172,7 +172,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
List<Declaration *> **decl_it = &ast->symbols; List<Declaration *> **decl_it = &ast->symbols;
for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) { for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) {
Name *name = 0; const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(it->value, qualTy, FullySpecifiedType declTy = semantic()->check(it->value, qualTy,
_scope, &name); _scope, &name);
@@ -268,7 +268,7 @@ bool CheckDeclaration::visit(ExceptionDeclarationAST *ast)
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
FullySpecifiedType qualTy = ty.qualifiedType(); FullySpecifiedType qualTy = ty.qualifiedType();
Name *name = 0; const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(ast->declarator, qualTy, FullySpecifiedType declTy = semantic()->check(ast->declarator, qualTy,
_scope, &name); _scope, &name);
@@ -293,7 +293,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
{ {
FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope); FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope);
FullySpecifiedType qualTy = ty.qualifiedType(); FullySpecifiedType qualTy = ty.qualifiedType();
Name *name = 0; const Name *name = 0;
FullySpecifiedType funTy = semantic()->check(ast->declarator, qualTy, FullySpecifiedType funTy = semantic()->check(ast->declarator, qualTy,
_scope, &name); _scope, &name);
if (! (funTy && funTy->isFunctionType())) { if (! (funTy && funTy->isFunctionType())) {
@@ -379,7 +379,7 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
bool CheckDeclaration::visit(NamespaceAST *ast) bool CheckDeclaration::visit(NamespaceAST *ast)
{ {
const Identifier *id = identifier(ast->identifier_token); const Identifier *id = identifier(ast->identifier_token);
Name *namespaceName = control()->nameId(id); const Name *namespaceName = control()->nameId(id);
unsigned sourceLocation = ast->firstToken(); unsigned sourceLocation = ast->firstToken();
@@ -411,7 +411,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
sourceLocation = ast->firstToken(); sourceLocation = ast->firstToken();
} }
Name *argName = 0; const Name *argName = 0;
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(), FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(),
_scope, &argName); _scope, &argName);
@@ -445,7 +445,7 @@ bool CheckDeclaration::visit(TypenameTypeParameterAST *ast)
if (ast->name) if (ast->name)
sourceLocation = ast->name->firstToken(); sourceLocation = ast->name->firstToken();
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type
ast->symbol = arg; ast->symbol = arg;
_scope->enterSymbol(arg); _scope->enterSymbol(arg);
@@ -458,7 +458,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
if (ast->name) if (ast->name)
sourceLocation = ast->name->firstToken(); sourceLocation = ast->name->firstToken();
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type
ast->symbol = arg; ast->symbol = arg;
_scope->enterSymbol(arg); _scope->enterSymbol(arg);
@@ -467,7 +467,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
bool CheckDeclaration::visit(UsingAST *ast) bool CheckDeclaration::visit(UsingAST *ast)
{ {
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
unsigned sourceLocation = ast->firstToken(); unsigned sourceLocation = ast->firstToken();
if (ast->name) if (ast->name)
@@ -481,7 +481,7 @@ bool CheckDeclaration::visit(UsingAST *ast)
bool CheckDeclaration::visit(UsingDirectiveAST *ast) bool CheckDeclaration::visit(UsingDirectiveAST *ast)
{ {
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
unsigned sourceLocation = ast->firstToken(); unsigned sourceLocation = ast->firstToken();
if (ast->name) if (ast->name)
@@ -510,7 +510,7 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
else else
declarationLocation = sourceLocation; declarationLocation = sourceLocation;
Name *protocolName = semantic()->check(it->value, _scope); const Name *protocolName = semantic()->check(it->value, _scope);
ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName); ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName);
fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset); fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset); fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -533,7 +533,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
else else
sourceLocation = ast->firstToken(); sourceLocation = ast->firstToken();
Name *protocolName = semantic()->check(ast->name, _scope); const Name *protocolName = semantic()->check(ast->name, _scope);
ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, protocolName); ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, protocolName);
protocol->setStartOffset(tokenAt(ast->firstToken()).offset); protocol->setStartOffset(tokenAt(ast->firstToken()).offset);
protocol->setEndOffset(tokenAt(ast->lastToken()).offset); protocol->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -541,7 +541,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
if (ast->protocol_refs && ast->protocol_refs->identifier_list) { if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value; NameAST* name = iter->value;
Name *protocolName = semantic()->check(name, _scope); const Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
protocol->addProtocol(baseProtocol); protocol->addProtocol(baseProtocol);
} }
@@ -571,7 +571,7 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
else else
declarationLocation = sourceLocation; declarationLocation = sourceLocation;
Name *className = semantic()->check(it->value, _scope); const Name *className = semantic()->check(it->value, _scope);
ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className); ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className);
fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset); fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset); fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -594,7 +594,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
else else
sourceLocation = ast->firstToken(); sourceLocation = ast->firstToken();
Name *className = semantic()->check(ast->class_name, _scope); const Name *className = semantic()->check(ast->class_name, _scope);
ObjCClass *klass = control()->newObjCClass(sourceLocation, className); ObjCClass *klass = control()->newObjCClass(sourceLocation, className);
klass->setStartOffset(tokenAt(ast->firstToken()).offset); klass->setStartOffset(tokenAt(ast->firstToken()).offset);
klass->setEndOffset(tokenAt(ast->lastToken()).offset); klass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -603,12 +603,12 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
klass->setInterface(ast->interface_token != 0); klass->setInterface(ast->interface_token != 0);
if (ast->category_name) { if (ast->category_name) {
Name *categoryName = semantic()->check(ast->category_name, _scope); const Name *categoryName = semantic()->check(ast->category_name, _scope);
klass->setCategoryName(categoryName); klass->setCategoryName(categoryName);
} }
if (ast->superclass) { if (ast->superclass) {
Name *superClassName = semantic()->check(ast->superclass, _scope); const Name *superClassName = semantic()->check(ast->superclass, _scope);
ObjCBaseClass *superKlass = control()->newObjCBaseClass(ast->superclass->firstToken(), superClassName); ObjCBaseClass *superKlass = control()->newObjCBaseClass(ast->superclass->firstToken(), superClassName);
klass->setBaseClass(superKlass); klass->setBaseClass(superKlass);
} }
@@ -616,7 +616,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
if (ast->protocol_refs && ast->protocol_refs->identifier_list) { if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value; NameAST* name = iter->value;
Name *protocolName = semantic()->check(name, _scope); const Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
klass->addProtocol(baseProtocol); klass->addProtocol(baseProtocol);
} }
@@ -711,7 +711,7 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
} }
int propAttrs = ObjCPropertyDeclaration::None; int propAttrs = ObjCPropertyDeclaration::None;
Name *getterName = 0, *setterName = 0; const Name *getterName = 0, *setterName = 0;
for (ObjCPropertyAttributeListAST *iter= ast->property_attribute_list; iter; iter = iter->next) { for (ObjCPropertyAttributeListAST *iter= ast->property_attribute_list; iter; iter = iter->next) {
ObjCPropertyAttributeAST *attrAst = iter->value; ObjCPropertyAttributeAST *attrAst = iter->value;

View File

@@ -70,12 +70,12 @@ CheckDeclarator::~CheckDeclarator()
FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator, FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
const FullySpecifiedType &type, const FullySpecifiedType &type,
Scope *scope, Scope *scope,
Name **name) const Name **name)
{ {
FullySpecifiedType previousType = switchFullySpecifiedType(type); FullySpecifiedType previousType = switchFullySpecifiedType(type);
Scope *previousScope = switchScope(scope); Scope *previousScope = switchScope(scope);
DeclaratorAST *previousDeclarator = switchDeclarator(declarator); DeclaratorAST *previousDeclarator = switchDeclarator(declarator);
Name **previousName = switchName(name); const Name **previousName = switchName(name);
accept(declarator); accept(declarator);
(void) switchName(previousName); (void) switchName(previousName);
(void) switchDeclarator(previousDeclarator); (void) switchDeclarator(previousDeclarator);
@@ -124,9 +124,9 @@ Scope *CheckDeclarator::switchScope(Scope *scope)
return previousScope; return previousScope;
} }
Name **CheckDeclarator::switchName(Name **name) const Name **CheckDeclarator::switchName(const Name **name)
{ {
Name **previousName = _name; const Name **previousName = _name;
_name = name; _name = name;
return previousName; return previousName;
} }
@@ -149,7 +149,7 @@ bool CheckDeclarator::visit(DeclaratorAST *ast)
bool CheckDeclarator::visit(DeclaratorIdAST *ast) bool CheckDeclarator::visit(DeclaratorIdAST *ast)
{ {
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
if (_name) if (_name)
*_name = name; *_name = name;
return false; return false;
@@ -219,7 +219,7 @@ bool CheckDeclarator::visit(ArrayDeclaratorAST *ast)
bool CheckDeclarator::visit(PointerToMemberAST *ast) bool CheckDeclarator::visit(PointerToMemberAST *ast)
{ {
Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope); const Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope);
PointerToMemberType *ptrTy = control()->pointerToMemberType(memberName, _fullySpecifiedType); PointerToMemberType *ptrTy = control()->pointerToMemberType(memberName, _fullySpecifiedType);
FullySpecifiedType ty(ptrTy); FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty; _fullySpecifiedType = ty;

View File

@@ -65,7 +65,7 @@ public:
FullySpecifiedType check(DeclaratorAST *declarator, FullySpecifiedType check(DeclaratorAST *declarator,
const FullySpecifiedType &type, const FullySpecifiedType &type,
Scope *scope, Scope *scope,
Name **name); const Name **name);
FullySpecifiedType check(PtrOperatorListAST *ptrOperators, FullySpecifiedType check(PtrOperatorListAST *ptrOperators,
const FullySpecifiedType &type, const FullySpecifiedType &type,
@@ -78,7 +78,7 @@ protected:
DeclaratorAST *switchDeclarator(DeclaratorAST *declarator); DeclaratorAST *switchDeclarator(DeclaratorAST *declarator);
FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type); FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
Scope *switchScope(Scope *scope); Scope *switchScope(Scope *scope);
Name **switchName(Name **name); const Name **switchName(const Name **name);
using ASTVisitor::visit; using ASTVisitor::visit;
@@ -102,7 +102,7 @@ protected:
private: private:
DeclaratorAST *_declarator; DeclaratorAST *_declarator;
Scope *_scope; Scope *_scope;
Name **_name; const Name **_name;
FullySpecifiedType _fullySpecifiedType; FullySpecifiedType _fullySpecifiedType;
}; };

View File

@@ -120,7 +120,7 @@ bool CheckExpression::visit(CastExpressionAST *ast)
bool CheckExpression::visit(ConditionAST *ast) bool CheckExpression::visit(ConditionAST *ast)
{ {
FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
Name *name = 0; const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(),
_scope, &name); _scope, &name);
Declaration *decl = control()->newDeclaration(ast->declarator->firstToken(), name); Declaration *decl = control()->newDeclaration(ast->declarator->firstToken(), name);
@@ -302,8 +302,7 @@ bool CheckExpression::visit(ThrowExpressionAST *ast)
bool CheckExpression::visit(TypeIdAST *ast) bool CheckExpression::visit(TypeIdAST *ast)
{ {
FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), _scope);
_scope);
_fullySpecifiedType = declTy; _fullySpecifiedType = declTy;
return false; return false;
} }
@@ -316,7 +315,7 @@ bool CheckExpression::visit(UnaryExpressionAST *ast)
bool CheckExpression::visit(QtMethodAST *ast) bool CheckExpression::visit(QtMethodAST *ast)
{ {
Name *name = 0; const Name *name = 0;
Scope dummy; Scope dummy;
FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(), FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(),
&dummy, &name); &dummy, &name);

View File

@@ -69,9 +69,9 @@ CheckName::CheckName(Semantic *semantic)
CheckName::~CheckName() CheckName::~CheckName()
{ } { }
Name *CheckName::check(NameAST *name, Scope *scope) const Name *CheckName::check(NameAST *name, Scope *scope)
{ {
Name *previousName = switchName(0); const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope); Scope *previousScope = switchScope(scope);
accept(name); accept(name);
@@ -82,12 +82,12 @@ Name *CheckName::check(NameAST *name, Scope *scope)
return switchName(previousName); return switchName(previousName);
} }
Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope) const Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope)
{ {
Name *previousName = switchName(0); const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope); Scope *previousScope = switchScope(scope);
std::vector<Name *> names; std::vector<const Name *> names;
for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) { for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value; NestedNameSpecifierAST *nested_name_specifier = it->value;
names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope)); names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope));
@@ -100,9 +100,9 @@ Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, S
return switchName(previousName); return switchName(previousName);
} }
Name *CheckName::check(ObjCSelectorAST *args, Scope *scope) const Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
{ {
Name *previousName = switchName(0); const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope); Scope *previousScope = switchScope(scope);
accept(args); accept(args);
@@ -113,7 +113,7 @@ Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope) void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
{ {
Name *previousName = switchName(0); const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope); Scope *previousScope = switchScope(scope);
accept(arg); accept(arg);
@@ -122,9 +122,9 @@ void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
(void) switchName(previousName); (void) switchName(previousName);
} }
Name *CheckName::switchName(Name *name) const Name *CheckName::switchName(const Name *name)
{ {
Name *previousName = _name; const Name *previousName = _name;
_name = name; _name = name;
return previousName; return previousName;
} }
@@ -138,14 +138,13 @@ Scope *CheckName::switchScope(Scope *scope)
bool CheckName::visit(QualifiedNameAST *ast) bool CheckName::visit(QualifiedNameAST *ast)
{ {
std::vector<Name *> names; std::vector<const Name *> names;
for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) { for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value; NestedNameSpecifierAST *nested_name_specifier = it->value;
names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope)); names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope));
} }
names.push_back(semantic()->check(ast->unqualified_name, _scope)); names.push_back(semantic()->check(ast->unqualified_name, _scope));
_name = control()->qualifiedNameId(&names[0], names.size(), _name = control()->qualifiedNameId(&names[0], names.size(), ast->global_scope_token != 0);
ast->global_scope_token != 0);
ast->name = _name; ast->name = _name;
return false; return false;
@@ -379,9 +378,9 @@ bool CheckName::visit(TemplateIdAST *ast)
bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast) bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
{ {
if (ast->name_token) { if (ast->name_token) {
std::vector<Name *> names; std::vector<const Name *> names;
const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token)); const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
NameId *nameId = control()->nameId(id); const NameId *nameId = control()->nameId(id);
names.push_back(nameId); names.push_back(nameId);
_name = control()->selectorNameId(&names[0], names.size(), false); _name = control()->selectorNameId(&names[0], names.size(), false);
ast->selector_name = _name; ast->selector_name = _name;
@@ -392,11 +391,11 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast) bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
{ {
std::vector<Name *> names; std::vector<const Name *> names;
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) { for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
if (it->value->name_token) { if (it->value->name_token) {
const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token)); const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
NameId *nameId = control()->nameId(id); const NameId *nameId = control()->nameId(id);
names.push_back(nameId); names.push_back(nameId);
} else { } else {
// we have an incomplete name due, probably due to error recovery. So, back out completely // we have an incomplete name due, probably due to error recovery. So, back out completely

View File

@@ -61,13 +61,13 @@ public:
CheckName(Semantic *semantic); CheckName(Semantic *semantic);
virtual ~CheckName(); virtual ~CheckName();
Name *check(NameAST *name, Scope *scope); const Name *check(NameAST *name, Scope *scope);
Name *check(NestedNameSpecifierListAST *name, Scope *scope); const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
Name *check(ObjCSelectorAST *args, Scope *scope); const Name *check(ObjCSelectorAST *args, Scope *scope);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope); void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
protected: protected:
Name *switchName(Name *name); const Name *switchName(const Name *name);
Scope *switchScope(Scope *scope); Scope *switchScope(Scope *scope);
using ASTVisitor::visit; using ASTVisitor::visit;
@@ -85,7 +85,7 @@ protected:
virtual bool visit(ObjCMessageArgumentDeclarationAST *ast); virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
private: private:
Name *_name; const Name *_name;
Scope *_scope; Scope *_scope;
}; };

View File

@@ -312,7 +312,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
if (ast->name) if (ast->name)
sourceLocation = ast->name->firstToken(); sourceLocation = ast->name->firstToken();
Name *className = semantic()->check(ast->name, _scope); const Name *className = semantic()->check(ast->name, _scope);
Class *klass = control()->newClass(sourceLocation, className); Class *klass = control()->newClass(sourceLocation, className);
klass->setStartOffset(tokenAt(ast->firstToken()).offset); klass->setStartOffset(tokenAt(ast->firstToken()).offset);
klass->setEndOffset(tokenAt(ast->lastToken()).offset); klass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -330,7 +330,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) { for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
BaseSpecifierAST *base = it->value; BaseSpecifierAST *base = it->value;
Name *baseClassName = semantic()->check(base->name, _scope); const Name *baseClassName = semantic()->check(base->name, _scope);
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName); BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
base->symbol = baseClass; base->symbol = baseClass;
if (base->virtual_token) if (base->virtual_token)
@@ -359,14 +359,14 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast) bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast)
{ {
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name)); _fullySpecifiedType.setType(control()->namedType(name));
return false; return false;
} }
bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast) bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast)
{ {
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name)); _fullySpecifiedType.setType(control()->namedType(name));
return false; return false;
} }
@@ -377,7 +377,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
if (ast->name) if (ast->name)
sourceLocation = ast->name->firstToken(); sourceLocation = ast->name->firstToken();
Name *name = semantic()->check(ast->name, _scope); const Name *name = semantic()->check(ast->name, _scope);
Enum *e = control()->newEnum(sourceLocation, name); Enum *e = control()->newEnum(sourceLocation, name);
e->setStartOffset(tokenAt(ast->firstToken()).offset); e->setStartOffset(tokenAt(ast->firstToken()).offset);
e->setEndOffset(tokenAt(ast->lastToken()).offset); e->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -389,7 +389,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
const Identifier *id = identifier(enumerator->identifier_token); const Identifier *id = identifier(enumerator->identifier_token);
if (! id) if (! id)
continue; continue;
NameId *enumeratorName = control()->nameId(id); const NameId *enumeratorName = control()->nameId(id);
Declaration *decl = control()->newDeclaration(enumerator->firstToken(), Declaration *decl = control()->newDeclaration(enumerator->firstToken(),
enumeratorName); enumeratorName);
e->addMember(decl); e->addMember(decl);

View File

@@ -154,7 +154,7 @@ bool CheckStatement::visit(ForeachStatementAST *ast)
Scope *previousScope = switchScope(block->members()); Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) { if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
Name *name = 0; const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name); ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken(); unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator) if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -183,7 +183,7 @@ bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
Scope *previousScope = switchScope(block->members()); Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) { if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope); FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
Name *name = 0; const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name); ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken(); unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator) if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -312,7 +312,7 @@ bool CheckStatement::visit(WhileStatementAST *ast)
bool CheckStatement::visit(QtMemberDeclarationAST *ast) bool CheckStatement::visit(QtMemberDeclarationAST *ast)
{ {
Name *name = 0; const Name *name = 0;
if (tokenKind(ast->q_token) == T_Q_D) if (tokenKind(ast->q_token) == T_Q_D)
name = control()->nameId(control()->findOrInsertIdentifier("d")); name = control()->nameId(control()->findOrInsertIdentifier("d"));
@@ -323,12 +323,13 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
if (tokenKind(ast->q_token) == T_Q_D) { if (tokenKind(ast->q_token) == T_Q_D) {
if (NamedType *namedTy = declTy->asNamedType()) { if (NamedType *namedTy = declTy->asNamedType()) {
if (NameId *nameId = namedTy->name()->asNameId()) { if (const NameId *nameId = namedTy->name()->asNameId()) {
std::string privateClass; std::string privateClass;
privateClass += nameId->identifier()->chars(); privateClass += nameId->identifier()->chars();
privateClass += "Private"; privateClass += "Private";
Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(), privateClass.size())); const Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(),
privateClass.size()));
declTy.setType(control()->namedType(privName)); declTy.setType(control()->namedType(privName));
} }
} }

View File

@@ -184,79 +184,78 @@ public:
delete_array_entries(symbols); delete_array_entries(symbols);
} }
NameId *findOrInsertNameId(const Identifier *id) const NameId *findOrInsertNameId(const Identifier *id)
{ {
if (! id) if (! id)
return 0; return 0;
std::map<const Identifier *, NameId *>::iterator it = nameIds.lower_bound(id); std::map<const Identifier *, const NameId *>::iterator it = nameIds.lower_bound(id);
if (it == nameIds.end() || it->first != id) if (it == nameIds.end() || it->first != id)
it = nameIds.insert(it, std::make_pair(id, new NameId(id))); it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
return it->second; return it->second;
} }
TemplateNameId *findOrInsertTemplateNameId(const Identifier *id, const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
const std::vector<FullySpecifiedType> &templateArguments) const std::vector<FullySpecifiedType> &templateArguments)
{ {
if (! id) if (! id)
return 0; return 0;
const TemplateNameIdKey key(id, templateArguments); const TemplateNameIdKey key(id, templateArguments);
std::map<TemplateNameIdKey, TemplateNameId *>::iterator it = std::map<TemplateNameIdKey, const TemplateNameId *>::iterator it =
templateNameIds.lower_bound(key); templateNameIds.lower_bound(key);
if (it == templateNameIds.end() || it->first != key) { if (it == templateNameIds.end() || it->first != key) {
const FullySpecifiedType *args = 0; const FullySpecifiedType *args = 0;
if (templateArguments.size()) if (templateArguments.size())
args = &templateArguments[0]; args = &templateArguments[0];
TemplateNameId *templ = new TemplateNameId(id, args, const TemplateNameId *templ = new TemplateNameId(id, args, templateArguments.size());
templateArguments.size());
it = templateNameIds.insert(it, std::make_pair(key, templ)); it = templateNameIds.insert(it, std::make_pair(key, templ));
} }
return it->second; return it->second;
} }
DestructorNameId *findOrInsertDestructorNameId(const Identifier *id) const DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
{ {
if (! id) if (! id)
return 0; return 0;
std::map<const Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id); std::map<const Identifier *, const DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
if (it == destructorNameIds.end() || it->first != id) if (it == destructorNameIds.end() || it->first != id)
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id))); it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
return it->second; return it->second;
} }
OperatorNameId *findOrInsertOperatorNameId(int kind) const OperatorNameId *findOrInsertOperatorNameId(int kind)
{ {
const int key(kind); const int key(kind);
std::map<int, OperatorNameId *>::iterator it = operatorNameIds.lower_bound(key); std::map<int, const OperatorNameId *>::iterator it = operatorNameIds.lower_bound(key);
if (it == operatorNameIds.end() || it->first != key) if (it == operatorNameIds.end() || it->first != key)
it = operatorNameIds.insert(it, std::make_pair(key, new OperatorNameId(kind))); it = operatorNameIds.insert(it, std::make_pair(key, new OperatorNameId(kind)));
return it->second; return it->second;
} }
ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type) const ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type)
{ {
std::map<FullySpecifiedType, ConversionNameId *>::iterator it = std::map<FullySpecifiedType, const ConversionNameId *>::iterator it =
conversionNameIds.lower_bound(type); conversionNameIds.lower_bound(type);
if (it == conversionNameIds.end() || it->first != type) if (it == conversionNameIds.end() || it->first != type)
it = conversionNameIds.insert(it, std::make_pair(type, new ConversionNameId(type))); it = conversionNameIds.insert(it, std::make_pair(type, new ConversionNameId(type)));
return it->second; return it->second;
} }
QualifiedNameId *findOrInsertQualifiedNameId(const std::vector<Name *> &names, bool isGlobal) const QualifiedNameId *findOrInsertQualifiedNameId(const std::vector<const Name *> &names, bool isGlobal)
{ {
const QualifiedNameIdKey key(names, isGlobal); const QualifiedNameIdKey key(names, isGlobal);
std::map<QualifiedNameIdKey, QualifiedNameId *>::iterator it = std::map<QualifiedNameIdKey, const QualifiedNameId *>::iterator it =
qualifiedNameIds.lower_bound(key); qualifiedNameIds.lower_bound(key);
if (it == qualifiedNameIds.end() || it->first != key) { if (it == qualifiedNameIds.end() || it->first != key) {
QualifiedNameId *name = new QualifiedNameId(&names[0], names.size(), isGlobal); const QualifiedNameId *name = new QualifiedNameId(&names[0], names.size(), isGlobal);
it = qualifiedNameIds.insert(it, std::make_pair(key, name)); it = qualifiedNameIds.insert(it, std::make_pair(key, name));
} }
return it->second; return it->second;
} }
SelectorNameId *findOrInsertSelectorNameId(const std::vector<Name *> &names, bool hasArguments) const SelectorNameId *findOrInsertSelectorNameId(const std::vector<const Name *> &names, bool hasArguments)
{ {
const SelectorNameIdKey key(names, hasArguments); const SelectorNameIdKey key(names, hasArguments);
std::map<SelectorNameIdKey, SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key); std::map<SelectorNameIdKey, const SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key);
if (it == selectorNameIds.end() || it->first != key) if (it == selectorNameIds.end() || it->first != key)
it = selectorNameIds.insert(it, std::make_pair(key, new SelectorNameId(&names[0], names.size(), hasArguments))); it = selectorNameIds.insert(it, std::make_pair(key, new SelectorNameId(&names[0], names.size(), hasArguments)));
return it->second; return it->second;
@@ -272,7 +271,7 @@ public:
return floatTypes.intern(FloatType(kind)); return floatTypes.intern(FloatType(kind));
} }
PointerToMemberType *findOrInsertPointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) PointerToMemberType *findOrInsertPointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
{ {
return pointerToMemberTypes.intern(PointerToMemberType(memberName, elementType)); return pointerToMemberTypes.intern(PointerToMemberType(memberName, elementType));
} }
@@ -292,12 +291,12 @@ public:
return arrayTypes.intern(ArrayType(elementType, size)); return arrayTypes.intern(ArrayType(elementType, size));
} }
NamedType *findOrInsertNamedType(Name *name) NamedType *findOrInsertNamedType(const Name *name)
{ {
return namedTypes.intern(NamedType(name)); return namedTypes.intern(NamedType(name));
} }
Declaration *newDeclaration(unsigned sourceLocation, Name *name) Declaration *newDeclaration(unsigned sourceLocation, const Name *name)
{ {
Declaration *declaration = new Declaration(translationUnit, Declaration *declaration = new Declaration(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -305,7 +304,7 @@ public:
return declaration; return declaration;
} }
Argument *newArgument(unsigned sourceLocation, Name *name) Argument *newArgument(unsigned sourceLocation, const Name *name)
{ {
Argument *argument = new Argument(translationUnit, Argument *argument = new Argument(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -313,7 +312,7 @@ public:
return argument; return argument;
} }
Function *newFunction(unsigned sourceLocation, Name *name) Function *newFunction(unsigned sourceLocation, const Name *name)
{ {
Function *function = new Function(translationUnit, Function *function = new Function(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -321,7 +320,7 @@ public:
return function; return function;
} }
BaseClass *newBaseClass(unsigned sourceLocation, Name *name) BaseClass *newBaseClass(unsigned sourceLocation, const Name *name)
{ {
BaseClass *baseClass = new BaseClass(translationUnit, BaseClass *baseClass = new BaseClass(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -336,7 +335,7 @@ public:
return block; return block;
} }
Class *newClass(unsigned sourceLocation, Name *name) Class *newClass(unsigned sourceLocation, const Name *name)
{ {
Class *klass = new Class(translationUnit, Class *klass = new Class(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -344,7 +343,7 @@ public:
return klass; return klass;
} }
Namespace *newNamespace(unsigned sourceLocation, Name *name) Namespace *newNamespace(unsigned sourceLocation, const Name *name)
{ {
Namespace *ns = new Namespace(translationUnit, Namespace *ns = new Namespace(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -352,7 +351,7 @@ public:
return ns; return ns;
} }
UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name) UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name)
{ {
UsingNamespaceDirective *u = new UsingNamespaceDirective(translationUnit, UsingNamespaceDirective *u = new UsingNamespaceDirective(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -360,7 +359,7 @@ public:
return u; return u;
} }
ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name) ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{ {
ForwardClassDeclaration *c = new ForwardClassDeclaration(translationUnit, ForwardClassDeclaration *c = new ForwardClassDeclaration(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -368,63 +367,63 @@ public:
return c; return c;
} }
ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name) ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name)
{ {
ObjCBaseClass *c = new ObjCBaseClass(translationUnit, sourceLocation, name); ObjCBaseClass *c = new ObjCBaseClass(translationUnit, sourceLocation, name);
symbols.push_back(c); symbols.push_back(c);
return c; return c;
} }
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name) ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
{ {
ObjCBaseProtocol *p = new ObjCBaseProtocol(translationUnit, sourceLocation, name); ObjCBaseProtocol *p = new ObjCBaseProtocol(translationUnit, sourceLocation, name);
symbols.push_back(p); symbols.push_back(p);
return p; return p;
} }
ObjCClass *newObjCClass(unsigned sourceLocation, Name *name) ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name)
{ {
ObjCClass *c = new ObjCClass(translationUnit, sourceLocation, name); ObjCClass *c = new ObjCClass(translationUnit, sourceLocation, name);
symbols.push_back(c); symbols.push_back(c);
return c; return c;
} }
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name) ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{ {
ObjCForwardClassDeclaration *fwd = new ObjCForwardClassDeclaration(translationUnit, sourceLocation, name); ObjCForwardClassDeclaration *fwd = new ObjCForwardClassDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(fwd); symbols.push_back(fwd);
return fwd; return fwd;
} }
ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name) ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name)
{ {
ObjCProtocol *p = new ObjCProtocol(translationUnit, sourceLocation, name); ObjCProtocol *p = new ObjCProtocol(translationUnit, sourceLocation, name);
symbols.push_back(p); symbols.push_back(p);
return p; return p;
} }
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name) ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
{ {
ObjCForwardProtocolDeclaration *fwd = new ObjCForwardProtocolDeclaration(translationUnit, sourceLocation, name); ObjCForwardProtocolDeclaration *fwd = new ObjCForwardProtocolDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(fwd); symbols.push_back(fwd);
return fwd; return fwd;
} }
ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name) ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name)
{ {
ObjCMethod *method = new ObjCMethod(translationUnit, sourceLocation, name); ObjCMethod *method = new ObjCMethod(translationUnit, sourceLocation, name);
symbols.push_back(method); symbols.push_back(method);
return method; return method;
} }
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name) ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
{ {
ObjCPropertyDeclaration *decl = new ObjCPropertyDeclaration(translationUnit, sourceLocation, name); ObjCPropertyDeclaration *decl = new ObjCPropertyDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(decl); symbols.push_back(decl);
return decl; return decl;
} }
Enum *newEnum(unsigned sourceLocation, Name *name) Enum *newEnum(unsigned sourceLocation, const Name *name)
{ {
Enum *e = new Enum(translationUnit, Enum *e = new Enum(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -432,7 +431,7 @@ public:
return e; return e;
} }
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name) UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name)
{ {
UsingDeclaration *u = new UsingDeclaration(translationUnit, UsingDeclaration *u = new UsingDeclaration(translationUnit,
sourceLocation, name); sourceLocation, name);
@@ -466,10 +465,10 @@ public:
}; };
struct QualifiedNameIdKey { struct QualifiedNameIdKey {
std::vector<Name *> names; std::vector<const Name *> names;
bool isGlobal; bool isGlobal;
QualifiedNameIdKey(const std::vector<Name *> &names, bool isGlobal) : QualifiedNameIdKey(const std::vector<const Name *> &names, bool isGlobal) :
names(names), isGlobal(isGlobal) names(names), isGlobal(isGlobal)
{ } { }
@@ -489,10 +488,10 @@ public:
}; };
struct SelectorNameIdKey { struct SelectorNameIdKey {
std::vector<Name *> _names; std::vector<const Name *> _names;
bool _hasArguments; bool _hasArguments;
SelectorNameIdKey(const std::vector<Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {} SelectorNameIdKey(const std::vector<const Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {}
bool operator==(const SelectorNameIdKey &other) const bool operator==(const SelectorNameIdKey &other) const
{ return _names == other._names && _hasArguments == other._hasArguments; } { return _names == other._names && _hasArguments == other._hasArguments; }
@@ -522,13 +521,13 @@ public:
// ### replace std::map with lookup tables. ASAP! // ### replace std::map with lookup tables. ASAP!
// names // names
std::map<const Identifier *, NameId *> nameIds; std::map<const Identifier *, const NameId *> nameIds;
std::map<const Identifier *, DestructorNameId *> destructorNameIds; std::map<const Identifier *, const DestructorNameId *> destructorNameIds;
std::map<int, OperatorNameId *> operatorNameIds; std::map<int, const OperatorNameId *> operatorNameIds;
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds; std::map<FullySpecifiedType, const ConversionNameId *> conversionNameIds;
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds; std::map<TemplateNameIdKey, const TemplateNameId *> templateNameIds;
std::map<QualifiedNameIdKey, QualifiedNameId *> qualifiedNameIds; std::map<QualifiedNameIdKey, const QualifiedNameId *> qualifiedNameIds;
std::map<SelectorNameIdKey, SelectorNameId *> selectorNameIds; std::map<SelectorNameIdKey, const SelectorNameId *> selectorNameIds;
// types // types
VoidType voidType; VoidType voidType;
@@ -635,39 +634,39 @@ const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
return findOrInsertNumericLiteral(chars, length); return findOrInsertNumericLiteral(chars, length);
} }
NameId *Control::nameId(const Identifier *id) const NameId *Control::nameId(const Identifier *id)
{ return d->findOrInsertNameId(id); } { return d->findOrInsertNameId(id); }
TemplateNameId *Control::templateNameId(const Identifier *id, const TemplateNameId *Control::templateNameId(const Identifier *id,
FullySpecifiedType *const args, const FullySpecifiedType *const args,
unsigned argv) unsigned argv)
{ {
std::vector<FullySpecifiedType> templateArguments(args, args + argv); std::vector<FullySpecifiedType> templateArguments(args, args + argv);
return d->findOrInsertTemplateNameId(id, templateArguments); return d->findOrInsertTemplateNameId(id, templateArguments);
} }
DestructorNameId *Control::destructorNameId(const Identifier *id) const DestructorNameId *Control::destructorNameId(const Identifier *id)
{ return d->findOrInsertDestructorNameId(id); } { return d->findOrInsertDestructorNameId(id); }
OperatorNameId *Control::operatorNameId(int kind) const OperatorNameId *Control::operatorNameId(int kind)
{ return d->findOrInsertOperatorNameId(kind); } { return d->findOrInsertOperatorNameId(kind); }
ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type) const ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type)
{ return d->findOrInsertConversionNameId(type); } { return d->findOrInsertConversionNameId(type); }
QualifiedNameId *Control::qualifiedNameId(Name *const *names, const QualifiedNameId *Control::qualifiedNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool isGlobal) bool isGlobal)
{ {
std::vector<Name *> classOrNamespaceNames(names, names + nameCount); std::vector<const Name *> classOrNamespaceNames(names, names + nameCount);
return d->findOrInsertQualifiedNameId(classOrNamespaceNames, isGlobal); return d->findOrInsertQualifiedNameId(classOrNamespaceNames, isGlobal);
} }
SelectorNameId *Control::selectorNameId(Name *const *names, const SelectorNameId *Control::selectorNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool hasArguments) bool hasArguments)
{ {
std::vector<Name *> selectorNames(names, names + nameCount); std::vector<const Name *> selectorNames(names, names + nameCount);
return d->findOrInsertSelectorNameId(selectorNames, hasArguments); return d->findOrInsertSelectorNameId(selectorNames, hasArguments);
} }
@@ -681,7 +680,7 @@ IntegerType *Control::integerType(int kind)
FloatType *Control::floatType(int kind) FloatType *Control::floatType(int kind)
{ return d->findOrInsertFloatType(kind); } { return d->findOrInsertFloatType(kind); }
PointerToMemberType *Control::pointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) PointerToMemberType *Control::pointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
{ return d->findOrInsertPointerToMemberType(memberName, elementType); } { return d->findOrInsertPointerToMemberType(memberName, elementType); }
PointerType *Control::pointerType(const FullySpecifiedType &elementType) PointerType *Control::pointerType(const FullySpecifiedType &elementType)
@@ -693,66 +692,66 @@ ReferenceType *Control::referenceType(const FullySpecifiedType &elementType)
ArrayType *Control::arrayType(const FullySpecifiedType &elementType, unsigned size) ArrayType *Control::arrayType(const FullySpecifiedType &elementType, unsigned size)
{ return d->findOrInsertArrayType(elementType, size); } { return d->findOrInsertArrayType(elementType, size); }
NamedType *Control::namedType(Name *name) NamedType *Control::namedType(const Name *name)
{ return d->findOrInsertNamedType(name); } { return d->findOrInsertNamedType(name); }
Argument *Control::newArgument(unsigned sourceLocation, Name *name) Argument *Control::newArgument(unsigned sourceLocation, const Name *name)
{ return d->newArgument(sourceLocation, name); } { return d->newArgument(sourceLocation, name); }
Function *Control::newFunction(unsigned sourceLocation, Name *name) Function *Control::newFunction(unsigned sourceLocation, const Name *name)
{ return d->newFunction(sourceLocation, name); } { return d->newFunction(sourceLocation, name); }
Namespace *Control::newNamespace(unsigned sourceLocation, Name *name) Namespace *Control::newNamespace(unsigned sourceLocation, const Name *name)
{ return d->newNamespace(sourceLocation, name); } { return d->newNamespace(sourceLocation, name); }
BaseClass *Control::newBaseClass(unsigned sourceLocation, Name *name) BaseClass *Control::newBaseClass(unsigned sourceLocation, const Name *name)
{ return d->newBaseClass(sourceLocation, name); } { return d->newBaseClass(sourceLocation, name); }
Class *Control::newClass(unsigned sourceLocation, Name *name) Class *Control::newClass(unsigned sourceLocation, const Name *name)
{ return d->newClass(sourceLocation, name); } { return d->newClass(sourceLocation, name); }
Enum *Control::newEnum(unsigned sourceLocation, Name *name) Enum *Control::newEnum(unsigned sourceLocation, const Name *name)
{ return d->newEnum(sourceLocation, name); } { return d->newEnum(sourceLocation, name); }
Block *Control::newBlock(unsigned sourceLocation) Block *Control::newBlock(unsigned sourceLocation)
{ return d->newBlock(sourceLocation); } { return d->newBlock(sourceLocation); }
Declaration *Control::newDeclaration(unsigned sourceLocation, Name *name) Declaration *Control::newDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newDeclaration(sourceLocation, name); } { return d->newDeclaration(sourceLocation, name); }
UsingNamespaceDirective *Control::newUsingNamespaceDirective(unsigned sourceLocation, UsingNamespaceDirective *Control::newUsingNamespaceDirective(unsigned sourceLocation,
Name *name) const Name *name)
{ return d->newUsingNamespaceDirective(sourceLocation, name); } { return d->newUsingNamespaceDirective(sourceLocation, name); }
UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, Name *name) UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newUsingDeclaration(sourceLocation, name); } { return d->newUsingDeclaration(sourceLocation, name); }
ForwardClassDeclaration *Control::newForwardClassDeclaration(unsigned sourceLocation, ForwardClassDeclaration *Control::newForwardClassDeclaration(unsigned sourceLocation,
Name *name) const Name *name)
{ return d->newForwardClassDeclaration(sourceLocation, name); } { return d->newForwardClassDeclaration(sourceLocation, name); }
ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, Name *name) ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, const Name *name)
{ return d->newObjCBaseClass(sourceLocation, name); } { return d->newObjCBaseClass(sourceLocation, name); }
ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, Name *name) ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
{ return d->newObjCBaseProtocol(sourceLocation, name); } { return d->newObjCBaseProtocol(sourceLocation, name); }
ObjCClass *Control::newObjCClass(unsigned sourceLocation, Name *name) ObjCClass *Control::newObjCClass(unsigned sourceLocation, const Name *name)
{ return d->newObjCClass(sourceLocation, name); } { return d->newObjCClass(sourceLocation, name); }
ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name) ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCForwardClassDeclaration(sourceLocation, name); } { return d->newObjCForwardClassDeclaration(sourceLocation, name); }
ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, Name *name) ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, const Name *name)
{ return d->newObjCProtocol(sourceLocation, name); } { return d->newObjCProtocol(sourceLocation, name); }
ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name) ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCForwardProtocolDeclaration(sourceLocation, name); } { return d->newObjCForwardProtocolDeclaration(sourceLocation, name); }
ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name) ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, const Name *name)
{ return d->newObjCMethod(sourceLocation, name); } { return d->newObjCMethod(sourceLocation, name); }
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name) ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCPropertyDeclaration(sourceLocation, name); } { return d->newObjCPropertyDeclaration(sourceLocation, name); }
const Identifier *Control::objcGetterId() const const Identifier *Control::objcGetterId() const

View File

@@ -66,28 +66,28 @@ public:
void setDiagnosticClient(DiagnosticClient *diagnosticClient); void setDiagnosticClient(DiagnosticClient *diagnosticClient);
/// Returns the canonical name id. /// Returns the canonical name id.
NameId *nameId(const Identifier *id); const NameId *nameId(const Identifier *id);
/// Returns the canonical template name id. /// Returns the canonical template name id.
TemplateNameId *templateNameId(const Identifier *id, const TemplateNameId *templateNameId(const Identifier *id,
FullySpecifiedType *const args = 0, const FullySpecifiedType *const args = 0,
unsigned argc = 0); unsigned argc = 0);
/// Returns the canonical destructor name id. /// Returns the canonical destructor name id.
DestructorNameId *destructorNameId(const Identifier *id); const DestructorNameId *destructorNameId(const Identifier *id);
/// Returns the canonical operator name id. /// Returns the canonical operator name id.
OperatorNameId *operatorNameId(int operatorId); const OperatorNameId *operatorNameId(int operatorId);
/// Returns the canonical conversion name id. /// Returns the canonical conversion name id.
ConversionNameId *conversionNameId(const FullySpecifiedType &type); const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
/// Returns the canonical qualified name id. /// Returns the canonical qualified name id.
QualifiedNameId *qualifiedNameId(Name *const *names, const QualifiedNameId *qualifiedNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool isGlobal = false); bool isGlobal = false);
SelectorNameId *selectorNameId(Name *const *names, const SelectorNameId *selectorNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool hasArguments); bool hasArguments);
@@ -101,7 +101,7 @@ public:
FloatType *floatType(int floatId); FloatType *floatType(int floatId);
/// Returns a Type object of type PointertoMemberType. /// Returns a Type object of type PointertoMemberType.
PointerToMemberType *pointerToMemberType(Name *memberName, PointerToMemberType *pointerToMemberType(const Name *memberName,
const FullySpecifiedType &elementType); const FullySpecifiedType &elementType);
/// Returns a Type object of type PointerType. /// Returns a Type object of type PointerType.
@@ -114,61 +114,61 @@ public:
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0); ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
/// Returns a Type object of type NamedType. /// Returns a Type object of type NamedType.
NamedType *namedType(Name *name); NamedType *namedType(const Name *name);
/// Creates a new Declaration symbol. /// Creates a new Declaration symbol.
Declaration *newDeclaration(unsigned sourceLocation, Name *name); Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
/// Creates a new Argument symbol. /// Creates a new Argument symbol.
Argument *newArgument(unsigned sourceLocation, Name *name = 0); Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Function symbol. /// Creates a new Function symbol.
Function *newFunction(unsigned sourceLocation, Name *name = 0); Function *newFunction(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Namespace symbol. /// Creates a new Namespace symbol.
Namespace *newNamespace(unsigned sourceLocation, Name *name = 0); Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0);
/// Creates a new BaseClass symbol. /// Creates a new BaseClass symbol.
BaseClass *newBaseClass(unsigned sourceLocation, Name *name = 0); BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Class symbol. /// Creates a new Class symbol.
Class *newClass(unsigned sourceLocation, Name *name = 0); Class *newClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Enum symbol. /// Creates a new Enum symbol.
Enum *newEnum(unsigned sourceLocation, Name *name = 0); Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Block symbol. /// Creates a new Block symbol.
Block *newBlock(unsigned sourceLocation); Block *newBlock(unsigned sourceLocation);
/// Creates a new UsingNamespaceDirective symbol. /// Creates a new UsingNamespaceDirective symbol.
UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name = 0); UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0);
/// Creates a new UsingDeclaration symbol. /// Creates a new UsingDeclaration symbol.
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name = 0); UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new ForwardClassDeclaration symbol. /// Creates a new ForwardClassDeclaration symbol.
ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name = 0); ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name); ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name); ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
/// Creates a new Objective-C class symbol. /// Creates a new Objective-C class symbol.
ObjCClass *newObjCClass(unsigned sourceLocation, Name *name = 0); ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C class forward declaration symbol. /// Creates a new Objective-C class forward declaration symbol.
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name = 0); ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C protocol symbol. /// Creates a new Objective-C protocol symbol.
ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name = 0); ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C protocol forward declaration symbol. /// Creates a new Objective-C protocol forward declaration symbol.
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name = 0); ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C method symbol. /// Creates a new Objective-C method symbol.
ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name = 0); ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C @property declaration symbol. /// Creates a new Objective-C @property declaration symbol.
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name); ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
// Objective-C specific context keywords. // Objective-C specific context keywords.
const Identifier *objcGetterId() const; const Identifier *objcGetterId() const;

View File

@@ -90,7 +90,7 @@ bool VoidType::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false; return false;
} }
PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType) PointerToMemberType::PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
: _memberName(memberName), : _memberName(memberName),
_elementType(elementType) _elementType(elementType)
{ } { }
@@ -98,7 +98,7 @@ PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedT
PointerToMemberType::~PointerToMemberType() PointerToMemberType::~PointerToMemberType()
{ } { }
Name *PointerToMemberType::memberName() const const Name *PointerToMemberType::memberName() const
{ return _memberName; } { return _memberName; }
FullySpecifiedType PointerToMemberType::elementType() const FullySpecifiedType PointerToMemberType::elementType() const
@@ -275,14 +275,14 @@ FullySpecifiedType ArrayType::elementType() const
unsigned ArrayType::size() const unsigned ArrayType::size() const
{ return _size; } { return _size; }
NamedType::NamedType(Name *name) NamedType::NamedType(const Name *name)
: _name(name) : _name(name)
{ } { }
NamedType::~NamedType() NamedType::~NamedType()
{ } { }
Name *NamedType::name() const const Name *NamedType::name() const
{ return _name; } { return _name; }
bool NamedType::isEqualTo(const Type *other) const bool NamedType::isEqualTo(const Type *other) const
@@ -291,12 +291,12 @@ bool NamedType::isEqualTo(const Type *other) const
if (! o) if (! o)
return false; return false;
Name *name = _name; const Name *name = _name;
if (QualifiedNameId *q = name->asQualifiedNameId()) if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId(); name = q->unqualifiedNameId();
Name *otherName = o->name(); const Name *otherName = o->name();
if (QualifiedNameId *q = otherName->asQualifiedNameId()) if (const QualifiedNameId *q = otherName->asQualifiedNameId())
otherName = q->unqualifiedNameId(); otherName = q->unqualifiedNameId();
return name->isEqualTo(otherName); return name->isEqualTo(otherName);

View File

@@ -186,10 +186,10 @@ private:
class CPLUSPLUS_EXPORT PointerToMemberType: public Type class CPLUSPLUS_EXPORT PointerToMemberType: public Type
{ {
public: public:
PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType); PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType);
virtual ~PointerToMemberType(); virtual ~PointerToMemberType();
Name *memberName() const; const Name *memberName() const;
FullySpecifiedType elementType() const; FullySpecifiedType elementType() const;
virtual bool isEqualTo(const Type *other) const; virtual bool isEqualTo(const Type *other) const;
@@ -205,7 +205,7 @@ protected:
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const; virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private: private:
Name *_memberName; const Name *_memberName;
FullySpecifiedType _elementType; FullySpecifiedType _elementType;
}; };
@@ -262,10 +262,10 @@ private:
class CPLUSPLUS_EXPORT NamedType: public Type class CPLUSPLUS_EXPORT NamedType: public Type
{ {
public: public:
NamedType(Name *name); NamedType(const Name *name);
virtual ~NamedType(); virtual ~NamedType();
Name *name() const; const Name *name() const;
virtual bool isEqualTo(const Type *other) const; virtual bool isEqualTo(const Type *other) const;
@@ -280,7 +280,7 @@ protected:
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const; virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private: private:
Name *_name; const Name *_name;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus

View File

@@ -79,14 +79,14 @@ bool Name::isQualifiedNameId() const
bool Name::isSelectorNameId() const bool Name::isSelectorNameId() const
{ return asSelectorNameId() != 0; } { return asSelectorNameId() != 0; }
void Name::accept(NameVisitor *visitor) void Name::accept(NameVisitor *visitor) const
{ {
if (visitor->preVisit(this)) if (visitor->preVisit(this))
accept0(visitor); accept0(visitor);
visitor->postVisit(this); visitor->postVisit(this);
} }
void Name::accept(Name *name, NameVisitor *visitor) void Name::accept(const Name *name, NameVisitor *visitor)
{ {
if (! name) if (! name)
return; return;

View File

@@ -78,21 +78,13 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const { return 0; } virtual const QualifiedNameId *asQualifiedNameId() const { return 0; }
virtual const SelectorNameId *asSelectorNameId() const { return 0; } virtual const SelectorNameId *asSelectorNameId() const { return 0; }
virtual NameId *asNameId() { return 0; }
virtual TemplateNameId *asTemplateNameId() { return 0; }
virtual DestructorNameId *asDestructorNameId() { return 0; }
virtual OperatorNameId *asOperatorNameId() { return 0; }
virtual ConversionNameId *asConversionNameId() { return 0; }
virtual QualifiedNameId *asQualifiedNameId() { return 0; }
virtual SelectorNameId *asSelectorNameId() { return 0; }
virtual bool isEqualTo(const Name *other) const = 0; virtual bool isEqualTo(const Name *other) const = 0;
void accept(NameVisitor *visitor); void accept(NameVisitor *visitor) const;
static void accept(Name *name, NameVisitor *visitor); static void accept(const Name *name, NameVisitor *visitor);
protected: protected:
virtual void accept0(NameVisitor *visitor) = 0; virtual void accept0(NameVisitor *visitor) const = 0;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus

View File

@@ -57,7 +57,5 @@ NameVisitor::NameVisitor()
NameVisitor::~NameVisitor() NameVisitor::~NameVisitor()
{ } { }
void NameVisitor::accept(Name *name) void NameVisitor::accept(const Name *name)
{ Name::accept(name, this); } { Name::accept(name, this); }

View File

@@ -63,18 +63,18 @@ public:
NameVisitor(); NameVisitor();
virtual ~NameVisitor(); virtual ~NameVisitor();
void accept(Name *name); void accept(const Name *name);
virtual bool preVisit(Name *) { return true; } virtual bool preVisit(const Name *) { return true; }
virtual void postVisit(Name *) {} virtual void postVisit(const Name *) {}
virtual void visit(NameId *) {} virtual void visit(const NameId *) {}
virtual void visit(TemplateNameId *) {} virtual void visit(const TemplateNameId *) {}
virtual void visit(DestructorNameId *) {} virtual void visit(const DestructorNameId *) {}
virtual void visit(OperatorNameId *) {} virtual void visit(const OperatorNameId *) {}
virtual void visit(ConversionNameId *) {} virtual void visit(const ConversionNameId *) {}
virtual void visit(QualifiedNameId *) {} virtual void visit(const QualifiedNameId *) {}
virtual void visit(SelectorNameId *) {} virtual void visit(const SelectorNameId *) {}
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus

View File

@@ -54,51 +54,42 @@
using namespace CPlusPlus; using namespace CPlusPlus;
QualifiedNameId::QualifiedNameId(Name *const names[], QualifiedNameId::QualifiedNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool isGlobal) bool isGlobal)
: _names(0), : _names(names, names + nameCount),
_nameCount(nameCount),
_isGlobal(isGlobal) _isGlobal(isGlobal)
{ { }
if (_nameCount) {
_names = new Name *[_nameCount];
std::copy(&names[0], &names[nameCount], _names);
}
}
QualifiedNameId::~QualifiedNameId() QualifiedNameId::~QualifiedNameId()
{ delete[] _names; } { }
void QualifiedNameId::accept0(NameVisitor *visitor) void QualifiedNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
const Identifier *QualifiedNameId::identifier() const const Identifier *QualifiedNameId::identifier() const
{ {
if (Name *u = unqualifiedNameId()) if (const Name *u = unqualifiedNameId())
return u->identifier(); return u->identifier();
return 0; return 0;
} }
unsigned QualifiedNameId::nameCount() const unsigned QualifiedNameId::nameCount() const
{ return _nameCount; } { return _names.size(); }
Name *QualifiedNameId::nameAt(unsigned index) const const Name *QualifiedNameId::nameAt(unsigned index) const
{ return _names[index]; } { return _names[index]; }
Name *const *QualifiedNameId::names() const
{ return _names; }
bool QualifiedNameId::isGlobal() const bool QualifiedNameId::isGlobal() const
{ return _isGlobal; } { return _isGlobal; }
Name *QualifiedNameId::unqualifiedNameId() const const Name *QualifiedNameId::unqualifiedNameId() const
{ {
if (! _nameCount) if (_names.empty())
return 0; return 0;
return _names[_nameCount - 1]; return _names.back();
} }
bool QualifiedNameId::isEqualTo(const Name *other) const bool QualifiedNameId::isEqualTo(const Name *other) const
@@ -113,8 +104,8 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
if (count != q->nameCount()) if (count != q->nameCount())
return false; return false;
for (unsigned i = 0; i < count; ++i) { for (unsigned i = 0; i < count; ++i) {
Name *l = nameAt(i); const Name *l = nameAt(i);
Name *r = q->nameAt(i); const Name *r = q->nameAt(i);
if (! l->isEqualTo(r)) if (! l->isEqualTo(r))
return false; return false;
} }
@@ -129,7 +120,7 @@ NameId::NameId(const Identifier *identifier)
NameId::~NameId() NameId::~NameId()
{ } { }
void NameId::accept0(NameVisitor *visitor) void NameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
const Identifier *NameId::identifier() const const Identifier *NameId::identifier() const
@@ -152,7 +143,7 @@ DestructorNameId::DestructorNameId(const Identifier *identifier)
DestructorNameId::~DestructorNameId() DestructorNameId::~DestructorNameId()
{ } { }
void DestructorNameId::accept0(NameVisitor *visitor) void DestructorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
const Identifier *DestructorNameId::identifier() const const Identifier *DestructorNameId::identifier() const
@@ -172,34 +163,24 @@ TemplateNameId::TemplateNameId(const Identifier *identifier,
const FullySpecifiedType templateArguments[], const FullySpecifiedType templateArguments[],
unsigned templateArgumentCount) unsigned templateArgumentCount)
: _identifier(identifier), : _identifier(identifier),
_templateArguments(0), _templateArguments(templateArguments, templateArguments + templateArgumentCount)
_templateArgumentCount(templateArgumentCount) { }
{
if (_templateArgumentCount) {
_templateArguments = new FullySpecifiedType[_templateArgumentCount];
std::copy(&templateArguments[0], &templateArguments[_templateArgumentCount],
_templateArguments);
}
}
TemplateNameId::~TemplateNameId() TemplateNameId::~TemplateNameId()
{ delete[] _templateArguments; } { }
void TemplateNameId::accept0(NameVisitor *visitor) void TemplateNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
const Identifier *TemplateNameId::identifier() const const Identifier *TemplateNameId::identifier() const
{ return _identifier; } { return _identifier; }
unsigned TemplateNameId::templateArgumentCount() const unsigned TemplateNameId::templateArgumentCount() const
{ return _templateArgumentCount; } { return _templateArguments.size(); }
const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const
{ return _templateArguments[index]; } { return _templateArguments[index]; }
const FullySpecifiedType *TemplateNameId::templateArguments() const
{ return _templateArguments; }
bool TemplateNameId::isEqualTo(const Name *other) const bool TemplateNameId::isEqualTo(const Name *other) const
{ {
const TemplateNameId *t = other->asTemplateNameId(); const TemplateNameId *t = other->asTemplateNameId();
@@ -209,9 +190,9 @@ bool TemplateNameId::isEqualTo(const Name *other) const
const Identifier *r = t->identifier(); const Identifier *r = t->identifier();
if (! l->isEqualTo(r)) if (! l->isEqualTo(r))
return false; return false;
if (_templateArgumentCount != t->_templateArgumentCount) if (templateArgumentCount() != t->templateArgumentCount())
return false; return false;
for (unsigned i = 0; i < _templateArgumentCount; ++i) { for (unsigned i = 0; i < templateArgumentCount(); ++i) {
const FullySpecifiedType &l = _templateArguments[i]; const FullySpecifiedType &l = _templateArguments[i];
const FullySpecifiedType &r = t->_templateArguments[i]; const FullySpecifiedType &r = t->_templateArguments[i];
if (! l.isEqualTo(r)) if (! l.isEqualTo(r))
@@ -227,7 +208,7 @@ OperatorNameId::OperatorNameId(int kind)
OperatorNameId::~OperatorNameId() OperatorNameId::~OperatorNameId()
{ } { }
void OperatorNameId::accept0(NameVisitor *visitor) void OperatorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
int OperatorNameId::kind() const int OperatorNameId::kind() const
@@ -251,7 +232,7 @@ ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
ConversionNameId::~ConversionNameId() ConversionNameId::~ConversionNameId()
{ } { }
void ConversionNameId::accept0(NameVisitor *visitor) void ConversionNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
FullySpecifiedType ConversionNameId::type() const FullySpecifiedType ConversionNameId::type() const
@@ -268,42 +249,33 @@ bool ConversionNameId::isEqualTo(const Name *other) const
return _type.isEqualTo(c->type()); return _type.isEqualTo(c->type());
} }
SelectorNameId::SelectorNameId(Name *const names[], SelectorNameId::SelectorNameId(const Name *const *names,
unsigned nameCount, unsigned nameCount,
bool hasArguments) bool hasArguments)
: _names(0), : _names(names, names + nameCount),
_nameCount(nameCount),
_hasArguments(hasArguments) _hasArguments(hasArguments)
{ { }
if (_nameCount) {
_names = new Name *[_nameCount];
std::copy(&names[0], &names[nameCount], _names);
}
}
SelectorNameId::~SelectorNameId() SelectorNameId::~SelectorNameId()
{ delete[] _names; } { }
void SelectorNameId::accept0(NameVisitor *visitor) void SelectorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); } { visitor->visit(this); }
const Identifier *SelectorNameId::identifier() const const Identifier *SelectorNameId::identifier() const
{ {
if (! _nameCount) if (_names.empty())
return 0; return 0;
return nameAt(0)->identifier(); return nameAt(0)->identifier();
} }
unsigned SelectorNameId::nameCount() const unsigned SelectorNameId::nameCount() const
{ return _nameCount; } { return _names.size(); }
Name *SelectorNameId::nameAt(unsigned index) const const Name *SelectorNameId::nameAt(unsigned index) const
{ return _names[index]; } { return _names[index]; }
Name *const *SelectorNameId::names() const
{ return _names; }
bool SelectorNameId::hasArguments() const bool SelectorNameId::hasArguments() const
{ return _hasArguments; } { return _hasArguments; }
@@ -319,8 +291,8 @@ bool SelectorNameId::isEqualTo(const Name *other) const
if (count != q->nameCount()) if (count != q->nameCount())
return false; return false;
for (unsigned i = 0; i < count; ++i) { for (unsigned i = 0; i < count; ++i) {
Name *l = nameAt(i); const Name *l = nameAt(i);
Name *r = q->nameAt(i); const Name *r = q->nameAt(i);
if (! l->isEqualTo(r)) if (! l->isEqualTo(r))
return false; return false;
} }

View File

@@ -52,24 +52,22 @@
#include "CPlusPlusForwardDeclarations.h" #include "CPlusPlusForwardDeclarations.h"
#include "Name.h" #include "Name.h"
#include "FullySpecifiedType.h" #include "FullySpecifiedType.h"
#include <vector>
namespace CPlusPlus { namespace CPlusPlus {
class CPLUSPLUS_EXPORT QualifiedNameId: public Name class CPLUSPLUS_EXPORT QualifiedNameId: public Name
{ {
public: public:
QualifiedNameId(Name *const names[], QualifiedNameId(const Name *const *names, unsigned nameCount, bool isGlobal = false);
unsigned nameCount,
bool isGlobal = false);
virtual ~QualifiedNameId(); virtual ~QualifiedNameId();
virtual const Identifier *identifier() const; virtual const Identifier *identifier() const;
unsigned nameCount() const; unsigned nameCount() const;
Name *nameAt(unsigned index) const; const Name *nameAt(unsigned index) const;
Name *const *names() const; const Name *unqualifiedNameId() const;
Name *unqualifiedNameId() const; const Name *const *names() const { return &_names[0]; } // ### remove me
bool isGlobal() const; bool isGlobal() const;
virtual bool isEqualTo(const Name *other) const; virtual bool isEqualTo(const Name *other) const;
@@ -77,15 +75,11 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const virtual const QualifiedNameId *asQualifiedNameId() const
{ return this; } { return this; }
virtual QualifiedNameId *asQualifiedNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
Name **_names; std::vector<const Name *> _names;
unsigned _nameCount;
bool _isGlobal; bool _isGlobal;
}; };
@@ -102,11 +96,8 @@ public:
virtual const NameId *asNameId() const virtual const NameId *asNameId() const
{ return this; } { return this; }
virtual NameId *asNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
const Identifier *_identifier; const Identifier *_identifier;
@@ -125,11 +116,8 @@ public:
virtual const DestructorNameId *asDestructorNameId() const virtual const DestructorNameId *asDestructorNameId() const
{ return this; } { return this; }
virtual DestructorNameId *asDestructorNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
const Identifier *_identifier; const Identifier *_identifier;
@@ -148,23 +136,18 @@ public:
// ### find a better name // ### find a better name
unsigned templateArgumentCount() const; unsigned templateArgumentCount() const;
const FullySpecifiedType &templateArgumentAt(unsigned index) const; const FullySpecifiedType &templateArgumentAt(unsigned index) const;
const FullySpecifiedType *templateArguments() const;
virtual bool isEqualTo(const Name *other) const; virtual bool isEqualTo(const Name *other) const;
virtual const TemplateNameId *asTemplateNameId() const virtual const TemplateNameId *asTemplateNameId() const
{ return this; } { return this; }
virtual TemplateNameId *asTemplateNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
const Identifier *_identifier; const Identifier *_identifier;
FullySpecifiedType *_templateArguments; std::vector<FullySpecifiedType> _templateArguments;
unsigned _templateArgumentCount;
}; };
class CPLUSPLUS_EXPORT OperatorNameId: public Name class CPLUSPLUS_EXPORT OperatorNameId: public Name
@@ -236,11 +219,8 @@ public:
virtual const OperatorNameId *asOperatorNameId() const virtual const OperatorNameId *asOperatorNameId() const
{ return this; } { return this; }
virtual OperatorNameId *asOperatorNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
int _kind; int _kind;
@@ -260,11 +240,8 @@ public:
virtual const ConversionNameId *asConversionNameId() const virtual const ConversionNameId *asConversionNameId() const
{ return this; } { return this; }
virtual ConversionNameId *asConversionNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
FullySpecifiedType _type; FullySpecifiedType _type;
@@ -273,17 +250,13 @@ private:
class CPLUSPLUS_EXPORT SelectorNameId: public Name class CPLUSPLUS_EXPORT SelectorNameId: public Name
{ {
public: public:
SelectorNameId(Name *const names[], SelectorNameId(const Name *const *names, unsigned nameCount, bool hasArguments);
unsigned nameCount,
bool hasArguments);
virtual ~SelectorNameId(); virtual ~SelectorNameId();
virtual const Identifier *identifier() const; virtual const Identifier *identifier() const;
unsigned nameCount() const; unsigned nameCount() const;
Name *nameAt(unsigned index) const; const Name *nameAt(unsigned index) const;
Name *const *names() const;
bool hasArguments() const; bool hasArguments() const;
virtual bool isEqualTo(const Name *other) const; virtual bool isEqualTo(const Name *other) const;
@@ -291,15 +264,11 @@ public:
virtual const SelectorNameId *asSelectorNameId() const virtual const SelectorNameId *asSelectorNameId() const
{ return this; } { return this; }
virtual SelectorNameId *asSelectorNameId()
{ return this; }
protected: protected:
virtual void accept0(NameVisitor *visitor); virtual void accept0(NameVisitor *visitor) const;
private: private:
Name **_names; std::vector<const Name *> _names;
unsigned _nameCount;
bool _hasArguments; bool _hasArguments;
}; };

View File

@@ -204,12 +204,12 @@ void Scope::enterSymbol(Symbol *symbol)
} }
} }
Symbol *Scope::lookat(Name *name) const Symbol *Scope::lookat(const Name *name) const
{ {
if (! name) if (! name)
return 0; return 0;
else if (OperatorNameId *opId = name->asOperatorNameId()) else if (const OperatorNameId *opId = name->asOperatorNameId())
return lookat(opId->kind()); return lookat(opId->kind());
else if (const Identifier *id = name->identifier()) else if (const Identifier *id = name->identifier())
@@ -227,21 +227,21 @@ Symbol *Scope::lookat(const Identifier *id) const
const unsigned h = id->hashCode() % _hashSize; const unsigned h = id->hashCode() % _hashSize;
Symbol *symbol = _hash[h]; Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) { for (; symbol; symbol = symbol->_next) {
Name *identity = symbol->identity(); const Name *identity = symbol->identity();
if (! identity) { if (! identity) {
continue; continue;
} else if (NameId *nameId = identity->asNameId()) { } else if (const NameId *nameId = identity->asNameId()) {
if (nameId->identifier()->isEqualTo(id)) if (nameId->identifier()->isEqualTo(id))
break; break;
} else if (TemplateNameId *t = identity->asTemplateNameId()) { } else if (const TemplateNameId *t = identity->asTemplateNameId()) {
if (t->identifier()->isEqualTo(id)) if (t->identifier()->isEqualTo(id))
break; break;
} else if (DestructorNameId *d = identity->asDestructorNameId()) { } else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->isEqualTo(id)) if (d->identifier()->isEqualTo(id))
break; break;
} else if (identity->isQualifiedNameId()) { } else if (identity->isQualifiedNameId()) {
assert(0); return 0;
} else if (SelectorNameId *selectorNameId = identity->asSelectorNameId()) { } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->isEqualTo(id)) if (selectorNameId->identifier()->isEqualTo(id))
break; break;
} }
@@ -257,8 +257,8 @@ Symbol *Scope::lookat(int operatorId) const
const unsigned h = operatorId % _hashSize; const unsigned h = operatorId % _hashSize;
Symbol *symbol = _hash[h]; Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) { for (; symbol; symbol = symbol->_next) {
Name *identity = symbol->identity(); const Name *identity = symbol->identity();
if (OperatorNameId *op = identity->asOperatorNameId()) { if (const OperatorNameId *op = identity->asOperatorNameId()) {
if (op->kind() == operatorId) if (op->kind() == operatorId)
break; break;
} }

View File

@@ -129,7 +129,7 @@ public:
/// Returns the last Symbol in the scope. /// Returns the last Symbol in the scope.
iterator lastSymbol() const; iterator lastSymbol() const;
Symbol *lookat(Name *name) const; Symbol *lookat(const Name *name) const;
Symbol *lookat(const Identifier *id) const; Symbol *lookat(const Identifier *id) const;
Symbol *lookat(int operatorId) const; Symbol *lookat(int operatorId) const;

View File

@@ -132,7 +132,7 @@ void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParamete
{ d->checkDeclaration->check(declaration, scope, templateParameters); } { d->checkDeclaration->check(declaration, scope, templateParameters); }
FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type, FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type,
Scope *scope, Name **name) Scope *scope, const Name **name)
{ return d->checkDeclarator->check(declarator, type, scope, name); } { return d->checkDeclarator->check(declarator, type, scope, name); }
FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
@@ -154,13 +154,13 @@ FullySpecifiedType Semantic::check(ExpressionAST *expression, Scope *scope)
void Semantic::check(StatementAST *statement, Scope *scope) void Semantic::check(StatementAST *statement, Scope *scope)
{ d->checkStatement->check(statement, scope); } { d->checkStatement->check(statement, scope); }
Name *Semantic::check(NameAST *name, Scope *scope) const Name *Semantic::check(NameAST *name, Scope *scope)
{ return d->checkName->check(name, scope); } { return d->checkName->check(name, scope); }
Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope) const Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope)
{ return d->checkName->check(name, scope); } { return d->checkName->check(name, scope); }
Name *Semantic::check(ObjCSelectorAST *args, Scope *scope) const Name *Semantic::check(ObjCSelectorAST *args, Scope *scope)
{ return d->checkName->check(args, scope); } { return d->checkName->check(args, scope); }
bool Semantic::skipFunctionBodies() const bool Semantic::skipFunctionBodies() const

View File

@@ -70,7 +70,7 @@ public:
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope); FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type, FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type,
Scope *scope, Name **name = 0); // ### ugly Scope *scope, const Name **name = 0); // ### ugly
FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
Scope *scope); Scope *scope);
@@ -83,11 +83,11 @@ public:
void check(StatementAST *statement, Scope *scope); void check(StatementAST *statement, Scope *scope);
Name *check(NameAST *name, Scope *scope); const Name *check(NameAST *name, Scope *scope);
Name *check(NestedNameSpecifierListAST *name, Scope *scope); const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
Name *check(ObjCSelectorAST *args, Scope *scope); const Name *check(ObjCSelectorAST *args, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope); FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope); void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);

View File

@@ -70,7 +70,7 @@ public:
virtual ~HashCode() virtual ~HashCode()
{ } { }
unsigned operator()(Name *name) unsigned operator()(const Name *name)
{ {
unsigned previousValue = switchValue(0); unsigned previousValue = switchValue(0);
accept(name); accept(name);
@@ -85,25 +85,25 @@ protected:
return previousValue; return previousValue;
} }
virtual void visit(NameId *name) virtual void visit(const NameId *name)
{ _value = name->identifier()->hashCode(); } { _value = name->identifier()->hashCode(); }
virtual void visit(TemplateNameId *name) virtual void visit(const TemplateNameId *name)
{ _value = name->identifier()->hashCode(); } { _value = name->identifier()->hashCode(); }
virtual void visit(DestructorNameId *name) virtual void visit(const DestructorNameId *name)
{ _value = name->identifier()->hashCode(); } { _value = name->identifier()->hashCode(); }
virtual void visit(OperatorNameId *name) virtual void visit(const OperatorNameId *name)
{ _value = unsigned(name->kind()); } { _value = unsigned(name->kind()); }
virtual void visit(ConversionNameId *) virtual void visit(const ConversionNameId *)
{ _value = 0; } // ### TODO: implement me { _value = 0; } // ### TODO: implement me
virtual void visit(QualifiedNameId *name) virtual void visit(const QualifiedNameId *name)
{ _value = operator()(name->unqualifiedNameId()); } { _value = operator()(name->unqualifiedNameId()); }
virtual void visit(SelectorNameId *name) virtual void visit(const SelectorNameId *name)
{ _value = name->identifier()->hashCode(); } { _value = name->identifier()->hashCode(); }
private: private:
@@ -120,47 +120,47 @@ public:
virtual ~IdentityForName() virtual ~IdentityForName()
{ } { }
Name *operator()(Name *name) const Name *operator()(const Name *name)
{ {
Name *previousIdentity = switchIdentity(0); const Name *previousIdentity = switchIdentity(0);
accept(name); accept(name);
return switchIdentity(previousIdentity); return switchIdentity(previousIdentity);
} }
protected: protected:
Name *switchIdentity(Name *identity) const Name *switchIdentity(const Name *identity)
{ {
Name *previousIdentity = _identity; const Name *previousIdentity = _identity;
_identity = identity; _identity = identity;
return previousIdentity; return previousIdentity;
} }
virtual void visit(NameId *name) virtual void visit(const NameId *name)
{ _identity = name; } { _identity = name; }
virtual void visit(TemplateNameId *name) virtual void visit(const TemplateNameId *name)
{ _identity = name; } { _identity = name; }
virtual void visit(DestructorNameId *name) virtual void visit(const DestructorNameId *name)
{ _identity = name; } { _identity = name; }
virtual void visit(OperatorNameId *name) virtual void visit(const OperatorNameId *name)
{ _identity = name; } { _identity = name; }
virtual void visit(ConversionNameId *name) virtual void visit(const ConversionNameId *name)
{ _identity = name; } { _identity = name; }
virtual void visit(QualifiedNameId *name) virtual void visit(const QualifiedNameId *name)
{ _identity = name->unqualifiedNameId(); } { _identity = name->unqualifiedNameId(); }
virtual void visit(SelectorNameId *name) virtual void visit(const SelectorNameId *name)
{ _identity = name; } { _identity = name; }
private: private:
Name *_identity; const Name *_identity;
}; };
Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: _control(translationUnit->control()), : _control(translationUnit->control()),
_sourceLocation(sourceLocation), _sourceLocation(sourceLocation),
_sourceOffset(0), _sourceOffset(0),
@@ -280,16 +280,16 @@ unsigned Symbol::endOffset() const
void Symbol::setEndOffset(unsigned offset) void Symbol::setEndOffset(unsigned offset)
{ _endOffset = offset; } { _endOffset = offset; }
Name *Symbol::identity() const const Name *Symbol::identity() const
{ {
IdentityForName id; IdentityForName id;
return id(_name); return id(_name);
} }
Name *Symbol::name() const const Name *Symbol::name() const
{ return _name; } { return _name; }
void Symbol::setName(Name *name) void Symbol::setName(const Name *name)
{ {
_name = name; _name = name;

View File

@@ -81,7 +81,7 @@ public:
public: public:
/// Constructs a Symbol with the given source location, name and translation unit. /// Constructs a Symbol with the given source location, name and translation unit.
Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
/// Destroy this Symbol. /// Destroy this Symbol.
virtual ~Symbol(); virtual ~Symbol();
@@ -121,10 +121,10 @@ public:
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const; void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
/// Returns this Symbol's name. /// Returns this Symbol's name.
Name *name() const; const Name *name() const;
/// Sets this Symbol's name. /// Sets this Symbol's name.
void setName(Name *name); // ### dangerous void setName(const Name *name); // ### dangerous
/// Returns this Symbol's (optional) identifier /// Returns this Symbol's (optional) identifier
const Identifier *identifier() const; const Identifier *identifier() const;
@@ -282,7 +282,7 @@ public:
/// Returns this Symbol's index. /// Returns this Symbol's index.
unsigned index() const; unsigned index() const;
Name *identity() const; const Name *identity() const;
bool isGenerated() const; bool isGenerated() const;
@@ -320,7 +320,7 @@ private:
unsigned _sourceOffset; unsigned _sourceOffset;
unsigned _startOffset; unsigned _startOffset;
unsigned _endOffset; unsigned _endOffset;
Name *_name; const Name *_name;
unsigned _hashCode; unsigned _hashCode;
int _storage; int _storage;
int _visibility; int _visibility;

View File

@@ -76,7 +76,7 @@ Scope *TemplateParameters::scope() const
{ return _scope; } { return _scope; }
UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit, UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit,
unsigned sourceLocation, Name *name) unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
{ } { }
@@ -90,7 +90,7 @@ void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit, UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation, Name *name) unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
{ } { }
@@ -103,7 +103,7 @@ FullySpecifiedType UsingDeclaration::type() const
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor) void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
_templateParameters(0) _templateParameters(0)
{ } { }
@@ -126,7 +126,7 @@ FullySpecifiedType Declaration::type() const
void Declaration::visitSymbol0(SymbolVisitor *visitor) void Declaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
_initializer(false) _initializer(false)
{ } { }
@@ -149,7 +149,7 @@ FullySpecifiedType Argument::type() const
void Argument::visitSymbol0(SymbolVisitor *visitor) void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name), : ScopedSymbol(translationUnit, sourceLocation, name),
_templateParameters(0), _templateParameters(0),
_flags(0) _flags(0)
@@ -203,8 +203,8 @@ bool Function::isEqualTo(const Type *other) const
else if (isVolatile() != o->isVolatile()) else if (isVolatile() != o->isVolatile())
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) { if (l == r || (l && l->isEqualTo(r))) {
if (_arguments->symbolCount() != o->_arguments->symbolCount()) if (_arguments->symbolCount() != o->_arguments->symbolCount())
return false; return false;
@@ -315,7 +315,7 @@ void Function::visitSymbol0(SymbolVisitor *visitor)
} }
} }
ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
{ _members = new Scope(this); } { _members = new Scope(this); }
@@ -361,7 +361,7 @@ void Block::visitSymbol0(SymbolVisitor *visitor)
} }
} }
Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name) : ScopedSymbol(translationUnit, sourceLocation, name)
{ } { }
@@ -376,8 +376,8 @@ bool Enum::isEqualTo(const Type *other) const
const Enum *o = other->asEnumType(); const Enum *o = other->asEnumType();
if (! o) if (! o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r) if (l == r)
return true; return true;
else if (! l) else if (! l)
@@ -405,7 +405,7 @@ void Enum::visitSymbol0(SymbolVisitor *visitor)
} }
} }
Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name) : ScopedSymbol(translationUnit, sourceLocation, name)
{ } { }
@@ -417,8 +417,8 @@ bool Namespace::isEqualTo(const Type *other) const
const Namespace *o = other->asNamespaceType(); const Namespace *o = other->asNamespaceType();
if (! o) if (! o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) if (l == r || (l && l->isEqualTo(r)))
return true; return true;
return false; return false;
@@ -447,7 +447,7 @@ void Namespace::visitSymbol0(SymbolVisitor *visitor)
FullySpecifiedType Namespace::type() const FullySpecifiedType Namespace::type() const
{ return FullySpecifiedType(const_cast<Namespace *>(this)); } { return FullySpecifiedType(const_cast<Namespace *>(this)); }
BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
_isVirtual(false) _isVirtual(false)
{ } { }
@@ -468,7 +468,7 @@ void BaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit, ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation, Name *name) unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name), : Symbol(translationUnit, sourceLocation, name),
_templateParameters(0) _templateParameters(0)
{ } { }
@@ -512,7 +512,7 @@ bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *mat
return false; return false;
} }
Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name), : ScopedSymbol(translationUnit, sourceLocation, name),
_key(ClassKey), _key(ClassKey),
_templateParameters(0) _templateParameters(0)
@@ -581,8 +581,8 @@ bool Class::isEqualTo(const Type *other) const
const Class *o = other->asClassType(); const Class *o = other->asClassType();
if (! o) if (! o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) if (l == r || (l && l->isEqualTo(r)))
return true; return true;
else else
@@ -601,7 +601,7 @@ void Class::visitSymbol0(SymbolVisitor *visitor)
} }
} }
ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
{ } { }
@@ -614,7 +614,7 @@ FullySpecifiedType ObjCBaseClass::type() const
void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor) void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name) : Symbol(translationUnit, sourceLocation, name)
{ } { }
@@ -627,7 +627,7 @@ FullySpecifiedType ObjCBaseProtocol::type() const
void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor) void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); } { visitor->visit(this); }
ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
ScopedSymbol(translationUnit, sourceLocation, name), ScopedSymbol(translationUnit, sourceLocation, name),
_isInterface(false), _isInterface(false),
_categoryName(0), _categoryName(0),
@@ -647,8 +647,8 @@ bool ObjCClass::isEqualTo(const Type *other) const
if (!o) if (!o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) if (l == r || (l && l->isEqualTo(r)))
return true; return true;
else else
@@ -680,7 +680,7 @@ bool ObjCClass::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false; return false;
} }
ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
ScopedSymbol(translationUnit, sourceLocation, name) ScopedSymbol(translationUnit, sourceLocation, name)
{ {
} }
@@ -697,8 +697,8 @@ bool ObjCProtocol::isEqualTo(const Type *other) const
if (!o) if (!o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) if (l == r || (l && l->isEqualTo(r)))
return true; return true;
else else
@@ -724,7 +724,8 @@ bool ObjCProtocol::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false; return false;
} }
ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
const Name *name):
Symbol(translationUnit, sourceLocation, name) Symbol(translationUnit, sourceLocation, name)
{ {
} }
@@ -763,7 +764,8 @@ bool ObjCForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher
return false; return false;
} }
ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name): ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
const Name *name):
Symbol(translationUnit, sourceLocation, name) Symbol(translationUnit, sourceLocation, name)
{ {
} }
@@ -802,7 +804,7 @@ bool ObjCForwardProtocolDeclaration::matchType0(const Type *otherType, TypeMatch
return false; return false;
} }
ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name) ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name), : ScopedSymbol(translationUnit, sourceLocation, name),
_flags(0) _flags(0)
{ _arguments = new Scope(this); } { _arguments = new Scope(this); }
@@ -818,8 +820,8 @@ bool ObjCMethod::isEqualTo(const Type *other) const
if (! o) if (! o)
return false; return false;
Name *l = identity(); const Name *l = identity();
Name *r = o->identity(); const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) { if (l == r || (l && l->isEqualTo(r))) {
if (_arguments->symbolCount() != o->_arguments->symbolCount()) if (_arguments->symbolCount() != o->_arguments->symbolCount())
return false; return false;
@@ -902,7 +904,7 @@ void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit, ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation, unsigned sourceLocation,
Name *name): const Name *name):
Symbol(translationUnit, sourceLocation, name), Symbol(translationUnit, sourceLocation, name),
_propertyAttributes(None), _propertyAttributes(None),
_getterName(0), _getterName(0),

View File

@@ -76,7 +76,7 @@ private:
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
{ {
public: public:
UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~UsingNamespaceDirective(); virtual ~UsingNamespaceDirective();
// Symbol's interface // Symbol's interface
@@ -95,7 +95,7 @@ protected:
class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
{ {
public: public:
UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~UsingDeclaration(); virtual ~UsingDeclaration();
// Symbol's interface // Symbol's interface
@@ -114,7 +114,7 @@ protected:
class CPLUSPLUS_EXPORT Declaration: public Symbol class CPLUSPLUS_EXPORT Declaration: public Symbol
{ {
public: public:
Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Declaration(); virtual ~Declaration();
TemplateParameters *templateParameters() const; TemplateParameters *templateParameters() const;
@@ -142,7 +142,7 @@ private:
class CPLUSPLUS_EXPORT Argument: public Symbol class CPLUSPLUS_EXPORT Argument: public Symbol
{ {
public: public:
Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Argument(); virtual ~Argument();
void setType(const FullySpecifiedType &type); void setType(const FullySpecifiedType &type);
@@ -170,7 +170,7 @@ private:
class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol
{ {
public: public:
ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ScopedSymbol(); virtual ~ScopedSymbol();
unsigned memberCount() const; unsigned memberCount() const;
@@ -210,7 +210,7 @@ protected:
class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
{ {
public: public:
ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ForwardClassDeclaration(); virtual ~ForwardClassDeclaration();
TemplateParameters *templateParameters() const; TemplateParameters *templateParameters() const;
@@ -244,7 +244,7 @@ private:
class CPLUSPLUS_EXPORT Enum: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT Enum: public ScopedSymbol, public Type
{ {
public: public:
Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Enum(); virtual ~Enum();
// Symbol's interface // Symbol's interface
@@ -281,7 +281,7 @@ public:
}; };
public: public:
Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Function(); virtual ~Function();
bool isNormal() const; bool isNormal() const;
@@ -372,7 +372,7 @@ private:
class CPLUSPLUS_EXPORT Namespace: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT Namespace: public ScopedSymbol, public Type
{ {
public: public:
Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Namespace(); virtual ~Namespace();
// Symbol's interface // Symbol's interface
@@ -402,7 +402,7 @@ protected:
class CPLUSPLUS_EXPORT BaseClass: public Symbol class CPLUSPLUS_EXPORT BaseClass: public Symbol
{ {
public: public:
BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~BaseClass(); virtual ~BaseClass();
bool isVirtual() const; bool isVirtual() const;
@@ -427,7 +427,7 @@ private:
class CPLUSPLUS_EXPORT Class: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT Class: public ScopedSymbol, public Type
{ {
public: public:
Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Class(); virtual ~Class();
enum Key { enum Key {
@@ -484,7 +484,7 @@ private:
class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
{ {
public: public:
ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCBaseClass(); virtual ~ObjCBaseClass();
// Symbol's interface // Symbol's interface
@@ -505,7 +505,7 @@ private:
class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
{ {
public: public:
ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCBaseProtocol(); virtual ~ObjCBaseProtocol();
// Symbol's interface // Symbol's interface
@@ -526,7 +526,7 @@ private:
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
{ {
public: public:
ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCForwardProtocolDeclaration(); virtual ~ObjCForwardProtocolDeclaration();
virtual FullySpecifiedType type() const; virtual FullySpecifiedType type() const;
@@ -556,7 +556,7 @@ private:
class CPLUSPLUS_EXPORT ObjCProtocol: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT ObjCProtocol: public ScopedSymbol, public Type
{ {
public: public:
ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCProtocol(); virtual ~ObjCProtocol();
unsigned protocolCount() const unsigned protocolCount() const
@@ -598,7 +598,7 @@ private:
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
{ {
public: public:
ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCForwardClassDeclaration(); virtual ~ObjCForwardClassDeclaration();
virtual FullySpecifiedType type() const; virtual FullySpecifiedType type() const;
@@ -628,15 +628,15 @@ private:
class CPLUSPLUS_EXPORT ObjCClass: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT ObjCClass: public ScopedSymbol, public Type
{ {
public: public:
ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCClass(); virtual ~ObjCClass();
bool isInterface() const { return _isInterface; } bool isInterface() const { return _isInterface; }
void setInterface(bool isInterface) { _isInterface = isInterface; } void setInterface(bool isInterface) { _isInterface = isInterface; }
bool isCategory() const { return _categoryName != 0; } bool isCategory() const { return _categoryName != 0; }
Name *categoryName() const { return _categoryName; } const Name *categoryName() const { return _categoryName; }
void setCategoryName(Name *categoryName) { _categoryName = categoryName; } void setCategoryName(const Name *categoryName) { _categoryName = categoryName; }
ObjCBaseClass *baseClass() const ObjCBaseClass *baseClass() const
{ return _baseClass; } { return _baseClass; }
@@ -677,7 +677,7 @@ protected:
private: private:
bool _isInterface; bool _isInterface;
Name *_categoryName; const Name *_categoryName;
ObjCBaseClass * _baseClass; ObjCBaseClass * _baseClass;
Array<ObjCBaseProtocol *> _protocols; Array<ObjCBaseProtocol *> _protocols;
}; };
@@ -685,7 +685,7 @@ private:
class CPLUSPLUS_EXPORT ObjCMethod: public ScopedSymbol, public Type class CPLUSPLUS_EXPORT ObjCMethod: public ScopedSymbol, public Type
{ {
public: public:
ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name); ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCMethod(); virtual ~ObjCMethod();
FullySpecifiedType returnType() const; FullySpecifiedType returnType() const;
@@ -760,7 +760,7 @@ public:
public: public:
ObjCPropertyDeclaration(TranslationUnit *translationUnit, ObjCPropertyDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation, unsigned sourceLocation,
Name *name); const Name *name);
virtual ~ObjCPropertyDeclaration(); virtual ~ObjCPropertyDeclaration();
bool hasAttribute(int attribute) const bool hasAttribute(int attribute) const
@@ -775,16 +775,16 @@ public:
bool hasSetter() const bool hasSetter() const
{ return hasAttribute(Setter); } { return hasAttribute(Setter); }
Name *getterName() const const Name *getterName() const
{ return _getterName; } { return _getterName; }
void setGetterName(Name *getterName) void setGetterName(const Name *getterName)
{ _getterName = getterName; } { _getterName = getterName; }
Name *setterName() const const Name *setterName() const
{ return _setterName; } { return _setterName; }
void setSetterName(Name *setterName) void setSetterName(const Name *setterName)
{ _setterName = setterName; } { _setterName = setterName; }
void setType(const FullySpecifiedType &type) void setType(const FullySpecifiedType &type)
@@ -805,7 +805,8 @@ protected:
private: private:
FullySpecifiedType _type; FullySpecifiedType _type;
int _propertyAttributes; int _propertyAttributes;
Name *_getterName, *_setterName; const Name *_getterName;
const Name *_setterName;
}; };
} // end of namespace CPlusPlus } // end of namespace CPlusPlus