forked from qt-creator/qt-creator
Use const literals.
This commit is contained in:
@@ -65,7 +65,7 @@ void CheckUndefinedSymbols::operator()(AST *ast)
|
|||||||
QByteArray CheckUndefinedSymbols::templateParameterName(NameAST *ast) const
|
QByteArray CheckUndefinedSymbols::templateParameterName(NameAST *ast) const
|
||||||
{
|
{
|
||||||
if (ast && ast->name) {
|
if (ast && ast->name) {
|
||||||
if (Identifier *id = ast->name->identifier())
|
if (const Identifier *id = ast->name->identifier())
|
||||||
return QByteArray::fromRawData(id->chars(), id->size());
|
return QByteArray::fromRawData(id->chars(), id->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const
|
|||||||
Symbol *member = members->symbolAt(m);
|
Symbol *member = members->symbolAt(m);
|
||||||
|
|
||||||
if (member->isTypedef() && member->isDeclaration()) {
|
if (member->isTypedef() && member->isDeclaration()) {
|
||||||
if (Identifier *id = member->identifier()) {
|
if (const Identifier *id = member->identifier()) {
|
||||||
if (name == id->chars())
|
if (name == id->chars())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const
|
|||||||
return _types.contains(name);
|
return _types.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::isType(Identifier *id) const
|
bool CheckUndefinedSymbols::isType(const Identifier *id) const
|
||||||
{
|
{
|
||||||
if (! id)
|
if (! id)
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +127,7 @@ void CheckUndefinedSymbols::addType(Name *name)
|
|||||||
if (! name)
|
if (! name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Identifier *id = name->identifier())
|
if (const Identifier *id = name->identifier())
|
||||||
_types.insert(QByteArray(id->chars(), id->size()));
|
_types.insert(QByteArray(id->chars(), id->size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ void CheckUndefinedSymbols::addProtocol(Name *name)
|
|||||||
if (!name)
|
if (!name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Identifier *id = name->identifier())
|
if (const Identifier *id = name->identifier())
|
||||||
_protocols.insert(QByteArray(id->chars(), id->size()));
|
_protocols.insert(QByteArray(id->chars(), id->size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ void CheckUndefinedSymbols::buildTypeMap(NamespaceBinding *binding, QSet<Namespa
|
|||||||
if (! processed->contains(binding)) {
|
if (! processed->contains(binding)) {
|
||||||
processed->insert(binding);
|
processed->insert(binding);
|
||||||
|
|
||||||
if (Identifier *id = binding->identifier()) {
|
if (const Identifier *id = binding->identifier()) {
|
||||||
_namespaceNames.insert(QByteArray(id->chars(), id->size()));
|
_namespaceNames.insert(QByteArray(id->chars(), id->size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ bool CheckUndefinedSymbols::visit(NamedTypeSpecifierAST *ast)
|
|||||||
unsigned line, col;
|
unsigned line, col;
|
||||||
getTokenStartPosition(ast->firstToken(), &line, &col);
|
getTokenStartPosition(ast->firstToken(), &line, &col);
|
||||||
// qWarning() << _doc->fileName() << line << col;
|
// qWarning() << _doc->fileName() << line << col;
|
||||||
} else if (Identifier *id = ast->name->name->identifier()) {
|
} else if (const Identifier *id = ast->name->name->identifier()) {
|
||||||
if (! isType(id)) {
|
if (! isType(id)) {
|
||||||
if (FunctionDeclaratorAST *functionDeclarator = currentFunctionDeclarator()) {
|
if (FunctionDeclaratorAST *functionDeclarator = currentFunctionDeclarator()) {
|
||||||
if (functionDeclarator->as_cpp_initializer)
|
if (functionDeclarator->as_cpp_initializer)
|
||||||
@@ -368,7 +368,7 @@ bool CheckUndefinedSymbols::visit(BaseSpecifierAST *base)
|
|||||||
bool resolvedBaseClassName = false;
|
bool resolvedBaseClassName = false;
|
||||||
|
|
||||||
if (Name *name = nameAST->name) {
|
if (Name *name = nameAST->name) {
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||||
if (isType(spell))
|
if (isType(spell))
|
||||||
resolvedBaseClassName = true;
|
resolvedBaseClassName = true;
|
||||||
@@ -406,7 +406,7 @@ bool CheckUndefinedSymbols::visit(QualifiedNameAST *ast)
|
|||||||
QualifiedNameId *q = ast->name->asQualifiedNameId();
|
QualifiedNameId *q = ast->name->asQualifiedNameId();
|
||||||
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
||||||
Name *name = q->nameAt(i);
|
Name *name = q->nameAt(i);
|
||||||
if (Identifier *id = name->identifier()) {
|
if (const Identifier *id = name->identifier()) {
|
||||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||||
if (! (_namespaceNames.contains(spell) || isType(id))) {
|
if (! (_namespaceNames.contains(spell) || isType(id))) {
|
||||||
translationUnit()->warning(ast->firstToken(),
|
translationUnit()->warning(ast->firstToken(),
|
||||||
@@ -475,7 +475,7 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast)
|
|||||||
bool resolvedSuperClassName = false;
|
bool resolvedSuperClassName = false;
|
||||||
|
|
||||||
if (Name *name = nameAST->name) {
|
if (Name *name = nameAST->name) {
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||||
if (isType(spell))
|
if (isType(spell))
|
||||||
resolvedSuperClassName = true;
|
resolvedSuperClassName = true;
|
||||||
@@ -497,7 +497,7 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
|
|||||||
bool resolvedProtocolName = false;
|
bool resolvedProtocolName = false;
|
||||||
|
|
||||||
if (Name *name = nameAST->name) {
|
if (Name *name = nameAST->name) {
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
const QByteArray spell = QByteArray::fromRawData(id->chars(), id->size());
|
||||||
if (isProtocol(spell))
|
if (isProtocol(spell))
|
||||||
resolvedProtocolName = true;
|
resolvedProtocolName = true;
|
||||||
@@ -522,11 +522,11 @@ bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast)
|
|||||||
bool CheckUndefinedSymbols::visit(ObjCPropertyDeclarationAST *ast)
|
bool CheckUndefinedSymbols::visit(ObjCPropertyDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
for (List<ObjCPropertyDeclaration *> *iter = ast->symbols; iter; iter = iter->next) {
|
for (List<ObjCPropertyDeclaration *> *iter = ast->symbols; iter; iter = iter->next) {
|
||||||
if (Name *getterName = iter->value->getterName()) {
|
if (/*Name *getterName = */ iter->value->getterName()) {
|
||||||
// FIXME: resolve the symbol for the name, and check its signature.
|
// FIXME: resolve the symbol for the name, and check its signature.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Name *setterName = iter->value->setterName()) {
|
if (/*Name *setterName = */ iter->value->setterName()) {
|
||||||
// FIXME: resolve the symbol for the name, and check its signature.
|
// FIXME: resolve the symbol for the name, and check its signature.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
|
|
||||||
bool isType(Identifier *id) const;
|
bool isType(const Identifier *id) const;
|
||||||
bool isType(const QByteArray &name) const;
|
bool isType(const QByteArray &name) const;
|
||||||
|
|
||||||
void addType(Name *name);
|
void addType(Name *name);
|
||||||
|
@@ -57,7 +57,7 @@ Location::Location(Symbol *symbol)
|
|||||||
_sourceLocation(symbol->sourceLocation())
|
_sourceLocation(symbol->sourceLocation())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
Location::Location(StringLiteral *fileId, unsigned sourceLocation)
|
Location::Location(const StringLiteral *fileId, unsigned sourceLocation)
|
||||||
: _fileId(fileId), _sourceLocation(sourceLocation)
|
: _fileId(fileId), _sourceLocation(sourceLocation)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ NameId *NamespaceBinding::name() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *NamespaceBinding::identifier() const
|
const Identifier *NamespaceBinding::identifier() const
|
||||||
{
|
{
|
||||||
if (NameId *nameId = name())
|
if (NameId *nameId = name())
|
||||||
return nameId->identifier();
|
return nameId->identifier();
|
||||||
@@ -113,7 +113,7 @@ NamespaceBinding *NamespaceBinding::globalNamespaceBinding()
|
|||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding *NamespaceBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed)
|
Binding *NamespaceBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed)
|
||||||
{
|
{
|
||||||
if (processed->contains(this))
|
if (processed->contains(this))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -156,7 +156,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
|
|||||||
Binding *current = this;
|
Binding *current = this;
|
||||||
|
|
||||||
for (unsigned i = 0; i < q->nameCount(); ++i) {
|
for (unsigned i = 0; i < q->nameCount(); ++i) {
|
||||||
Identifier *nameId = q->nameAt(i)->identifier();
|
const Identifier *nameId = q->nameAt(i)->identifier();
|
||||||
if (! nameId)
|
if (! nameId)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ ClassBinding *NamespaceBinding::findClassBinding(Name *name, QSet<Binding *> *pr
|
|||||||
|
|
||||||
processed->insert(this);
|
processed->insert(this);
|
||||||
|
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
|
|
||||||
foreach (ClassBinding *classBinding, classBindings) {
|
foreach (ClassBinding *classBinding, classBindings) {
|
||||||
if (id->isEqualTo(classBinding->identifier()))
|
if (id->isEqualTo(classBinding->identifier()))
|
||||||
@@ -306,7 +306,7 @@ static void closure(const Location &loc,
|
|||||||
|
|
||||||
Q_ASSERT(name->isNameId());
|
Q_ASSERT(name->isNameId());
|
||||||
|
|
||||||
Identifier *id = name->asNameId()->identifier();
|
const Identifier *id = name->asNameId()->identifier();
|
||||||
bool ignoreUsingDirectives = false;
|
bool ignoreUsingDirectives = false;
|
||||||
|
|
||||||
foreach (Namespace *symbol, binding->symbols) {
|
foreach (Namespace *symbol, binding->symbols) {
|
||||||
@@ -394,7 +394,7 @@ QByteArray NamespaceBinding::qualifiedId() const
|
|||||||
s.append(parent->qualifiedId());
|
s.append(parent->qualifiedId());
|
||||||
s.append("::");
|
s.append("::");
|
||||||
|
|
||||||
if (Identifier *id = identifier())
|
if (const Identifier *id = identifier())
|
||||||
s.append(id->chars(), id->size());
|
s.append(id->chars(), id->size());
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -409,7 +409,7 @@ QByteArray ClassBinding::qualifiedId() const
|
|||||||
QByteArray s = parent->qualifiedId();
|
QByteArray s = parent->qualifiedId();
|
||||||
s += "::";
|
s += "::";
|
||||||
|
|
||||||
if (Identifier *id = identifier())
|
if (const Identifier *id = identifier())
|
||||||
s.append(id->chars(), id->size());
|
s.append(id->chars(), id->size());
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -418,7 +418,7 @@ QByteArray ClassBinding::qualifiedId() const
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Binding *ClassBinding::findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed)
|
Binding *ClassBinding::findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed)
|
||||||
{
|
{
|
||||||
if (id->isEqualTo(identifier()))
|
if (id->isEqualTo(identifier()))
|
||||||
return this;
|
return this;
|
||||||
@@ -461,7 +461,7 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces
|
|||||||
Binding *currentBinding = this;
|
Binding *currentBinding = this;
|
||||||
|
|
||||||
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
for (unsigned i = 0; i < q->nameCount() - 1; ++i) {
|
||||||
Identifier *id = q->nameAt(i)->identifier();
|
const Identifier *id = q->nameAt(i)->identifier();
|
||||||
if (! id)
|
if (! id)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -479,12 +479,12 @@ ClassBinding *ClassBinding::findClassBinding(Name *name, QSet<Binding *> *proces
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Identifier *id = name->identifier()) {
|
if (const Identifier *id = name->identifier()) {
|
||||||
if (id->isEqualTo(identifier()))
|
if (id->isEqualTo(identifier()))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
foreach (ClassBinding *nestedClassBinding, children) {
|
foreach (ClassBinding *nestedClassBinding, children) {
|
||||||
if (Identifier *nestedClassId = nestedClassBinding->identifier()) {
|
if (const Identifier *nestedClassId = nestedClassBinding->identifier()) {
|
||||||
if (nestedClassId->isEqualTo(id))
|
if (nestedClassId->isEqualTo(id))
|
||||||
return nestedClassBinding;
|
return nestedClassBinding;
|
||||||
}
|
}
|
||||||
@@ -557,7 +557,7 @@ Name *ClassBinding::name() const
|
|||||||
return symbols.first()->name();
|
return symbols.first()->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *ClassBinding::identifier() const
|
const Identifier *ClassBinding::identifier() const
|
||||||
{
|
{
|
||||||
if (Name *n = name())
|
if (Name *n = name())
|
||||||
return n->identifier();
|
return n->identifier();
|
||||||
|
@@ -53,7 +53,7 @@ class CPLUSPLUS_EXPORT Location
|
|||||||
public:
|
public:
|
||||||
Location();
|
Location();
|
||||||
Location(Symbol *symbol);
|
Location(Symbol *symbol);
|
||||||
Location(StringLiteral *fileId, unsigned sourceLocation);
|
Location(const StringLiteral *fileId, unsigned sourceLocation);
|
||||||
|
|
||||||
inline bool isValid() const
|
inline bool isValid() const
|
||||||
{ return _fileId != 0; }
|
{ return _fileId != 0; }
|
||||||
@@ -61,14 +61,14 @@ public:
|
|||||||
inline operator bool() const
|
inline operator bool() const
|
||||||
{ return _fileId != 0; }
|
{ return _fileId != 0; }
|
||||||
|
|
||||||
inline StringLiteral *fileId() const
|
inline const StringLiteral *fileId() const
|
||||||
{ return _fileId; }
|
{ return _fileId; }
|
||||||
|
|
||||||
inline unsigned sourceLocation() const
|
inline unsigned sourceLocation() const
|
||||||
{ return _sourceLocation; }
|
{ return _sourceLocation; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StringLiteral *_fileId;
|
const StringLiteral *_fileId;
|
||||||
unsigned _sourceLocation;
|
unsigned _sourceLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
virtual ClassBinding *asClassBinding() { return 0; }
|
virtual ClassBinding *asClassBinding() { return 0; }
|
||||||
|
|
||||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed) = 0;
|
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed) = 0;
|
||||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed) = 0;
|
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT NamespaceBinding: public Binding
|
class CPLUSPLUS_EXPORT NamespaceBinding: public Binding
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
NameId *name() const;
|
NameId *name() const;
|
||||||
|
|
||||||
/// Returns this binding's identifier.
|
/// Returns this binding's identifier.
|
||||||
Identifier *identifier() const;
|
const Identifier *identifier() const;
|
||||||
|
|
||||||
/// Returns the binding for the global namespace (aka ::).
|
/// Returns the binding for the global namespace (aka ::).
|
||||||
NamespaceBinding *globalNamespaceBinding();
|
NamespaceBinding *globalNamespaceBinding();
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
bool lookAtParent = true);
|
bool lookAtParent = true);
|
||||||
|
|
||||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
||||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed);
|
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
|
||||||
|
|
||||||
/// Helpers.
|
/// Helpers.
|
||||||
virtual QByteArray qualifiedId() const;
|
virtual QByteArray qualifiedId() const;
|
||||||
@@ -168,11 +168,11 @@ public:
|
|||||||
Name *name() const;
|
Name *name() const;
|
||||||
|
|
||||||
/// Returns this binding's identifier.
|
/// Returns this binding's identifier.
|
||||||
Identifier *identifier() const;
|
const Identifier *identifier() const;
|
||||||
virtual QByteArray qualifiedId() const;
|
virtual QByteArray qualifiedId() const;
|
||||||
|
|
||||||
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
virtual ClassBinding *findClassBinding(Name *name, QSet<Binding *> *processed);
|
||||||
virtual Binding *findClassOrNamespaceBinding(Identifier *id, QSet<Binding *> *processed);
|
virtual Binding *findClassOrNamespaceBinding(const Identifier *id, QSet<Binding *> *processed);
|
||||||
|
|
||||||
void dump();
|
void dump();
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void report(int level,
|
virtual void report(int level,
|
||||||
StringLiteral *fileId,
|
const StringLiteral *fileId,
|
||||||
unsigned line, unsigned column,
|
unsigned line, unsigned column,
|
||||||
const char *format, va_list ap)
|
const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
@@ -118,7 +118,7 @@ Document::Document(const QString &fileName)
|
|||||||
_control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages));
|
_control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages));
|
||||||
|
|
||||||
const QByteArray localFileName = fileName.toUtf8();
|
const QByteArray localFileName = fileName.toUtf8();
|
||||||
StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(),
|
const StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(),
|
||||||
localFileName.size());
|
localFileName.size());
|
||||||
_translationUnit = new TranslationUnit(_control, fileId);
|
_translationUnit = new TranslationUnit(_control, fileId);
|
||||||
_translationUnit->setQtMocRunEnabled(true);
|
_translationUnit->setQtMocRunEnabled(true);
|
||||||
|
@@ -57,7 +57,7 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
|
|||||||
_globalNamespaceBinding = globalNamespaceBinding;
|
_globalNamespaceBinding = globalNamespaceBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> FindUsages::operator()(Symbol *symbol, Identifier *id, AST *ast)
|
QList<int> FindUsages::operator()(Symbol *symbol, const Identifier *id, AST *ast)
|
||||||
{
|
{
|
||||||
_processed.clear();
|
_processed.clear();
|
||||||
_references.clear();
|
_references.clear();
|
||||||
@@ -344,7 +344,7 @@ bool FindUsages::visit(QualifiedNameAST *ast)
|
|||||||
|
|
||||||
bool FindUsages::visit(EnumeratorAST *ast)
|
bool FindUsages::visit(EnumeratorAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
if (id == _id) {
|
if (id == _id) {
|
||||||
LookupContext context = currentContext(ast);
|
LookupContext context = currentContext(ast);
|
||||||
const QList<Symbol *> candidates = context.resolve(control()->nameId(id));
|
const QList<Symbol *> candidates = context.resolve(control()->nameId(id));
|
||||||
@@ -358,7 +358,7 @@ bool FindUsages::visit(EnumeratorAST *ast)
|
|||||||
|
|
||||||
bool FindUsages::visit(SimpleNameAST *ast)
|
bool FindUsages::visit(SimpleNameAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
if (id == _id) {
|
if (id == _id) {
|
||||||
LookupContext context = currentContext(ast);
|
LookupContext context = currentContext(ast);
|
||||||
const QList<Symbol *> candidates = context.resolve(ast->name);
|
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||||
@@ -370,7 +370,7 @@ bool FindUsages::visit(SimpleNameAST *ast)
|
|||||||
|
|
||||||
bool FindUsages::visit(DestructorNameAST *ast)
|
bool FindUsages::visit(DestructorNameAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
if (id == _id) {
|
if (id == _id) {
|
||||||
LookupContext context = currentContext(ast);
|
LookupContext context = currentContext(ast);
|
||||||
const QList<Symbol *> candidates = context.resolve(ast->name);
|
const QList<Symbol *> candidates = context.resolve(ast->name);
|
||||||
|
@@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
|
void setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBinding);
|
||||||
|
|
||||||
QList<int> operator()(Symbol *symbol, Identifier *id, AST *ast);
|
QList<int> operator()(Symbol *symbol, const Identifier *id, AST *ast);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using ASTVisitor::visit;
|
using ASTVisitor::visit;
|
||||||
@@ -101,7 +101,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QFutureInterface<Usage> *_future;
|
QFutureInterface<Usage> *_future;
|
||||||
Identifier *_id;
|
const Identifier *_id;
|
||||||
Symbol *_declSymbol;
|
Symbol *_declSymbol;
|
||||||
Document::Ptr _doc;
|
Document::Ptr _doc;
|
||||||
Snapshot _snapshot;
|
Snapshot _snapshot;
|
||||||
|
@@ -55,7 +55,7 @@ public:
|
|||||||
FullySpecifiedType apply(Name *name);
|
FullySpecifiedType apply(Name *name);
|
||||||
FullySpecifiedType apply(const FullySpecifiedType &type);
|
FullySpecifiedType apply(const FullySpecifiedType &type);
|
||||||
|
|
||||||
int findSubstitution(Identifier *id) const;
|
int findSubstitution(const Identifier *id) const;
|
||||||
FullySpecifiedType applySubstitution(int index) const;
|
FullySpecifiedType applySubstitution(int index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -218,7 +218,7 @@ private:
|
|||||||
Control *control() const
|
Control *control() const
|
||||||
{ return q->control(); }
|
{ return q->control(); }
|
||||||
|
|
||||||
int findSubstitution(Identifier *id) const
|
int findSubstitution(const Identifier *id) const
|
||||||
{ return q->findSubstitution(id); }
|
{ return q->findSubstitution(id); }
|
||||||
|
|
||||||
FullySpecifiedType applySubstitution(int index) const
|
FullySpecifiedType applySubstitution(int index) const
|
||||||
@@ -337,12 +337,12 @@ FullySpecifiedType ApplySubstitution::apply(const FullySpecifiedType &type)
|
|||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ApplySubstitution::findSubstitution(Identifier *id) const
|
int ApplySubstitution::findSubstitution(const Identifier *id) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(id != 0);
|
Q_ASSERT(id != 0);
|
||||||
|
|
||||||
for (int index = 0; index < substitution.size(); ++index) {
|
for (int index = 0; index < substitution.size(); ++index) {
|
||||||
QPair<Identifier *, FullySpecifiedType> s = substitution.at(index);
|
QPair<const Identifier *, FullySpecifiedType> s = substitution.at(index);
|
||||||
|
|
||||||
if (id->isEqualTo(s.first))
|
if (id->isEqualTo(s.first))
|
||||||
return index;
|
return index;
|
||||||
|
@@ -44,7 +44,7 @@ namespace CPlusPlus {
|
|||||||
class CPLUSPLUS_EXPORT GenTemplateInstance
|
class CPLUSPLUS_EXPORT GenTemplateInstance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QList< QPair<Identifier *, FullySpecifiedType> > Substitution;
|
typedef QList< QPair<const Identifier *, FullySpecifiedType> > Substitution;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GenTemplateInstance(const LookupContext &context, const Substitution &substitution);
|
GenTemplateInstance(const LookupContext &context, const Substitution &substitution);
|
||||||
|
@@ -240,7 +240,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
|||||||
else if (OperatorNameId *opId = name->asOperatorNameId())
|
else if (OperatorNameId *opId = name->asOperatorNameId())
|
||||||
return resolveOperatorNameId(opId, visibleScopes, mode);
|
return resolveOperatorNameId(opId, visibleScopes, mode);
|
||||||
|
|
||||||
else if (Identifier *id = name->identifier()) {
|
else if (const Identifier *id = name->identifier()) {
|
||||||
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
|
for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
|
||||||
Scope *scope = visibleScopes.at(scopeIndex);
|
Scope *scope = visibleScopes.at(scopeIndex);
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
|||||||
else if (! maybeValidSymbol(symbol, mode, candidates))
|
else if (! maybeValidSymbol(symbol, mode, candidates))
|
||||||
continue; // skip it, we're not looking for this kind of symbols
|
continue; // skip it, we're not looking for this kind of symbols
|
||||||
|
|
||||||
else if (Identifier *symbolId = symbol->identifier()) {
|
else if (const Identifier *symbolId = symbol->identifier()) {
|
||||||
if (! symbolId->isEqualTo(id))
|
if (! symbolId->isEqualTo(id))
|
||||||
continue; // skip it, the symbol's id is not compatible with this lookup.
|
continue; // skip it, the symbol's id is not compatible with this lookup.
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
|||||||
Name *classOrNamespaceName = control()->qualifiedNameId(q->names(),
|
Name *classOrNamespaceName = control()->qualifiedNameId(q->names(),
|
||||||
q->nameCount() - 1);
|
q->nameCount() - 1);
|
||||||
|
|
||||||
if (Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) {
|
if (const Identifier *classOrNamespaceNameId = identifier(classOrNamespaceName)) {
|
||||||
if (classOrNamespaceNameId->isEqualTo(id))
|
if (classOrNamespaceNameId->isEqualTo(id))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
|||||||
return candidates;
|
return candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *LookupContext::identifier(const Name *name) const
|
const Identifier *LookupContext::identifier(const Name *name) const
|
||||||
{
|
{
|
||||||
if (name)
|
if (name)
|
||||||
return name->identifier();
|
return name->identifier();
|
||||||
@@ -667,7 +667,7 @@ Symbol *LookupContext::canonicalSymbol(Symbol *symbol,
|
|||||||
if (! canonicalSymbol)
|
if (! canonicalSymbol)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (Identifier *symbolId = canonicalSymbol->identifier()) {
|
if (const Identifier *symbolId = canonicalSymbol->identifier()) {
|
||||||
if (symbolId && canonicalSymbol->type()->isFunctionType()) {
|
if (symbolId && canonicalSymbol->type()->isFunctionType()) {
|
||||||
Class *enclosingClass = canonicalSymbol->scope()->owner()->asClass();
|
Class *enclosingClass = canonicalSymbol->scope()->owner()->asClass();
|
||||||
const QList<ClassBinding *> classBindings = visibleClassBindings(enclosingClass, globalNamespace);
|
const QList<ClassBinding *> classBindings = visibleClassBindings(enclosingClass, globalNamespace);
|
||||||
|
@@ -198,7 +198,7 @@ private:
|
|||||||
QList<Scope *> resolveNestedNameSpecifier(QualifiedNameId *q,
|
QList<Scope *> resolveNestedNameSpecifier(QualifiedNameId *q,
|
||||||
const QList<Scope *> &visibleScopes) const;
|
const QList<Scope *> &visibleScopes) const;
|
||||||
|
|
||||||
Identifier *identifier(const Name *name) const;
|
const Identifier *identifier(const Name *name) const;
|
||||||
|
|
||||||
QList<Scope *> buildVisibleScopes();
|
QList<Scope *> buildVisibleScopes();
|
||||||
|
|
||||||
|
@@ -64,7 +64,7 @@ QString NamePrettyPrinter::switchName(const QString &name)
|
|||||||
|
|
||||||
void NamePrettyPrinter::visit(NameId *name)
|
void NamePrettyPrinter::visit(NameId *name)
|
||||||
{
|
{
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
if (id)
|
if (id)
|
||||||
_name = QString::fromLatin1(id->chars(), id->size());
|
_name = QString::fromLatin1(id->chars(), id->size());
|
||||||
else
|
else
|
||||||
@@ -73,7 +73,7 @@ void NamePrettyPrinter::visit(NameId *name)
|
|||||||
|
|
||||||
void NamePrettyPrinter::visit(TemplateNameId *name)
|
void NamePrettyPrinter::visit(TemplateNameId *name)
|
||||||
{
|
{
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
if (id)
|
if (id)
|
||||||
_name = QString::fromLatin1(id->chars(), id->size());
|
_name = QString::fromLatin1(id->chars(), id->size());
|
||||||
else
|
else
|
||||||
@@ -95,7 +95,7 @@ void NamePrettyPrinter::visit(TemplateNameId *name)
|
|||||||
|
|
||||||
void NamePrettyPrinter::visit(DestructorNameId *name)
|
void NamePrettyPrinter::visit(DestructorNameId *name)
|
||||||
{
|
{
|
||||||
Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
_name += QLatin1Char('~');
|
_name += QLatin1Char('~');
|
||||||
_name += QString::fromLatin1(id->chars(), id->size());
|
_name += QString::fromLatin1(id->chars(), id->size());
|
||||||
}
|
}
|
||||||
@@ -261,8 +261,7 @@ void NamePrettyPrinter::visit(SelectorNameId *name)
|
|||||||
if (!n)
|
if (!n)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Identifier *id = n->identifier();
|
if (const Identifier *id = n->identifier()) {
|
||||||
if (id) {
|
|
||||||
_name += QString::fromLatin1(id->chars(), id->size());
|
_name += QString::fromLatin1(id->chars(), id->size());
|
||||||
|
|
||||||
if (name->hasArguments() || name->nameCount() > 1)
|
if (name->hasArguments() || name->nameCount() > 1)
|
||||||
|
@@ -226,7 +226,7 @@ bool ResolveExpression::visit(SizeofExpressionAST *)
|
|||||||
bool ResolveExpression::visit(NumericLiteralAST *ast)
|
bool ResolveExpression::visit(NumericLiteralAST *ast)
|
||||||
{
|
{
|
||||||
Type *type = 0;
|
Type *type = 0;
|
||||||
NumericLiteral *literal = numericLiteral(ast->literal_token);
|
const NumericLiteral *literal = numericLiteral(ast->literal_token);
|
||||||
|
|
||||||
if (literal->isChar())
|
if (literal->isChar())
|
||||||
type = control()->integerType(IntegerType::Char);
|
type = control()->integerType(IntegerType::Char);
|
||||||
@@ -723,7 +723,7 @@ ResolveExpression::resolveMember(Name *memberName, Class *klass,
|
|||||||
if (i < klass->templateParameterCount()) {
|
if (i < klass->templateParameterCount()) {
|
||||||
Name *templArgName = klass->templateParameterAt(i)->name();
|
Name *templArgName = klass->templateParameterAt(i)->name();
|
||||||
if (templArgName && templArgName->identifier()) {
|
if (templArgName && templArgName->identifier()) {
|
||||||
Identifier *templArgId = templArgName->identifier();
|
const Identifier *templArgId = templArgName->identifier();
|
||||||
subst.append(qMakePair(templArgId, templArgTy));
|
subst.append(qMakePair(templArgId, templArgTy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -219,7 +219,7 @@ protected:
|
|||||||
if (! (ast && ast->name))
|
if (! (ast && ast->name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Identifier *id = ast->name->identifier();
|
const Identifier *id = ast->name->identifier();
|
||||||
|
|
||||||
if (scope) {
|
if (scope) {
|
||||||
for (Symbol *member = scope->lookat(id); member; member = member->next()) {
|
for (Symbol *member = scope->lookat(id); member; member = member->next()) {
|
||||||
@@ -1701,9 +1701,9 @@ void CPPEditor::performQuickFix(int index)
|
|||||||
{
|
{
|
||||||
CPPQuickFixCollector *quickFixCollector = CppPlugin::instance()->quickFixCollector();
|
CPPQuickFixCollector *quickFixCollector = CppPlugin::instance()->quickFixCollector();
|
||||||
QuickFixOperationPtr op = m_quickFixes.at(index);
|
QuickFixOperationPtr op = m_quickFixes.at(index);
|
||||||
//quickFixCollector->perform(op);
|
quickFixCollector->perform(op);
|
||||||
op->createChangeSet();
|
//op->createChangeSet();
|
||||||
setChangeSet(op->changeSet());
|
//setChangeSet(op->changeSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
|
void CPPEditor::contextMenuEvent(QContextMenuEvent *e)
|
||||||
|
@@ -162,7 +162,7 @@ static QString buildHelpId(Symbol *symbol, Name *name)
|
|||||||
|
|
||||||
if (owner && owner->name() && ! scope->isEnumScope()) {
|
if (owner && owner->name() && ! scope->isEnumScope()) {
|
||||||
Name *name = owner->name();
|
Name *name = owner->name();
|
||||||
Identifier *id = 0;
|
const Identifier *id = 0;
|
||||||
|
|
||||||
if (NameId *nameId = name->asNameId())
|
if (NameId *nameId = name->asNameId())
|
||||||
id = nameId->identifier();
|
id = nameId->identifier();
|
||||||
@@ -341,7 +341,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
|
|||||||
if (resolvedSymbol && resolvedSymbol->scope()
|
if (resolvedSymbol && resolvedSymbol->scope()
|
||||||
&& resolvedSymbol->scope()->isClassScope()) {
|
&& resolvedSymbol->scope()->isClassScope()) {
|
||||||
Class *enclosingClass = resolvedSymbol->scope()->owner()->asClass();
|
Class *enclosingClass = resolvedSymbol->scope()->owner()->asClass();
|
||||||
if (Identifier *id = enclosingClass->identifier()) {
|
if (const Identifier *id = enclosingClass->identifier()) {
|
||||||
if (id->isEqualTo(resolvedSymbol->identifier()))
|
if (id->isEqualTo(resolvedSymbol->identifier()))
|
||||||
resolvedSymbol = enclosingClass;
|
resolvedSymbol = enclosingClass;
|
||||||
}
|
}
|
||||||
|
@@ -79,8 +79,8 @@ QList<int> CppFindReferences::references(Symbol *symbol,
|
|||||||
Document::Ptr doc,
|
Document::Ptr doc,
|
||||||
const Snapshot& snapshot) const
|
const Snapshot& snapshot) const
|
||||||
{
|
{
|
||||||
Identifier *id = 0;
|
const Identifier *id = 0;
|
||||||
if (Identifier *symbolId = symbol->identifier())
|
if (const Identifier *symbolId = symbol->identifier())
|
||||||
id = doc->control()->findIdentifier(symbolId->chars(), symbolId->size());
|
id = doc->control()->findIdentifier(symbolId->chars(), symbolId->size());
|
||||||
|
|
||||||
QList<int> references;
|
QList<int> references;
|
||||||
@@ -106,7 +106,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
|||||||
QTime tm;
|
QTime tm;
|
||||||
tm.start();
|
tm.start();
|
||||||
|
|
||||||
Identifier *symbolId = symbol->identifier();
|
const Identifier *symbolId = symbol->identifier();
|
||||||
Q_ASSERT(symbolId != 0);
|
Q_ASSERT(symbolId != 0);
|
||||||
|
|
||||||
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
||||||
@@ -142,7 +142,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
|||||||
|
|
||||||
if (Document::Ptr previousDoc = snapshot.value(fileName)) {
|
if (Document::Ptr previousDoc = snapshot.value(fileName)) {
|
||||||
Control *control = previousDoc->control();
|
Control *control = previousDoc->control();
|
||||||
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
|
||||||
if (! id)
|
if (! id)
|
||||||
continue; // skip this document, it's not using symbolId.
|
continue; // skip this document, it's not using symbolId.
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
|||||||
doc->tokenize();
|
doc->tokenize();
|
||||||
|
|
||||||
Control *control = doc->control();
|
Control *control = doc->control();
|
||||||
if (Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
if (const Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size())) {
|
||||||
QTime tm;
|
QTime tm;
|
||||||
tm.start();
|
tm.start();
|
||||||
doc->parse();
|
doc->parse();
|
||||||
@@ -202,7 +202,7 @@ void CppFindReferences::findUsages(Symbol *symbol)
|
|||||||
|
|
||||||
void CppFindReferences::renameUsages(Symbol *symbol)
|
void CppFindReferences::renameUsages(Symbol *symbol)
|
||||||
{
|
{
|
||||||
if (Identifier *id = symbol->identifier()) {
|
if (const Identifier *id = symbol->identifier()) {
|
||||||
const QString textToReplace = QString::fromUtf8(id->chars(), id->size());
|
const QString textToReplace = QString::fromUtf8(id->chars(), id->size());
|
||||||
|
|
||||||
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
|
Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
|
||||||
|
@@ -666,7 +666,7 @@ static int blockStartState(const QTextBlock &block)
|
|||||||
return state & 0xff;
|
return state & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar typedChar)
|
void ScriptEditor::indentBlock(QTextDocument *, QTextBlock block, QChar /*typedChar*/)
|
||||||
{
|
{
|
||||||
TextEditor::TabSettings ts = tabSettings();
|
TextEditor::TabSettings ts = tabSettings();
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ namespace QmlEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool visit(Block *ast)
|
virtual bool visit(Block * /*ast*/)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
// if (_pos > ast->lbraceToken.end() && _pos < ast->rbraceToken.offset) {
|
// if (_pos > ast->lbraceToken.end() && _pos < ast->rbraceToken.offset) {
|
||||||
|
@@ -89,28 +89,28 @@ int ASTVisitor::tokenKind(unsigned index) const
|
|||||||
const char *ASTVisitor::spell(unsigned index) const
|
const char *ASTVisitor::spell(unsigned index) const
|
||||||
{ return translationUnit()->spell(index); }
|
{ return translationUnit()->spell(index); }
|
||||||
|
|
||||||
Identifier *ASTVisitor::identifier(unsigned index) const
|
const Identifier *ASTVisitor::identifier(unsigned index) const
|
||||||
{ return translationUnit()->identifier(index); }
|
{ return translationUnit()->identifier(index); }
|
||||||
|
|
||||||
Literal *ASTVisitor::literal(unsigned index) const
|
const Literal *ASTVisitor::literal(unsigned index) const
|
||||||
{ return translationUnit()->literal(index); }
|
{ return translationUnit()->literal(index); }
|
||||||
|
|
||||||
NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
const NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||||
{ return translationUnit()->numericLiteral(index); }
|
{ return translationUnit()->numericLiteral(index); }
|
||||||
|
|
||||||
StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
const StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||||
{ return translationUnit()->stringLiteral(index); }
|
{ return translationUnit()->stringLiteral(index); }
|
||||||
|
|
||||||
void ASTVisitor::getPosition(unsigned offset,
|
void ASTVisitor::getPosition(unsigned offset,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{ translationUnit()->getPosition(offset, line, column, fileName); }
|
{ translationUnit()->getPosition(offset, line, column, fileName); }
|
||||||
|
|
||||||
void ASTVisitor::getTokenPosition(unsigned index,
|
void ASTVisitor::getTokenPosition(unsigned index,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
|
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
|
||||||
|
|
||||||
void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
|
void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
|
||||||
|
@@ -72,20 +72,20 @@ public:
|
|||||||
const Token &tokenAt(unsigned index) const;
|
const Token &tokenAt(unsigned index) const;
|
||||||
int tokenKind(unsigned index) const;
|
int tokenKind(unsigned index) const;
|
||||||
const char *spell(unsigned index) const;
|
const char *spell(unsigned index) const;
|
||||||
Identifier *identifier(unsigned index) const;
|
const Identifier *identifier(unsigned index) const;
|
||||||
Literal *literal(unsigned index) const;
|
const Literal *literal(unsigned index) const;
|
||||||
NumericLiteral *numericLiteral(unsigned index) const;
|
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||||
StringLiteral *stringLiteral(unsigned index) const;
|
const StringLiteral *stringLiteral(unsigned index) const;
|
||||||
|
|
||||||
void getPosition(unsigned offset,
|
void getPosition(unsigned offset,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void getTokenPosition(unsigned index,
|
void getTokenPosition(unsigned index,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const;
|
void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||||
void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const;
|
void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||||
|
@@ -378,7 +378,7 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
|
|||||||
|
|
||||||
bool CheckDeclaration::visit(NamespaceAST *ast)
|
bool CheckDeclaration::visit(NamespaceAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
Name *namespaceName = control()->nameId(id);
|
Name *namespaceName = control()->nameId(id);
|
||||||
|
|
||||||
unsigned sourceLocation = ast->firstToken();
|
unsigned sourceLocation = ast->firstToken();
|
||||||
@@ -718,7 +718,7 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
|
|||||||
if (!attrAst)
|
if (!attrAst)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
const Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
||||||
if (attrId == control()->objcGetterId()) {
|
if (attrId == control()->objcGetterId()) {
|
||||||
if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) {
|
if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) {
|
||||||
getterName = semantic()->check(attrAst->method_selector, _scope);
|
getterName = semantic()->check(attrAst->method_selector, _scope);
|
||||||
|
@@ -343,7 +343,7 @@ bool CheckName::visit(ConversionFunctionIdAST *ast)
|
|||||||
|
|
||||||
bool CheckName::visit(SimpleNameAST *ast)
|
bool CheckName::visit(SimpleNameAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
_name = control()->nameId(id);
|
_name = control()->nameId(id);
|
||||||
ast->name = _name;
|
ast->name = _name;
|
||||||
return false;
|
return false;
|
||||||
@@ -351,7 +351,7 @@ bool CheckName::visit(SimpleNameAST *ast)
|
|||||||
|
|
||||||
bool CheckName::visit(DestructorNameAST *ast)
|
bool CheckName::visit(DestructorNameAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
_name = control()->destructorNameId(id);
|
_name = control()->destructorNameId(id);
|
||||||
ast->name = _name;
|
ast->name = _name;
|
||||||
return false;
|
return false;
|
||||||
@@ -359,7 +359,7 @@ bool CheckName::visit(DestructorNameAST *ast)
|
|||||||
|
|
||||||
bool CheckName::visit(TemplateIdAST *ast)
|
bool CheckName::visit(TemplateIdAST *ast)
|
||||||
{
|
{
|
||||||
Identifier *id = identifier(ast->identifier_token);
|
const Identifier *id = identifier(ast->identifier_token);
|
||||||
std::vector<FullySpecifiedType> templateArguments;
|
std::vector<FullySpecifiedType> templateArguments;
|
||||||
for (TemplateArgumentListAST *it = ast->template_argument_list; it;
|
for (TemplateArgumentListAST *it = ast->template_argument_list; it;
|
||||||
it = it->next) {
|
it = it->next) {
|
||||||
@@ -380,7 +380,7 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
|
|||||||
{
|
{
|
||||||
if (ast->name_token) {
|
if (ast->name_token) {
|
||||||
std::vector<Name *> names;
|
std::vector<Name *> names;
|
||||||
Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
|
const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
|
||||||
NameId *nameId = control()->nameId(id);
|
NameId *nameId = control()->nameId(id);
|
||||||
names.push_back(nameId);
|
names.push_back(nameId);
|
||||||
_name = control()->selectorNameId(&names[0], names.size(), false);
|
_name = control()->selectorNameId(&names[0], names.size(), false);
|
||||||
@@ -395,7 +395,7 @@ bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
|
|||||||
std::vector<Name *> names;
|
std::vector<Name *> names;
|
||||||
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
|
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
|
||||||
if (it->value->name_token) {
|
if (it->value->name_token) {
|
||||||
Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
|
const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
|
||||||
NameId *nameId = control()->nameId(id);
|
NameId *nameId = control()->nameId(id);
|
||||||
names.push_back(nameId);
|
names.push_back(nameId);
|
||||||
} else {
|
} else {
|
||||||
@@ -420,7 +420,7 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
|
|||||||
type = semantic()->check(ast->type_name, _scope);
|
type = semantic()->check(ast->type_name, _scope);
|
||||||
|
|
||||||
if (ast->param_name_token) {
|
if (ast->param_name_token) {
|
||||||
Identifier *id = identifier(ast->param_name_token);
|
const Identifier *id = identifier(ast->param_name_token);
|
||||||
_name = control()->nameId(id);
|
_name = control()->nameId(id);
|
||||||
ast->name = _name;
|
ast->name = _name;
|
||||||
|
|
||||||
|
@@ -386,7 +386,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
|
|||||||
_fullySpecifiedType.setType(e);
|
_fullySpecifiedType.setType(e);
|
||||||
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
|
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
|
||||||
EnumeratorAST *enumerator = it->value;
|
EnumeratorAST *enumerator = it->value;
|
||||||
Identifier *id = identifier(enumerator->identifier_token);
|
const Identifier *id = identifier(enumerator->identifier_token);
|
||||||
if (! id)
|
if (! id)
|
||||||
continue;
|
continue;
|
||||||
NameId *enumeratorName = control()->nameId(id);
|
NameId *enumeratorName = control()->nameId(id);
|
||||||
@@ -403,7 +403,7 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
|
bool CheckSpecifier::visit(AttributeSpecifierAST * /*ast*/)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -184,17 +184,17 @@ public:
|
|||||||
delete_array_entries(symbols);
|
delete_array_entries(symbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
NameId *findOrInsertNameId(Identifier *id)
|
NameId *findOrInsertNameId(const Identifier *id)
|
||||||
{
|
{
|
||||||
if (! id)
|
if (! id)
|
||||||
return 0;
|
return 0;
|
||||||
std::map<Identifier *, NameId *>::iterator it = nameIds.lower_bound(id);
|
std::map<const Identifier *, NameId *>::iterator it = nameIds.lower_bound(id);
|
||||||
if (it == nameIds.end() || it->first != id)
|
if (it == nameIds.end() || it->first != id)
|
||||||
it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
|
it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateNameId *findOrInsertTemplateNameId(Identifier *id,
|
TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
|
||||||
const std::vector<FullySpecifiedType> &templateArguments)
|
const std::vector<FullySpecifiedType> &templateArguments)
|
||||||
{
|
{
|
||||||
if (! id)
|
if (! id)
|
||||||
@@ -213,11 +213,11 @@ public:
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
DestructorNameId *findOrInsertDestructorNameId(Identifier *id)
|
DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
|
||||||
{
|
{
|
||||||
if (! id)
|
if (! id)
|
||||||
return 0;
|
return 0;
|
||||||
std::map<Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
|
std::map<const Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
|
||||||
if (it == destructorNameIds.end() || it->first != id)
|
if (it == destructorNameIds.end() || it->first != id)
|
||||||
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
|
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
|
||||||
return it->second;
|
return it->second;
|
||||||
@@ -441,10 +441,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TemplateNameIdKey {
|
struct TemplateNameIdKey {
|
||||||
Identifier *id;
|
const Identifier *id;
|
||||||
std::vector<FullySpecifiedType> templateArguments;
|
std::vector<FullySpecifiedType> templateArguments;
|
||||||
|
|
||||||
TemplateNameIdKey(Identifier *id, const std::vector<FullySpecifiedType> &templateArguments)
|
TemplateNameIdKey(const Identifier *id, const std::vector<FullySpecifiedType> &templateArguments)
|
||||||
: id(id), templateArguments(templateArguments)
|
: id(id), templateArguments(templateArguments)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -522,8 +522,8 @@ public:
|
|||||||
// ### replace std::map with lookup tables. ASAP!
|
// ### replace std::map with lookup tables. ASAP!
|
||||||
|
|
||||||
// names
|
// names
|
||||||
std::map<Identifier *, NameId *> nameIds;
|
std::map<const Identifier *, NameId *> nameIds;
|
||||||
std::map<Identifier *, DestructorNameId *> destructorNameIds;
|
std::map<const Identifier *, DestructorNameId *> destructorNameIds;
|
||||||
std::map<int, OperatorNameId *> operatorNameIds;
|
std::map<int, OperatorNameId *> operatorNameIds;
|
||||||
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
|
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
|
||||||
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
|
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
|
||||||
@@ -544,14 +544,14 @@ public:
|
|||||||
std::vector<Symbol *> symbols;
|
std::vector<Symbol *> symbols;
|
||||||
|
|
||||||
// ObjC context keywords:
|
// ObjC context keywords:
|
||||||
Identifier *objcGetterId;
|
const Identifier *objcGetterId;
|
||||||
Identifier *objcSetterId;
|
const Identifier *objcSetterId;
|
||||||
Identifier *objcReadwriteId;
|
const Identifier *objcReadwriteId;
|
||||||
Identifier *objcReadonlyId;
|
const Identifier *objcReadonlyId;
|
||||||
Identifier *objcAssignId;
|
const Identifier *objcAssignId;
|
||||||
Identifier *objcRetainId;
|
const Identifier *objcRetainId;
|
||||||
Identifier *objcCopyId;
|
const Identifier *objcCopyId;
|
||||||
Identifier *objcNonatomicId;
|
const Identifier *objcNonatomicId;
|
||||||
};
|
};
|
||||||
|
|
||||||
Control::Control()
|
Control::Control()
|
||||||
@@ -587,13 +587,13 @@ DiagnosticClient *Control::diagnosticClient() const
|
|||||||
void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
|
void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
|
||||||
{ d->diagnosticClient = diagnosticClient; }
|
{ d->diagnosticClient = diagnosticClient; }
|
||||||
|
|
||||||
Identifier *Control::findIdentifier(const char *chars, unsigned size) const
|
const Identifier *Control::findIdentifier(const char *chars, unsigned size) const
|
||||||
{ return d->identifiers.findLiteral(chars, size); }
|
{ return d->identifiers.findLiteral(chars, size); }
|
||||||
|
|
||||||
Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
|
const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
|
||||||
{ return d->identifiers.findOrInsertLiteral(chars, size); }
|
{ return d->identifiers.findOrInsertLiteral(chars, size); }
|
||||||
|
|
||||||
Identifier *Control::findOrInsertIdentifier(const char *chars)
|
const Identifier *Control::findOrInsertIdentifier(const char *chars)
|
||||||
{
|
{
|
||||||
unsigned length = std::strlen(chars);
|
unsigned length = std::strlen(chars);
|
||||||
return findOrInsertIdentifier(chars, length);
|
return findOrInsertIdentifier(chars, length);
|
||||||
@@ -617,28 +617,28 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const
|
|||||||
Control::NumericLiteralIterator Control::lastNumericLiteral() const
|
Control::NumericLiteralIterator Control::lastNumericLiteral() const
|
||||||
{ return d->numericLiterals.end(); }
|
{ return d->numericLiterals.end(); }
|
||||||
|
|
||||||
StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
|
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
|
||||||
{ return d->stringLiterals.findOrInsertLiteral(chars, size); }
|
{ return d->stringLiterals.findOrInsertLiteral(chars, size); }
|
||||||
|
|
||||||
StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
||||||
{
|
{
|
||||||
unsigned length = std::strlen(chars);
|
unsigned length = std::strlen(chars);
|
||||||
return findOrInsertStringLiteral(chars, length);
|
return findOrInsertStringLiteral(chars, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size)
|
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size)
|
||||||
{ return d->numericLiterals.findOrInsertLiteral(chars, size); }
|
{ return d->numericLiterals.findOrInsertLiteral(chars, size); }
|
||||||
|
|
||||||
NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
||||||
{
|
{
|
||||||
unsigned length = std::strlen(chars);
|
unsigned length = std::strlen(chars);
|
||||||
return findOrInsertNumericLiteral(chars, length);
|
return findOrInsertNumericLiteral(chars, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
NameId *Control::nameId(Identifier *id)
|
NameId *Control::nameId(const Identifier *id)
|
||||||
{ return d->findOrInsertNameId(id); }
|
{ return d->findOrInsertNameId(id); }
|
||||||
|
|
||||||
TemplateNameId *Control::templateNameId(Identifier *id,
|
TemplateNameId *Control::templateNameId(const Identifier *id,
|
||||||
FullySpecifiedType *const args,
|
FullySpecifiedType *const args,
|
||||||
unsigned argv)
|
unsigned argv)
|
||||||
{
|
{
|
||||||
@@ -646,7 +646,7 @@ TemplateNameId *Control::templateNameId(Identifier *id,
|
|||||||
return d->findOrInsertTemplateNameId(id, templateArguments);
|
return d->findOrInsertTemplateNameId(id, templateArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
DestructorNameId *Control::destructorNameId(Identifier *id)
|
DestructorNameId *Control::destructorNameId(const Identifier *id)
|
||||||
{ return d->findOrInsertDestructorNameId(id); }
|
{ return d->findOrInsertDestructorNameId(id); }
|
||||||
|
|
||||||
OperatorNameId *Control::operatorNameId(int kind)
|
OperatorNameId *Control::operatorNameId(int kind)
|
||||||
@@ -755,26 +755,26 @@ ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
|
|||||||
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
|
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
|
||||||
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
|
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
|
||||||
|
|
||||||
Identifier *Control::objcGetterId() const
|
const Identifier *Control::objcGetterId() const
|
||||||
{ return d->objcGetterId; }
|
{ return d->objcGetterId; }
|
||||||
|
|
||||||
Identifier *Control::objcSetterId() const
|
const Identifier *Control::objcSetterId() const
|
||||||
{ return d->objcSetterId; }
|
{ return d->objcSetterId; }
|
||||||
|
|
||||||
Identifier *Control::objcReadwriteId() const
|
const Identifier *Control::objcReadwriteId() const
|
||||||
{ return d->objcReadwriteId; }
|
{ return d->objcReadwriteId; }
|
||||||
|
|
||||||
Identifier *Control::objcReadonlyId() const
|
const Identifier *Control::objcReadonlyId() const
|
||||||
{ return d->objcReadonlyId; }
|
{ return d->objcReadonlyId; }
|
||||||
|
|
||||||
Identifier *Control::objcAssignId() const
|
const Identifier *Control::objcAssignId() const
|
||||||
{ return d->objcAssignId; }
|
{ return d->objcAssignId; }
|
||||||
|
|
||||||
Identifier *Control::objcRetainId() const
|
const Identifier *Control::objcRetainId() const
|
||||||
{ return d->objcRetainId; }
|
{ return d->objcRetainId; }
|
||||||
|
|
||||||
Identifier *Control::objcCopyId() const
|
const Identifier *Control::objcCopyId() const
|
||||||
{ return d->objcCopyId; }
|
{ return d->objcCopyId; }
|
||||||
|
|
||||||
Identifier *Control::objcNonatomicId() const
|
const Identifier *Control::objcNonatomicId() const
|
||||||
{ return d->objcNonatomicId; }
|
{ return d->objcNonatomicId; }
|
||||||
|
@@ -66,15 +66,15 @@ public:
|
|||||||
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
||||||
|
|
||||||
/// Returns the canonical name id.
|
/// Returns the canonical name id.
|
||||||
NameId *nameId(Identifier *id);
|
NameId *nameId(const Identifier *id);
|
||||||
|
|
||||||
/// Returns the canonical template name id.
|
/// Returns the canonical template name id.
|
||||||
TemplateNameId *templateNameId(Identifier *id,
|
TemplateNameId *templateNameId(const Identifier *id,
|
||||||
FullySpecifiedType *const args = 0,
|
FullySpecifiedType *const args = 0,
|
||||||
unsigned argc = 0);
|
unsigned argc = 0);
|
||||||
|
|
||||||
/// Returns the canonical destructor name id.
|
/// Returns the canonical destructor name id.
|
||||||
DestructorNameId *destructorNameId(Identifier *id);
|
DestructorNameId *destructorNameId(const Identifier *id);
|
||||||
|
|
||||||
/// Returns the canonical operator name id.
|
/// Returns the canonical operator name id.
|
||||||
OperatorNameId *operatorNameId(int operatorId);
|
OperatorNameId *operatorNameId(int operatorId);
|
||||||
@@ -171,19 +171,18 @@ public:
|
|||||||
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
|
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
|
||||||
|
|
||||||
// Objective-C specific context keywords.
|
// Objective-C specific context keywords.
|
||||||
Identifier *objcGetterId() const;
|
const Identifier *objcGetterId() const;
|
||||||
Identifier *objcSetterId() const;
|
const Identifier *objcSetterId() const;
|
||||||
Identifier *objcReadwriteId() const;
|
const Identifier *objcReadwriteId() const;
|
||||||
Identifier *objcReadonlyId() const;
|
const Identifier *objcReadonlyId() const;
|
||||||
Identifier *objcAssignId() const;
|
const Identifier *objcAssignId() const;
|
||||||
Identifier *objcRetainId() const;
|
const Identifier *objcRetainId() const;
|
||||||
Identifier *objcCopyId() const;
|
const Identifier *objcCopyId() const;
|
||||||
Identifier *objcNonatomicId() const;
|
const Identifier *objcNonatomicId() const;
|
||||||
|
|
||||||
Identifier *findIdentifier(const char *chars, unsigned size) const;
|
const Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||||
|
const Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
||||||
Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
const Identifier *findOrInsertIdentifier(const char *chars);
|
||||||
Identifier *findOrInsertIdentifier(const char *chars);
|
|
||||||
|
|
||||||
typedef const Identifier *const *IdentifierIterator;
|
typedef const Identifier *const *IdentifierIterator;
|
||||||
typedef const StringLiteral *const *StringLiteralIterator;
|
typedef const StringLiteral *const *StringLiteralIterator;
|
||||||
@@ -198,11 +197,11 @@ public:
|
|||||||
NumericLiteralIterator firstNumericLiteral() const;
|
NumericLiteralIterator firstNumericLiteral() const;
|
||||||
NumericLiteralIterator lastNumericLiteral() const;
|
NumericLiteralIterator lastNumericLiteral() const;
|
||||||
|
|
||||||
StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
||||||
StringLiteral *findOrInsertStringLiteral(const char *chars);
|
const StringLiteral *findOrInsertStringLiteral(const char *chars);
|
||||||
|
|
||||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
||||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
const NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Data;
|
class Data;
|
||||||
|
@@ -71,7 +71,7 @@ public:
|
|||||||
virtual ~DiagnosticClient();
|
virtual ~DiagnosticClient();
|
||||||
|
|
||||||
virtual void report(int level,
|
virtual void report(int level,
|
||||||
StringLiteral *fileName,
|
const StringLiteral *fileName,
|
||||||
unsigned line, unsigned column,
|
unsigned line, unsigned column,
|
||||||
const char *format, va_list ap) = 0;
|
const char *format, va_list ap) = 0;
|
||||||
};
|
};
|
||||||
|
@@ -61,7 +61,7 @@ class LiteralTable
|
|||||||
void operator =(const LiteralTable &other);
|
void operator =(const LiteralTable &other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Literal **iterator;
|
typedef _Literal *const *iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LiteralTable()
|
LiteralTable()
|
||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
unsigned size() const
|
unsigned size() const
|
||||||
{ return _literalCount + 1; }
|
{ return _literalCount + 1; }
|
||||||
|
|
||||||
_Literal *at(unsigned index) const
|
const _Literal *at(unsigned index) const
|
||||||
{ return _literals[index]; }
|
{ return _literals[index]; }
|
||||||
|
|
||||||
iterator begin() const
|
iterator begin() const
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
iterator end() const
|
iterator end() const
|
||||||
{ return _literals + _literalCount + 1; }
|
{ return _literals + _literalCount + 1; }
|
||||||
|
|
||||||
_Literal *findLiteral(const char *chars, unsigned size) const
|
const _Literal *findLiteral(const char *chars, unsigned size) const
|
||||||
{
|
{
|
||||||
if (_buckets) {
|
if (_buckets) {
|
||||||
unsigned h = _Literal::hashCode(chars, size);
|
unsigned h = _Literal::hashCode(chars, size);
|
||||||
@@ -113,7 +113,7 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
const _Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||||
{
|
{
|
||||||
if (_buckets) {
|
if (_buckets) {
|
||||||
unsigned h = _Literal::hashCode(chars, size);
|
unsigned h = _Literal::hashCode(chars, size);
|
||||||
|
@@ -56,14 +56,11 @@ namespace CPlusPlus {
|
|||||||
|
|
||||||
class CPLUSPLUS_EXPORT Name
|
class CPLUSPLUS_EXPORT Name
|
||||||
{
|
{
|
||||||
Name(const Name &other);
|
|
||||||
void operator =(const Name &other);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Name();
|
Name();
|
||||||
virtual ~Name();
|
virtual ~Name();
|
||||||
|
|
||||||
virtual Identifier *identifier() const = 0;
|
virtual const Identifier *identifier() const = 0;
|
||||||
|
|
||||||
bool isNameId() const;
|
bool isNameId() const;
|
||||||
bool isTemplateNameId() const;
|
bool isTemplateNameId() const;
|
||||||
|
@@ -73,7 +73,7 @@ QualifiedNameId::~QualifiedNameId()
|
|||||||
void QualifiedNameId::accept0(NameVisitor *visitor)
|
void QualifiedNameId::accept0(NameVisitor *visitor)
|
||||||
{ visitor->visit(this); }
|
{ visitor->visit(this); }
|
||||||
|
|
||||||
Identifier *QualifiedNameId::identifier() const
|
const Identifier *QualifiedNameId::identifier() const
|
||||||
{
|
{
|
||||||
if (Name *u = unqualifiedNameId())
|
if (Name *u = unqualifiedNameId())
|
||||||
return u->identifier();
|
return u->identifier();
|
||||||
@@ -122,7 +122,7 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NameId::NameId(Identifier *identifier)
|
NameId::NameId(const Identifier *identifier)
|
||||||
: _identifier(identifier)
|
: _identifier(identifier)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ NameId::~NameId()
|
|||||||
void NameId::accept0(NameVisitor *visitor)
|
void NameId::accept0(NameVisitor *visitor)
|
||||||
{ visitor->visit(this); }
|
{ visitor->visit(this); }
|
||||||
|
|
||||||
Identifier *NameId::identifier() const
|
const Identifier *NameId::identifier() const
|
||||||
{ return _identifier; }
|
{ return _identifier; }
|
||||||
|
|
||||||
bool NameId::isEqualTo(const Name *other) const
|
bool NameId::isEqualTo(const Name *other) const
|
||||||
@@ -140,12 +140,12 @@ bool NameId::isEqualTo(const Name *other) const
|
|||||||
const NameId *nameId = other->asNameId();
|
const NameId *nameId = other->asNameId();
|
||||||
if (! nameId)
|
if (! nameId)
|
||||||
return false;
|
return false;
|
||||||
Identifier *l = identifier();
|
const Identifier *l = identifier();
|
||||||
Identifier *r = nameId->identifier();
|
const Identifier *r = nameId->identifier();
|
||||||
return l->isEqualTo(r);
|
return l->isEqualTo(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
DestructorNameId::DestructorNameId(Identifier *identifier)
|
DestructorNameId::DestructorNameId(const Identifier *identifier)
|
||||||
: _identifier(identifier)
|
: _identifier(identifier)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ DestructorNameId::~DestructorNameId()
|
|||||||
void DestructorNameId::accept0(NameVisitor *visitor)
|
void DestructorNameId::accept0(NameVisitor *visitor)
|
||||||
{ visitor->visit(this); }
|
{ visitor->visit(this); }
|
||||||
|
|
||||||
Identifier *DestructorNameId::identifier() const
|
const Identifier *DestructorNameId::identifier() const
|
||||||
{ return _identifier; }
|
{ return _identifier; }
|
||||||
|
|
||||||
bool DestructorNameId::isEqualTo(const Name *other) const
|
bool DestructorNameId::isEqualTo(const Name *other) const
|
||||||
@@ -163,12 +163,12 @@ bool DestructorNameId::isEqualTo(const Name *other) const
|
|||||||
const DestructorNameId *d = other->asDestructorNameId();
|
const DestructorNameId *d = other->asDestructorNameId();
|
||||||
if (! d)
|
if (! d)
|
||||||
return false;
|
return false;
|
||||||
Identifier *l = identifier();
|
const Identifier *l = identifier();
|
||||||
Identifier *r = d->identifier();
|
const Identifier *r = d->identifier();
|
||||||
return l->isEqualTo(r);
|
return l->isEqualTo(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateNameId::TemplateNameId(Identifier *identifier,
|
TemplateNameId::TemplateNameId(const Identifier *identifier,
|
||||||
const FullySpecifiedType templateArguments[],
|
const FullySpecifiedType templateArguments[],
|
||||||
unsigned templateArgumentCount)
|
unsigned templateArgumentCount)
|
||||||
: _identifier(identifier),
|
: _identifier(identifier),
|
||||||
@@ -188,7 +188,7 @@ TemplateNameId::~TemplateNameId()
|
|||||||
void TemplateNameId::accept0(NameVisitor *visitor)
|
void TemplateNameId::accept0(NameVisitor *visitor)
|
||||||
{ visitor->visit(this); }
|
{ visitor->visit(this); }
|
||||||
|
|
||||||
Identifier *TemplateNameId::identifier() const
|
const Identifier *TemplateNameId::identifier() const
|
||||||
{ return _identifier; }
|
{ return _identifier; }
|
||||||
|
|
||||||
unsigned TemplateNameId::templateArgumentCount() const
|
unsigned TemplateNameId::templateArgumentCount() const
|
||||||
@@ -205,8 +205,8 @@ bool TemplateNameId::isEqualTo(const Name *other) const
|
|||||||
const TemplateNameId *t = other->asTemplateNameId();
|
const TemplateNameId *t = other->asTemplateNameId();
|
||||||
if (! t)
|
if (! t)
|
||||||
return false;
|
return false;
|
||||||
Identifier *l = identifier();
|
const Identifier *l = identifier();
|
||||||
Identifier *r = t->identifier();
|
const Identifier *r = t->identifier();
|
||||||
if (! l->isEqualTo(r))
|
if (! l->isEqualTo(r))
|
||||||
return false;
|
return false;
|
||||||
if (_templateArgumentCount != t->_templateArgumentCount)
|
if (_templateArgumentCount != t->_templateArgumentCount)
|
||||||
@@ -233,7 +233,7 @@ void OperatorNameId::accept0(NameVisitor *visitor)
|
|||||||
int OperatorNameId::kind() const
|
int OperatorNameId::kind() const
|
||||||
{ return _kind; }
|
{ return _kind; }
|
||||||
|
|
||||||
Identifier *OperatorNameId::identifier() const
|
const Identifier *OperatorNameId::identifier() const
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
bool OperatorNameId::isEqualTo(const Name *other) const
|
bool OperatorNameId::isEqualTo(const Name *other) const
|
||||||
@@ -257,7 +257,7 @@ void ConversionNameId::accept0(NameVisitor *visitor)
|
|||||||
FullySpecifiedType ConversionNameId::type() const
|
FullySpecifiedType ConversionNameId::type() const
|
||||||
{ return _type; }
|
{ return _type; }
|
||||||
|
|
||||||
Identifier *ConversionNameId::identifier() const
|
const Identifier *ConversionNameId::identifier() const
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
bool ConversionNameId::isEqualTo(const Name *other) const
|
bool ConversionNameId::isEqualTo(const Name *other) const
|
||||||
@@ -287,7 +287,7 @@ SelectorNameId::~SelectorNameId()
|
|||||||
void SelectorNameId::accept0(NameVisitor *visitor)
|
void SelectorNameId::accept0(NameVisitor *visitor)
|
||||||
{ visitor->visit(this); }
|
{ visitor->visit(this); }
|
||||||
|
|
||||||
Identifier *SelectorNameId::identifier() const
|
const Identifier *SelectorNameId::identifier() const
|
||||||
{
|
{
|
||||||
if (! _nameCount)
|
if (! _nameCount)
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
bool isGlobal = false);
|
bool isGlobal = false);
|
||||||
virtual ~QualifiedNameId();
|
virtual ~QualifiedNameId();
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
|
|
||||||
unsigned nameCount() const;
|
unsigned nameCount() const;
|
||||||
Name *nameAt(unsigned index) const;
|
Name *nameAt(unsigned index) const;
|
||||||
@@ -92,10 +92,10 @@ private:
|
|||||||
class CPLUSPLUS_EXPORT NameId: public Name
|
class CPLUSPLUS_EXPORT NameId: public Name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NameId(Identifier *identifier);
|
NameId(const Identifier *identifier);
|
||||||
virtual ~NameId();
|
virtual ~NameId();
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
|
|
||||||
virtual bool isEqualTo(const Name *other) const;
|
virtual bool isEqualTo(const Name *other) const;
|
||||||
|
|
||||||
@@ -109,16 +109,16 @@ protected:
|
|||||||
virtual void accept0(NameVisitor *visitor);
|
virtual void accept0(NameVisitor *visitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Identifier *_identifier;
|
const Identifier *_identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DestructorNameId(Identifier *identifier);
|
DestructorNameId(const Identifier *identifier);
|
||||||
virtual ~DestructorNameId();
|
virtual ~DestructorNameId();
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
|
|
||||||
virtual bool isEqualTo(const Name *other) const;
|
virtual bool isEqualTo(const Name *other) const;
|
||||||
|
|
||||||
@@ -132,18 +132,18 @@ protected:
|
|||||||
virtual void accept0(NameVisitor *visitor);
|
virtual void accept0(NameVisitor *visitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Identifier *_identifier;
|
const Identifier *_identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TemplateNameId(Identifier *identifier,
|
TemplateNameId(const Identifier *identifier,
|
||||||
const FullySpecifiedType templateArguments[],
|
const FullySpecifiedType templateArguments[],
|
||||||
unsigned templateArgumentCount);
|
unsigned templateArgumentCount);
|
||||||
virtual ~TemplateNameId();
|
virtual ~TemplateNameId();
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
|
|
||||||
// ### find a better name
|
// ### find a better name
|
||||||
unsigned templateArgumentCount() const;
|
unsigned templateArgumentCount() const;
|
||||||
@@ -162,7 +162,7 @@ protected:
|
|||||||
virtual void accept0(NameVisitor *visitor);
|
virtual void accept0(NameVisitor *visitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Identifier *_identifier;
|
const Identifier *_identifier;
|
||||||
FullySpecifiedType *_templateArguments;
|
FullySpecifiedType *_templateArguments;
|
||||||
unsigned _templateArgumentCount;
|
unsigned _templateArgumentCount;
|
||||||
};
|
};
|
||||||
@@ -230,7 +230,7 @@ public:
|
|||||||
|
|
||||||
int kind() const;
|
int kind() const;
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
virtual bool isEqualTo(const Name *other) const;
|
virtual bool isEqualTo(const Name *other) const;
|
||||||
|
|
||||||
virtual const OperatorNameId *asOperatorNameId() const
|
virtual const OperatorNameId *asOperatorNameId() const
|
||||||
@@ -254,7 +254,7 @@ public:
|
|||||||
|
|
||||||
FullySpecifiedType type() const;
|
FullySpecifiedType type() const;
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
virtual bool isEqualTo(const Name *other) const;
|
virtual bool isEqualTo(const Name *other) const;
|
||||||
|
|
||||||
virtual const ConversionNameId *asConversionNameId() const
|
virtual const ConversionNameId *asConversionNameId() const
|
||||||
@@ -278,7 +278,7 @@ public:
|
|||||||
bool hasArguments);
|
bool hasArguments);
|
||||||
virtual ~SelectorNameId();
|
virtual ~SelectorNameId();
|
||||||
|
|
||||||
virtual Identifier *identifier() const;
|
virtual const Identifier *identifier() const;
|
||||||
|
|
||||||
unsigned nameCount() const;
|
unsigned nameCount() const;
|
||||||
Name *nameAt(unsigned index) const;
|
Name *nameAt(unsigned index) const;
|
||||||
|
@@ -4981,7 +4981,7 @@ bool Parser::parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node)
|
|||||||
|
|
||||||
node = new (_pool) ObjCPropertyAttributeAST;
|
node = new (_pool) ObjCPropertyAttributeAST;
|
||||||
|
|
||||||
Identifier *id = tok().identifier;
|
const Identifier *id = tok().identifier;
|
||||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case Token_copy:
|
case Token_copy:
|
||||||
@@ -5079,7 +5079,7 @@ bool Parser::parseObjCTypeQualifiers(unsigned &type_qualifier)
|
|||||||
if (LA() != T_IDENTIFIER)
|
if (LA() != T_IDENTIFIER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Identifier *id = tok().identifier;
|
const Identifier *id = tok().identifier;
|
||||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||||
if (k == Token_identifier)
|
if (k == Token_identifier)
|
||||||
return false;
|
return false;
|
||||||
@@ -5092,7 +5092,7 @@ bool Parser::peekAtObjCContextKeyword(int kind)
|
|||||||
if (LA() != T_IDENTIFIER)
|
if (LA() != T_IDENTIFIER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Identifier *id = tok().identifier;
|
const Identifier *id = tok().identifier;
|
||||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||||
return k == kind;
|
return k == kind;
|
||||||
}
|
}
|
||||||
|
@@ -212,14 +212,14 @@ Symbol *Scope::lookat(Name *name) const
|
|||||||
else if (OperatorNameId *opId = name->asOperatorNameId())
|
else if (OperatorNameId *opId = name->asOperatorNameId())
|
||||||
return lookat(opId->kind());
|
return lookat(opId->kind());
|
||||||
|
|
||||||
else if (Identifier *id = name->identifier())
|
else if (const Identifier *id = name->identifier())
|
||||||
return lookat(id);
|
return lookat(id);
|
||||||
|
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol *Scope::lookat(Identifier *id) const
|
Symbol *Scope::lookat(const Identifier *id) const
|
||||||
{
|
{
|
||||||
if (! _hash || ! id)
|
if (! _hash || ! id)
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -130,7 +130,7 @@ public:
|
|||||||
iterator lastSymbol() const;
|
iterator lastSymbol() const;
|
||||||
|
|
||||||
Symbol *lookat(Name *name) const;
|
Symbol *lookat(Name *name) const;
|
||||||
Symbol *lookat(Identifier *id) const;
|
Symbol *lookat(const Identifier *id) const;
|
||||||
Symbol *lookat(int operatorId) const;
|
Symbol *lookat(int operatorId) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -232,7 +232,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation)
|
|||||||
unsigned Symbol::line() const
|
unsigned Symbol::line() const
|
||||||
{
|
{
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileId = 0;
|
const StringLiteral *fileId = 0;
|
||||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
@@ -240,26 +240,26 @@ unsigned Symbol::line() const
|
|||||||
unsigned Symbol::column() const
|
unsigned Symbol::column() const
|
||||||
{
|
{
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileId = 0;
|
const StringLiteral *fileId = 0;
|
||||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringLiteral *Symbol::fileId() const
|
const StringLiteral *Symbol::fileId() const
|
||||||
{
|
{
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileId = 0;
|
const StringLiteral *fileId = 0;
|
||||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||||
return fileId;
|
return fileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Symbol::getPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
void Symbol::getPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||||
{ translationUnit()->getPosition(_sourceOffset, line, column, fileId); }
|
{ translationUnit()->getPosition(_sourceOffset, line, column, fileId); }
|
||||||
|
|
||||||
void Symbol::getStartPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
void Symbol::getStartPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||||
{ translationUnit()->getPosition(_startOffset, line, column, fileId); }
|
{ translationUnit()->getPosition(_startOffset, line, column, fileId); }
|
||||||
|
|
||||||
void Symbol::getEndPosition(unsigned *line, unsigned *column, StringLiteral **fileId) const
|
void Symbol::getEndPosition(unsigned *line, unsigned *column, const StringLiteral **fileId) const
|
||||||
{ translationUnit()->getPosition(_endOffset, line, column, fileId); }
|
{ translationUnit()->getPosition(_endOffset, line, column, fileId); }
|
||||||
|
|
||||||
const char *Symbol::fileName() const
|
const char *Symbol::fileName() const
|
||||||
@@ -302,7 +302,7 @@ void Symbol::setName(Name *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *Symbol::identifier() const
|
const Identifier *Symbol::identifier() const
|
||||||
{
|
{
|
||||||
if (_name)
|
if (_name)
|
||||||
return _name->identifier();
|
return _name->identifier();
|
||||||
|
@@ -102,7 +102,7 @@ public:
|
|||||||
unsigned column() const;
|
unsigned column() const;
|
||||||
|
|
||||||
/// Returns this Symbol's file name.
|
/// Returns this Symbol's file name.
|
||||||
StringLiteral *fileId() const;
|
const StringLiteral *fileId() const;
|
||||||
|
|
||||||
/// Returns this Symbol's file name.
|
/// Returns this Symbol's file name.
|
||||||
const char *fileName() const;
|
const char *fileName() const;
|
||||||
@@ -116,9 +116,9 @@ public:
|
|||||||
unsigned endOffset() const;
|
unsigned endOffset() const;
|
||||||
void setEndOffset(unsigned offset);
|
void setEndOffset(unsigned offset);
|
||||||
|
|
||||||
void getPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
void getPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||||
void getStartPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
void getStartPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||||
void getEndPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||||
|
|
||||||
/// Returns this Symbol's name.
|
/// Returns this Symbol's name.
|
||||||
Name *name() const;
|
Name *name() const;
|
||||||
@@ -127,7 +127,7 @@ public:
|
|||||||
void setName(Name *name); // ### dangerous
|
void setName(Name *name); // ### dangerous
|
||||||
|
|
||||||
/// Returns this Symbol's (optional) identifier
|
/// Returns this Symbol's (optional) identifier
|
||||||
Identifier *identifier() const;
|
const Identifier *identifier() const;
|
||||||
|
|
||||||
/// Returns this Symbol's storage class specifier.
|
/// Returns this Symbol's storage class specifier.
|
||||||
int storage() const;
|
int storage() const;
|
||||||
|
@@ -335,10 +335,10 @@ public:
|
|||||||
|
|
||||||
union {
|
union {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
Literal *literal;
|
const Literal *literal;
|
||||||
NumericLiteral *number;
|
const NumericLiteral *number;
|
||||||
StringLiteral *string;
|
const StringLiteral *string;
|
||||||
Identifier *identifier;
|
const Identifier *identifier;
|
||||||
unsigned close_brace;
|
unsigned close_brace;
|
||||||
unsigned lineno;
|
unsigned lineno;
|
||||||
};
|
};
|
||||||
|
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId)
|
TranslationUnit::TranslationUnit(Control *control, const StringLiteral *fileId)
|
||||||
: _control(control),
|
: _control(control),
|
||||||
_fileId(fileId),
|
_fileId(fileId),
|
||||||
_firstSourceChar(0),
|
_firstSourceChar(0),
|
||||||
@@ -96,7 +96,7 @@ void TranslationUnit::setObjCEnabled(bool onoff)
|
|||||||
Control *TranslationUnit::control() const
|
Control *TranslationUnit::control() const
|
||||||
{ return _control; }
|
{ return _control; }
|
||||||
|
|
||||||
StringLiteral *TranslationUnit::fileId() const
|
const StringLiteral *TranslationUnit::fileId() const
|
||||||
{ return _fileId; }
|
{ return _fileId; }
|
||||||
|
|
||||||
const char *TranslationUnit::fileName() const
|
const char *TranslationUnit::fileName() const
|
||||||
@@ -137,16 +137,16 @@ const char *TranslationUnit::spell(unsigned index) const
|
|||||||
return _tokens->at(index).spell();
|
return _tokens->at(index).spell();
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *TranslationUnit::identifier(unsigned index) const
|
const Identifier *TranslationUnit::identifier(unsigned index) const
|
||||||
{ return _tokens->at(index).identifier; }
|
{ return _tokens->at(index).identifier; }
|
||||||
|
|
||||||
Literal *TranslationUnit::literal(unsigned index) const
|
const Literal *TranslationUnit::literal(unsigned index) const
|
||||||
{ return _tokens->at(index).literal; }
|
{ return _tokens->at(index).literal; }
|
||||||
|
|
||||||
StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
const StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||||
{ return _tokens->at(index).string; }
|
{ return _tokens->at(index).string; }
|
||||||
|
|
||||||
NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
const NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||||
{ return _tokens->at(index).number; }
|
{ return _tokens->at(index).number; }
|
||||||
|
|
||||||
unsigned TranslationUnit::matchingBrace(unsigned index) const
|
unsigned TranslationUnit::matchingBrace(unsigned index) const
|
||||||
@@ -181,8 +181,8 @@ void TranslationUnit::tokenize()
|
|||||||
pushLineOffset(0);
|
pushLineOffset(0);
|
||||||
pushPreprocessorLine(0, 1, fileId());
|
pushPreprocessorLine(0, 1, fileId());
|
||||||
|
|
||||||
Identifier *lineId = control()->findOrInsertIdentifier("line");
|
const Identifier *lineId = control()->findOrInsertIdentifier("line");
|
||||||
Identifier *genId = control()->findOrInsertIdentifier("gen");
|
const Identifier *genId = control()->findOrInsertIdentifier("gen");
|
||||||
|
|
||||||
bool generated = false;
|
bool generated = false;
|
||||||
Token tk;
|
Token tk;
|
||||||
@@ -211,7 +211,7 @@ void TranslationUnit::tokenize()
|
|||||||
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
||||||
lex(&tk);
|
lex(&tk);
|
||||||
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
||||||
StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||||
tk.string->size());
|
tk.string->size());
|
||||||
pushPreprocessorLine(offset, line, fileName);
|
pushPreprocessorLine(offset, line, fileName);
|
||||||
lex(&tk);
|
lex(&tk);
|
||||||
@@ -303,7 +303,7 @@ void TranslationUnit::pushLineOffset(unsigned offset)
|
|||||||
|
|
||||||
void TranslationUnit::pushPreprocessorLine(unsigned offset,
|
void TranslationUnit::pushPreprocessorLine(unsigned offset,
|
||||||
unsigned line,
|
unsigned line,
|
||||||
StringLiteral *fileName)
|
const StringLiteral *fileName)
|
||||||
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
|
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
|
||||||
|
|
||||||
unsigned TranslationUnit::findLineNumber(unsigned offset) const
|
unsigned TranslationUnit::findLineNumber(unsigned offset) const
|
||||||
@@ -339,23 +339,23 @@ unsigned TranslationUnit::findColumnNumber(unsigned offset, unsigned lineNumber)
|
|||||||
void TranslationUnit::getTokenPosition(unsigned index,
|
void TranslationUnit::getTokenPosition(unsigned index,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{ return getPosition(tokenAt(index).offset, line, column, fileName); }
|
{ return getPosition(tokenAt(index).offset, line, column, fileName); }
|
||||||
|
|
||||||
void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line,
|
void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{ return getPosition(tokenAt(index).begin(), line, column, fileName); }
|
{ return getPosition(tokenAt(index).begin(), line, column, fileName); }
|
||||||
|
|
||||||
void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line,
|
void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{ return getPosition(tokenAt(index).end(), line, column, fileName); }
|
{ return getPosition(tokenAt(index).end(), line, column, fileName); }
|
||||||
|
|
||||||
void TranslationUnit::getPosition(unsigned tokenOffset,
|
void TranslationUnit::getPosition(unsigned tokenOffset,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column,
|
unsigned *column,
|
||||||
StringLiteral **fileName) const
|
const StringLiteral **fileName) const
|
||||||
{
|
{
|
||||||
unsigned lineNumber = findLineNumber(tokenOffset);
|
unsigned lineNumber = findLineNumber(tokenOffset);
|
||||||
unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber);
|
unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber);
|
||||||
@@ -389,7 +389,7 @@ void TranslationUnit::warning(unsigned index, const char *format, ...)
|
|||||||
index = std::min(index, tokenCount() - 1);
|
index = std::min(index, tokenCount() - 1);
|
||||||
|
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileName = 0;
|
const StringLiteral *fileName = 0;
|
||||||
getTokenPosition(index, &line, &column, &fileName);
|
getTokenPosition(index, &line, &column, &fileName);
|
||||||
|
|
||||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||||
@@ -420,7 +420,7 @@ void TranslationUnit::error(unsigned index, const char *format, ...)
|
|||||||
index = std::min(index, tokenCount() - 1);
|
index = std::min(index, tokenCount() - 1);
|
||||||
|
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileName = 0;
|
const StringLiteral *fileName = 0;
|
||||||
getTokenPosition(index, &line, &column, &fileName);
|
getTokenPosition(index, &line, &column, &fileName);
|
||||||
|
|
||||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||||
@@ -451,7 +451,7 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...)
|
|||||||
index = std::min(index, tokenCount() - 1);
|
index = std::min(index, tokenCount() - 1);
|
||||||
|
|
||||||
unsigned line = 0, column = 0;
|
unsigned line = 0, column = 0;
|
||||||
StringLiteral *fileName = 0;
|
const StringLiteral *fileName = 0;
|
||||||
getTokenPosition(index, &line, &column, &fileName);
|
getTokenPosition(index, &line, &column, &fileName);
|
||||||
|
|
||||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||||
|
@@ -65,12 +65,12 @@ class CPLUSPLUS_EXPORT TranslationUnit
|
|||||||
void operator =(const TranslationUnit &other);
|
void operator =(const TranslationUnit &other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TranslationUnit(Control *control, StringLiteral *fileId);
|
TranslationUnit(Control *control, const StringLiteral *fileId);
|
||||||
~TranslationUnit();
|
~TranslationUnit();
|
||||||
|
|
||||||
Control *control() const;
|
Control *control() const;
|
||||||
|
|
||||||
StringLiteral *fileId() const;
|
const StringLiteral *fileId() const;
|
||||||
const char *fileName() const;
|
const char *fileName() const;
|
||||||
unsigned fileNameLength() const;
|
unsigned fileNameLength() const;
|
||||||
|
|
||||||
@@ -86,10 +86,10 @@ public:
|
|||||||
const char *spell(unsigned index) const;
|
const char *spell(unsigned index) const;
|
||||||
|
|
||||||
unsigned matchingBrace(unsigned index) const;
|
unsigned matchingBrace(unsigned index) const;
|
||||||
Identifier *identifier(unsigned index) const;
|
const Identifier *identifier(unsigned index) const;
|
||||||
Literal *literal(unsigned index) const;
|
const Literal *literal(unsigned index) const;
|
||||||
StringLiteral *stringLiteral(unsigned index) const;
|
const StringLiteral *stringLiteral(unsigned index) const;
|
||||||
NumericLiteral *numericLiteral(unsigned index) const;
|
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||||
|
|
||||||
MemoryPool *memoryPool() const;
|
MemoryPool *memoryPool() const;
|
||||||
AST *ast() const;
|
AST *ast() const;
|
||||||
@@ -129,26 +129,26 @@ public:
|
|||||||
|
|
||||||
void getTokenStartPosition(unsigned index, unsigned *line,
|
void getTokenStartPosition(unsigned index, unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void getTokenEndPosition(unsigned index, unsigned *line,
|
void getTokenEndPosition(unsigned index, unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void getPosition(unsigned offset,
|
void getPosition(unsigned offset,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void getTokenPosition(unsigned index,
|
void getTokenPosition(unsigned index,
|
||||||
unsigned *line,
|
unsigned *line,
|
||||||
unsigned *column = 0,
|
unsigned *column = 0,
|
||||||
StringLiteral **fileName = 0) const;
|
const StringLiteral **fileName = 0) const;
|
||||||
|
|
||||||
void pushLineOffset(unsigned offset);
|
void pushLineOffset(unsigned offset);
|
||||||
void pushPreprocessorLine(unsigned offset,
|
void pushPreprocessorLine(unsigned offset,
|
||||||
unsigned line,
|
unsigned line,
|
||||||
StringLiteral *fileName);
|
const StringLiteral *fileName);
|
||||||
|
|
||||||
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
|
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
|
||||||
|
|
||||||
@@ -156,11 +156,11 @@ public:
|
|||||||
struct PPLine {
|
struct PPLine {
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
unsigned line;
|
unsigned line;
|
||||||
StringLiteral *fileName;
|
const StringLiteral *fileName;
|
||||||
|
|
||||||
PPLine(unsigned offset = 0,
|
PPLine(unsigned offset = 0,
|
||||||
unsigned line = 0,
|
unsigned line = 0,
|
||||||
StringLiteral *fileName = 0)
|
const StringLiteral *fileName = 0)
|
||||||
: offset(offset), line(line), fileName(fileName)
|
: offset(offset), line(line), fileName(fileName)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ private:
|
|||||||
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
||||||
|
|
||||||
Control *_control;
|
Control *_control;
|
||||||
StringLiteral *_fileId;
|
const StringLiteral *_fileId;
|
||||||
const char *_firstSourceChar;
|
const char *_firstSourceChar;
|
||||||
const char *_lastSourceChar;
|
const char *_lastSourceChar;
|
||||||
Array<Token, 8> *_tokens;
|
Array<Token, 8> *_tokens;
|
||||||
|
Reference in New Issue
Block a user