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

View File

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

View File

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

View File

@@ -84,7 +84,7 @@ public:
virtual NamespaceBinding *asNamespaceBinding() { 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;
};
@@ -98,7 +98,7 @@ public:
virtual ~NamespaceBinding();
/// Returns this binding's name.
NameId *name() const;
const NameId *name() const;
/// Returns this binding's identifier.
const Identifier *identifier() const;
@@ -107,16 +107,16 @@ public:
NamespaceBinding *globalNamespaceBinding();
/// 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.
NamespaceBinding *findOrCreateNamespaceBinding(Namespace *symbol);
NamespaceBinding *resolveNamespace(const Location &loc,
Name *name,
const Name *name,
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);
/// Helpers.
@@ -129,10 +129,10 @@ public:
static ClassBinding *find(Class *symbol, NamespaceBinding *binding);
private:
NamespaceBinding *findNamespaceBindingForNameId(NameId *name,
NamespaceBinding *findNamespaceBindingForNameId(const NameId *name,
bool lookAtParentNamespace);
NamespaceBinding *findNamespaceBindingForNameId_helper(NameId *name,
NamespaceBinding *findNamespaceBindingForNameId_helper(const NameId *name,
bool lookAtParentNamespace,
QSet<NamespaceBinding *> *processed);
@@ -165,13 +165,13 @@ public:
virtual ClassBinding *asClassBinding() { return this; }
/// Returns this binding's name.
Name *name() const;
const Name *name() const;
/// Returns this binding's identifier.
const Identifier *identifier() 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);
void dump();

View File

@@ -52,7 +52,7 @@ public:
Control *control() const { return context.control(); }
FullySpecifiedType apply(Name *name);
FullySpecifiedType apply(const Name *name);
FullySpecifiedType apply(const FullySpecifiedType &type);
int findSubstitution(const Identifier *id) const;
@@ -207,7 +207,7 @@ private:
public:
ApplyToName(ApplySubstitution *q): q(q) {}
FullySpecifiedType operator()(Name *name)
FullySpecifiedType operator()(const Name *name)
{
FullySpecifiedType previousType = switchType(FullySpecifiedType());
accept(name);
@@ -231,7 +231,7 @@ private:
return previousType;
}
virtual void visit(NameId *name)
virtual void visit(const NameId *name)
{
int index = findSubstitution(name->identifier());
@@ -242,7 +242,7 @@ private:
_type = control()->namedType(name);
}
virtual void visit(TemplateNameId *name)
virtual void visit(const TemplateNameId *name)
{
QVarLengthArray<FullySpecifiedType, 8> arguments(name->templateArgumentCount());
for (unsigned i = 0; i < name->templateArgumentCount(); ++i) {
@@ -250,17 +250,19 @@ private:
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);
}
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) {
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());
for (unsigned templateArgIndex = 0; templateArgIndex < templId->templateArgumentCount(); ++templateArgIndex) {
FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex);
@@ -273,29 +275,29 @@ private:
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);
}
virtual void visit(DestructorNameId *name)
virtual void visit(const DestructorNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
}
virtual void visit(OperatorNameId *name)
virtual void visit(const OperatorNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
}
virtual void visit(ConversionNameId *name)
virtual void visit(const ConversionNameId *name)
{
Overview oo;
qWarning() << "ignored name:" << oo(name);
}
virtual void visit(SelectorNameId *name)
virtual void visit(const SelectorNameId *name)
{
Overview oo;
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);
return ty;

View File

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

View File

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

View File

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

View File

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

View File

@@ -117,13 +117,13 @@ void Overview::setShowFullyQualifiedNamed(bool showFullyQualifiedNames)
_showFullyQualifiedNames = showFullyQualifiedNames;
}
QString Overview::prettyName(Name *name) const
QString Overview::prettyName(const Name *name) const
{
NamePrettyPrinter pp(this);
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));
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -477,7 +477,7 @@ protected:
class FindFunctionDefinitions: protected SymbolVisitor
{
Name *_declarationName;
const Name *_declarationName;
QList<Function *> *_functions;
public:
@@ -486,7 +486,7 @@ public:
_functions(0)
{ }
void operator()(Name *declarationName, Scope *globals,
void operator()(const Name *declarationName, Scope *globals,
QList<Function *> *functions)
{
_declarationName = declarationName;
@@ -502,8 +502,8 @@ protected:
virtual bool visit(Function *function)
{
Name *name = function->name();
if (QualifiedNameId *q = name->asQualifiedNameId())
const Name *name = function->name();
if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId();
if (_declarationName->isEqualTo(name))
@@ -515,19 +515,19 @@ protected:
} // 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)
return 0; // nothing to do.
QVector<Name *> names;
QVector<const Name *> names;
for (Scope *scope = s->scope(); scope; scope = scope->enclosingScope()) {
if (scope->isClassScope() || scope->isNamespaceScope()) {
if (scope->owner() && scope->owner()->name()) {
Name *ownerName = scope->owner()->name();
if (QualifiedNameId *q = ownerName->asQualifiedNameId()) {
const Name *ownerName = scope->owner()->name();
if (const QualifiedNameId *q = ownerName->asQualifiedNameId()) {
for (unsigned i = 0; i < q->nameCount(); ++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) {
names.append(q->nameAt(i));
}
@@ -1021,27 +1021,28 @@ void CPPEditor::updateUsesNow()
semanticRehighlight();
}
static bool isCompatible(Name *name, Name *otherName)
static bool isCompatible(const Name *name, const Name *otherName)
{
if (NameId *nameId = name->asNameId()) {
if (TemplateNameId *otherTemplId = otherName->asTemplateNameId())
if (const NameId *nameId = name->asNameId()) {
if (const TemplateNameId *otherTemplId = otherName->asTemplateNameId())
return nameId->identifier()->isEqualTo(otherTemplId->identifier());
} else if (TemplateNameId *templId = name->asTemplateNameId()) {
if (NameId *otherNameId = otherName->asNameId())
} else if (const TemplateNameId *templId = name->asTemplateNameId()) {
if (const NameId *otherNameId = otherName->asNameId())
return templId->identifier()->isEqualTo(otherNameId->identifier());
}
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();
if (! declTy)
return false;
Name *definitionName = definition->name();
if (QualifiedNameId *q = definitionName->asQualifiedNameId()) {
const Name *definitionName = definition->name();
if (const QualifiedNameId *q = definitionName->asQualifiedNameId()) {
if (! isCompatible(q->unqualifiedNameId(), declaration->name()))
return false;
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) {
Name *n = q->nameAt(q->nameCount() - i - 1);
Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1);
const Name *n = q->nameAt(q->nameCount() - i - 1);
const Name *m = declarationName->nameAt(declarationName->nameCount() - i - 1);
if (! isCompatible(n, m))
return false;
}
@@ -1105,7 +1106,7 @@ void CPPEditor::switchDeclarationDefinition()
QList<LookupItem> resolvedSymbols = typeOfExpression(QString(), doc, lastSymbol);
const LookupContext &context = typeOfExpression.lookupContext();
QualifiedNameId *q = qualifiedNameIdForSymbol(f, context);
const QualifiedNameId *q = qualifiedNameIdForSymbol(f, context);
QList<Symbol *> symbols = context.resolve(q);
Symbol *declaration = 0;
@@ -1278,11 +1279,11 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
if (! funTy)
return 0; // symbol does not have function type.
Name *name = symbol->name();
const Name *name = symbol->name();
if (! name)
return 0; // skip anonymous functions!
if (QualifiedNameId *q = name->asQualifiedNameId())
if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId();
// 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;
@@ -161,13 +161,13 @@ static QString buildHelpId(Symbol *symbol, Name *name)
Symbol *owner = scope->owner();
if (owner && owner->name() && ! scope->isEnumScope()) {
Name *name = owner->name();
const Name *name = owner->name();
const Identifier *id = 0;
if (NameId *nameId = name->asNameId())
if (const NameId *nameId = name->asNameId())
id = nameId->identifier();
else if (TemplateNameId *nameId = name->asTemplateNameId())
else if (const TemplateNameId *nameId = name->asTemplateNameId())
id = nameId->identifier();
if (id)
@@ -182,7 +182,7 @@ static QString buildHelpId(Symbol *symbol, Name *name)
static FullySpecifiedType resolve(const FullySpecifiedType &ty,
const LookupContext &context,
Symbol **resolvedSymbol,
Name **resolvedName)
const Name **resolvedName)
{
Control *control = context.control();
@@ -334,7 +334,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
Symbol *lookupSymbol = result.lastVisibleSymbol(); // lookup symbol
Symbol *resolvedSymbol = lookupSymbol;
Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0;
const Name *resolvedName = lookupSymbol ? lookupSymbol->name() : 0;
firstType = resolve(firstType, typeOfExpression.lookupContext(),
&resolvedSymbol, &resolvedName);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -69,9 +69,9 @@ CheckName::CheckName(Semantic *semantic)
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);
accept(name);
@@ -82,12 +82,12 @@ Name *CheckName::check(NameAST *name, Scope *scope)
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);
std::vector<Name *> names;
std::vector<const Name *> names;
for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value;
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);
}
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);
accept(args);
@@ -113,7 +113,7 @@ Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
{
Name *previousName = switchName(0);
const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope);
accept(arg);
@@ -122,9 +122,9 @@ void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
(void) switchName(previousName);
}
Name *CheckName::switchName(Name *name)
const Name *CheckName::switchName(const Name *name)
{
Name *previousName = _name;
const Name *previousName = _name;
_name = name;
return previousName;
}
@@ -138,14 +138,13 @@ Scope *CheckName::switchScope(Scope *scope)
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) {
NestedNameSpecifierAST *nested_name_specifier = it->value;
names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope));
}
names.push_back(semantic()->check(ast->unqualified_name, _scope));
_name = control()->qualifiedNameId(&names[0], names.size(),
ast->global_scope_token != 0);
_name = control()->qualifiedNameId(&names[0], names.size(), ast->global_scope_token != 0);
ast->name = _name;
return false;
@@ -379,9 +378,9 @@ bool CheckName::visit(TemplateIdAST *ast)
bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
{
if (ast->name_token) {
std::vector<Name *> names;
std::vector<const Name *> names;
const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
NameId *nameId = control()->nameId(id);
const NameId *nameId = control()->nameId(id);
names.push_back(nameId);
_name = control()->selectorNameId(&names[0], names.size(), false);
ast->selector_name = _name;
@@ -392,11 +391,11 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *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) {
if (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);
} else {
// 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);
virtual ~CheckName();
Name *check(NameAST *name, Scope *scope);
Name *check(NestedNameSpecifierListAST *name, Scope *scope);
Name *check(ObjCSelectorAST *args, Scope *scope);
const Name *check(NameAST *name, Scope *scope);
const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
const Name *check(ObjCSelectorAST *args, Scope *scope);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
protected:
Name *switchName(Name *name);
const Name *switchName(const Name *name);
Scope *switchScope(Scope *scope);
using ASTVisitor::visit;
@@ -85,7 +85,7 @@ protected:
virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
private:
Name *_name;
const Name *_name;
Scope *_scope;
};

View File

@@ -312,7 +312,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
if (ast->name)
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);
klass->setStartOffset(tokenAt(ast->firstToken()).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) {
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);
base->symbol = baseClass;
if (base->virtual_token)
@@ -359,14 +359,14 @@ bool CheckSpecifier::visit(ClassSpecifierAST *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));
return false;
}
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));
return false;
}
@@ -377,7 +377,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
if (ast->name)
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);
e->setStartOffset(tokenAt(ast->firstToken()).offset);
e->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -389,7 +389,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
const Identifier *id = identifier(enumerator->identifier_token);
if (! id)
continue;
NameId *enumeratorName = control()->nameId(id);
const NameId *enumeratorName = control()->nameId(id);
Declaration *decl = control()->newDeclaration(enumerator->firstToken(),
enumeratorName);
e->addMember(decl);

View File

@@ -154,7 +154,7 @@ bool CheckStatement::visit(ForeachStatementAST *ast)
Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
Name *name = 0;
const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -183,7 +183,7 @@ bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
Name *name = 0;
const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -312,7 +312,7 @@ bool CheckStatement::visit(WhileStatementAST *ast)
bool CheckStatement::visit(QtMemberDeclarationAST *ast)
{
Name *name = 0;
const Name *name = 0;
if (tokenKind(ast->q_token) == T_Q_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 (NamedType *namedTy = declTy->asNamedType()) {
if (NameId *nameId = namedTy->name()->asNameId()) {
if (const NameId *nameId = namedTy->name()->asNameId()) {
std::string privateClass;
privateClass += nameId->identifier()->chars();
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));
}
}

View File

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

View File

@@ -66,30 +66,30 @@ public:
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
/// Returns the canonical name id.
NameId *nameId(const Identifier *id);
const NameId *nameId(const Identifier *id);
/// Returns the canonical template name id.
TemplateNameId *templateNameId(const Identifier *id,
FullySpecifiedType *const args = 0,
unsigned argc = 0);
const TemplateNameId *templateNameId(const Identifier *id,
const FullySpecifiedType *const args = 0,
unsigned argc = 0);
/// Returns the canonical destructor name id.
DestructorNameId *destructorNameId(const Identifier *id);
const DestructorNameId *destructorNameId(const Identifier *id);
/// Returns the canonical operator name id.
OperatorNameId *operatorNameId(int operatorId);
const OperatorNameId *operatorNameId(int operatorId);
/// Returns the canonical conversion name id.
ConversionNameId *conversionNameId(const FullySpecifiedType &type);
const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
/// Returns the canonical qualified name id.
QualifiedNameId *qualifiedNameId(Name *const *names,
unsigned nameCount,
bool isGlobal = false);
const QualifiedNameId *qualifiedNameId(const Name *const *names,
unsigned nameCount,
bool isGlobal = false);
SelectorNameId *selectorNameId(Name *const *names,
unsigned nameCount,
bool hasArguments);
const SelectorNameId *selectorNameId(const Name *const *names,
unsigned nameCount,
bool hasArguments);
/// Returns a Type object of type VoidType.
VoidType *voidType();
@@ -101,7 +101,7 @@ public:
FloatType *floatType(int floatId);
/// Returns a Type object of type PointertoMemberType.
PointerToMemberType *pointerToMemberType(Name *memberName,
PointerToMemberType *pointerToMemberType(const Name *memberName,
const FullySpecifiedType &elementType);
/// Returns a Type object of type PointerType.
@@ -114,61 +114,61 @@ public:
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
/// Returns a Type object of type NamedType.
NamedType *namedType(Name *name);
NamedType *namedType(const Name *name);
/// Creates a new Declaration symbol.
Declaration *newDeclaration(unsigned sourceLocation, Name *name);
Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
/// 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.
Function *newFunction(unsigned sourceLocation, Name *name = 0);
Function *newFunction(unsigned sourceLocation, const Name *name = 0);
/// 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.
BaseClass *newBaseClass(unsigned sourceLocation, Name *name = 0);
BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
/// 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.
Enum *newEnum(unsigned sourceLocation, Name *name = 0);
Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Block symbol.
Block *newBlock(unsigned sourceLocation);
/// 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.
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name = 0);
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
/// 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);
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name);
ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
/// 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.
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name = 0);
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
/// 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.
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name = 0);
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
/// 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.
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
// Objective-C specific context keywords.
const Identifier *objcGetterId() const;

View File

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

View File

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

View File

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

View File

@@ -78,21 +78,13 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() 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;
void accept(NameVisitor *visitor);
static void accept(Name *name, NameVisitor *visitor);
void accept(NameVisitor *visitor) const;
static void accept(const Name *name, NameVisitor *visitor);
protected:
virtual void accept0(NameVisitor *visitor) = 0;
virtual void accept0(NameVisitor *visitor) const = 0;
};
} // end of namespace CPlusPlus

View File

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

View File

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

View File

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

View File

@@ -52,24 +52,22 @@
#include "CPlusPlusForwardDeclarations.h"
#include "Name.h"
#include "FullySpecifiedType.h"
#include <vector>
namespace CPlusPlus {
class CPLUSPLUS_EXPORT QualifiedNameId: public Name
{
public:
QualifiedNameId(Name *const names[],
unsigned nameCount,
bool isGlobal = false);
QualifiedNameId(const Name *const *names, unsigned nameCount, bool isGlobal = false);
virtual ~QualifiedNameId();
virtual const Identifier *identifier() const;
unsigned nameCount() const;
Name *nameAt(unsigned index) const;
Name *const *names() const;
Name *unqualifiedNameId() const;
const Name *nameAt(unsigned index) const;
const Name *unqualifiedNameId() const;
const Name *const *names() const { return &_names[0]; } // ### remove me
bool isGlobal() const;
virtual bool isEqualTo(const Name *other) const;
@@ -77,15 +75,11 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const
{ return this; }
virtual QualifiedNameId *asQualifiedNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
Name **_names;
unsigned _nameCount;
std::vector<const Name *> _names;
bool _isGlobal;
};
@@ -102,11 +96,8 @@ public:
virtual const NameId *asNameId() const
{ return this; }
virtual NameId *asNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
@@ -125,11 +116,8 @@ public:
virtual const DestructorNameId *asDestructorNameId() const
{ return this; }
virtual DestructorNameId *asDestructorNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
@@ -148,23 +136,18 @@ public:
// ### find a better name
unsigned templateArgumentCount() const;
const FullySpecifiedType &templateArgumentAt(unsigned index) const;
const FullySpecifiedType *templateArguments() const;
virtual bool isEqualTo(const Name *other) const;
virtual const TemplateNameId *asTemplateNameId() const
{ return this; }
virtual TemplateNameId *asTemplateNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
FullySpecifiedType *_templateArguments;
unsigned _templateArgumentCount;
std::vector<FullySpecifiedType> _templateArguments;
};
class CPLUSPLUS_EXPORT OperatorNameId: public Name
@@ -236,11 +219,8 @@ public:
virtual const OperatorNameId *asOperatorNameId() const
{ return this; }
virtual OperatorNameId *asOperatorNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
int _kind;
@@ -260,11 +240,8 @@ public:
virtual const ConversionNameId *asConversionNameId() const
{ return this; }
virtual ConversionNameId *asConversionNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
FullySpecifiedType _type;
@@ -273,17 +250,13 @@ private:
class CPLUSPLUS_EXPORT SelectorNameId: public Name
{
public:
SelectorNameId(Name *const names[],
unsigned nameCount,
bool hasArguments);
SelectorNameId(const Name *const *names, unsigned nameCount, bool hasArguments);
virtual ~SelectorNameId();
virtual const Identifier *identifier() const;
unsigned nameCount() const;
Name *nameAt(unsigned index) const;
Name *const *names() const;
const Name *nameAt(unsigned index) const;
bool hasArguments() const;
virtual bool isEqualTo(const Name *other) const;
@@ -291,15 +264,11 @@ public:
virtual const SelectorNameId *asSelectorNameId() const
{ return this; }
virtual SelectorNameId *asSelectorNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
virtual void accept0(NameVisitor *visitor) const;
private:
Name **_names;
unsigned _nameCount;
std::vector<const Name *> _names;
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)
return 0;
else if (OperatorNameId *opId = name->asOperatorNameId())
else if (const OperatorNameId *opId = name->asOperatorNameId())
return lookat(opId->kind());
else if (const Identifier *id = name->identifier())
@@ -227,21 +227,21 @@ Symbol *Scope::lookat(const Identifier *id) const
const unsigned h = id->hashCode() % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
Name *identity = symbol->identity();
const Name *identity = symbol->identity();
if (! identity) {
continue;
} else if (NameId *nameId = identity->asNameId()) {
} else if (const NameId *nameId = identity->asNameId()) {
if (nameId->identifier()->isEqualTo(id))
break;
} else if (TemplateNameId *t = identity->asTemplateNameId()) {
} else if (const TemplateNameId *t = identity->asTemplateNameId()) {
if (t->identifier()->isEqualTo(id))
break;
} else if (DestructorNameId *d = identity->asDestructorNameId()) {
} else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->isEqualTo(id))
break;
} else if (identity->isQualifiedNameId()) {
assert(0);
} else if (SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
return 0;
} else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->isEqualTo(id))
break;
}
@@ -257,8 +257,8 @@ Symbol *Scope::lookat(int operatorId) const
const unsigned h = operatorId % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
Name *identity = symbol->identity();
if (OperatorNameId *op = identity->asOperatorNameId()) {
const Name *identity = symbol->identity();
if (const OperatorNameId *op = identity->asOperatorNameId()) {
if (op->kind() == operatorId)
break;
}

View File

@@ -129,7 +129,7 @@ public:
/// Returns the last Symbol in the scope.
iterator lastSymbol() const;
Symbol *lookat(Name *name) const;
Symbol *lookat(const Name *name) const;
Symbol *lookat(const Identifier *id) 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); }
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); }
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)
{ 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); }
Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope)
const Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *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); }
bool Semantic::skipFunctionBodies() const

View File

@@ -70,7 +70,7 @@ public:
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
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,
Scope *scope);
@@ -83,11 +83,11 @@ public:
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);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);

View File

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

View File

@@ -81,7 +81,7 @@ public:
public:
/// 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.
virtual ~Symbol();
@@ -121,10 +121,10 @@ public:
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
/// Returns this Symbol's name.
Name *name() const;
const Name *name() const;
/// Sets this Symbol's name.
void setName(Name *name); // ### dangerous
void setName(const Name *name); // ### dangerous
/// Returns this Symbol's (optional) identifier
const Identifier *identifier() const;
@@ -282,7 +282,7 @@ public:
/// Returns this Symbol's index.
unsigned index() const;
Name *identity() const;
const Name *identity() const;
bool isGenerated() const;
@@ -320,7 +320,7 @@ private:
unsigned _sourceOffset;
unsigned _startOffset;
unsigned _endOffset;
Name *_name;
const Name *_name;
unsigned _hashCode;
int _storage;
int _visibility;

View File

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

View File

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