forked from qt-creator/qt-creator
Use const literals.
This commit is contained in:
@@ -89,28 +89,28 @@ int ASTVisitor::tokenKind(unsigned index) const
|
||||
const char *ASTVisitor::spell(unsigned index) const
|
||||
{ return translationUnit()->spell(index); }
|
||||
|
||||
Identifier *ASTVisitor::identifier(unsigned index) const
|
||||
const Identifier *ASTVisitor::identifier(unsigned index) const
|
||||
{ return translationUnit()->identifier(index); }
|
||||
|
||||
Literal *ASTVisitor::literal(unsigned index) const
|
||||
const Literal *ASTVisitor::literal(unsigned index) const
|
||||
{ return translationUnit()->literal(index); }
|
||||
|
||||
NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||
const NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||
{ return translationUnit()->numericLiteral(index); }
|
||||
|
||||
StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||
const StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||
{ return translationUnit()->stringLiteral(index); }
|
||||
|
||||
void ASTVisitor::getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getPosition(offset, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
|
||||
|
||||
@@ -72,20 +72,20 @@ public:
|
||||
const Token &tokenAt(unsigned index) const;
|
||||
int tokenKind(unsigned index) const;
|
||||
const char *spell(unsigned index) const;
|
||||
Identifier *identifier(unsigned index) const;
|
||||
Literal *literal(unsigned index) const;
|
||||
NumericLiteral *numericLiteral(unsigned index) const;
|
||||
StringLiteral *stringLiteral(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenStartPosition(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)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
Name *namespaceName = control()->nameId(id);
|
||||
|
||||
unsigned sourceLocation = ast->firstToken();
|
||||
@@ -718,7 +718,7 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
|
||||
if (!attrAst)
|
||||
continue;
|
||||
|
||||
Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
||||
const Identifier *attrId = identifier(attrAst->attribute_identifier_token);
|
||||
if (attrId == control()->objcGetterId()) {
|
||||
if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) {
|
||||
getterName = semantic()->check(attrAst->method_selector, _scope);
|
||||
|
||||
@@ -343,7 +343,7 @@ bool CheckName::visit(ConversionFunctionIdAST *ast)
|
||||
|
||||
bool CheckName::visit(SimpleNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
_name = control()->nameId(id);
|
||||
ast->name = _name;
|
||||
return false;
|
||||
@@ -351,7 +351,7 @@ bool CheckName::visit(SimpleNameAST *ast)
|
||||
|
||||
bool CheckName::visit(DestructorNameAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
_name = control()->destructorNameId(id);
|
||||
ast->name = _name;
|
||||
return false;
|
||||
@@ -359,7 +359,7 @@ bool CheckName::visit(DestructorNameAST *ast)
|
||||
|
||||
bool CheckName::visit(TemplateIdAST *ast)
|
||||
{
|
||||
Identifier *id = identifier(ast->identifier_token);
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
std::vector<FullySpecifiedType> templateArguments;
|
||||
for (TemplateArgumentListAST *it = ast->template_argument_list; it;
|
||||
it = it->next) {
|
||||
@@ -380,7 +380,7 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
|
||||
{
|
||||
if (ast->name_token) {
|
||||
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);
|
||||
names.push_back(nameId);
|
||||
_name = control()->selectorNameId(&names[0], names.size(), false);
|
||||
@@ -395,7 +395,7 @@ bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
|
||||
std::vector<Name *> names;
|
||||
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
|
||||
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);
|
||||
names.push_back(nameId);
|
||||
} else {
|
||||
@@ -420,7 +420,7 @@ bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
|
||||
type = semantic()->check(ast->type_name, _scope);
|
||||
|
||||
if (ast->param_name_token) {
|
||||
Identifier *id = identifier(ast->param_name_token);
|
||||
const Identifier *id = identifier(ast->param_name_token);
|
||||
_name = control()->nameId(id);
|
||||
ast->name = _name;
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
|
||||
_fullySpecifiedType.setType(e);
|
||||
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
|
||||
EnumeratorAST *enumerator = it->value;
|
||||
Identifier *id = identifier(enumerator->identifier_token);
|
||||
const Identifier *id = identifier(enumerator->identifier_token);
|
||||
if (! id)
|
||||
continue;
|
||||
NameId *enumeratorName = control()->nameId(id);
|
||||
@@ -403,7 +403,7 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
|
||||
bool CheckSpecifier::visit(AttributeSpecifierAST * /*ast*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -184,17 +184,17 @@ public:
|
||||
delete_array_entries(symbols);
|
||||
}
|
||||
|
||||
NameId *findOrInsertNameId(Identifier *id)
|
||||
NameId *findOrInsertNameId(const Identifier *id)
|
||||
{
|
||||
if (! id)
|
||||
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)
|
||||
it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
|
||||
return it->second;
|
||||
}
|
||||
|
||||
TemplateNameId *findOrInsertTemplateNameId(Identifier *id,
|
||||
TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
|
||||
const std::vector<FullySpecifiedType> &templateArguments)
|
||||
{
|
||||
if (! id)
|
||||
@@ -213,11 +213,11 @@ public:
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DestructorNameId *findOrInsertDestructorNameId(Identifier *id)
|
||||
DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
|
||||
{
|
||||
if (! id)
|
||||
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)
|
||||
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
|
||||
return it->second;
|
||||
@@ -441,10 +441,10 @@ public:
|
||||
}
|
||||
|
||||
struct TemplateNameIdKey {
|
||||
Identifier *id;
|
||||
const Identifier *id;
|
||||
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)
|
||||
{ }
|
||||
|
||||
@@ -522,8 +522,8 @@ public:
|
||||
// ### replace std::map with lookup tables. ASAP!
|
||||
|
||||
// names
|
||||
std::map<Identifier *, NameId *> nameIds;
|
||||
std::map<Identifier *, DestructorNameId *> destructorNameIds;
|
||||
std::map<const Identifier *, NameId *> nameIds;
|
||||
std::map<const Identifier *, DestructorNameId *> destructorNameIds;
|
||||
std::map<int, OperatorNameId *> operatorNameIds;
|
||||
std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
|
||||
std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
|
||||
@@ -544,14 +544,14 @@ public:
|
||||
std::vector<Symbol *> symbols;
|
||||
|
||||
// ObjC context keywords:
|
||||
Identifier *objcGetterId;
|
||||
Identifier *objcSetterId;
|
||||
Identifier *objcReadwriteId;
|
||||
Identifier *objcReadonlyId;
|
||||
Identifier *objcAssignId;
|
||||
Identifier *objcRetainId;
|
||||
Identifier *objcCopyId;
|
||||
Identifier *objcNonatomicId;
|
||||
const Identifier *objcGetterId;
|
||||
const Identifier *objcSetterId;
|
||||
const Identifier *objcReadwriteId;
|
||||
const Identifier *objcReadonlyId;
|
||||
const Identifier *objcAssignId;
|
||||
const Identifier *objcRetainId;
|
||||
const Identifier *objcCopyId;
|
||||
const Identifier *objcNonatomicId;
|
||||
};
|
||||
|
||||
Control::Control()
|
||||
@@ -587,13 +587,13 @@ DiagnosticClient *Control::diagnosticClient() const
|
||||
void Control::setDiagnosticClient(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); }
|
||||
|
||||
Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
|
||||
const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned 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);
|
||||
return findOrInsertIdentifier(chars, length);
|
||||
@@ -617,36 +617,36 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const
|
||||
Control::NumericLiteralIterator Control::lastNumericLiteral() const
|
||||
{ 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); }
|
||||
|
||||
StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
||||
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
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); }
|
||||
|
||||
NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
||||
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return findOrInsertNumericLiteral(chars, length);
|
||||
}
|
||||
|
||||
NameId *Control::nameId(Identifier *id)
|
||||
NameId *Control::nameId(const Identifier *id)
|
||||
{ return d->findOrInsertNameId(id); }
|
||||
|
||||
TemplateNameId *Control::templateNameId(Identifier *id,
|
||||
FullySpecifiedType *const args,
|
||||
unsigned argv)
|
||||
TemplateNameId *Control::templateNameId(const Identifier *id,
|
||||
FullySpecifiedType *const args,
|
||||
unsigned argv)
|
||||
{
|
||||
std::vector<FullySpecifiedType> templateArguments(args, args + argv);
|
||||
return d->findOrInsertTemplateNameId(id, templateArguments);
|
||||
}
|
||||
|
||||
DestructorNameId *Control::destructorNameId(Identifier *id)
|
||||
DestructorNameId *Control::destructorNameId(const Identifier *id)
|
||||
{ return d->findOrInsertDestructorNameId(id); }
|
||||
|
||||
OperatorNameId *Control::operatorNameId(int kind)
|
||||
@@ -755,26 +755,26 @@ ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
|
||||
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
|
||||
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
|
||||
|
||||
Identifier *Control::objcGetterId() const
|
||||
const Identifier *Control::objcGetterId() const
|
||||
{ return d->objcGetterId; }
|
||||
|
||||
Identifier *Control::objcSetterId() const
|
||||
const Identifier *Control::objcSetterId() const
|
||||
{ return d->objcSetterId; }
|
||||
|
||||
Identifier *Control::objcReadwriteId() const
|
||||
const Identifier *Control::objcReadwriteId() const
|
||||
{ return d->objcReadwriteId; }
|
||||
|
||||
Identifier *Control::objcReadonlyId() const
|
||||
const Identifier *Control::objcReadonlyId() const
|
||||
{ return d->objcReadonlyId; }
|
||||
|
||||
Identifier *Control::objcAssignId() const
|
||||
const Identifier *Control::objcAssignId() const
|
||||
{ return d->objcAssignId; }
|
||||
|
||||
Identifier *Control::objcRetainId() const
|
||||
const Identifier *Control::objcRetainId() const
|
||||
{ return d->objcRetainId; }
|
||||
|
||||
Identifier *Control::objcCopyId() const
|
||||
const Identifier *Control::objcCopyId() const
|
||||
{ return d->objcCopyId; }
|
||||
|
||||
Identifier *Control::objcNonatomicId() const
|
||||
const Identifier *Control::objcNonatomicId() const
|
||||
{ return d->objcNonatomicId; }
|
||||
|
||||
@@ -66,15 +66,15 @@ public:
|
||||
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
||||
|
||||
/// Returns the canonical name id.
|
||||
NameId *nameId(Identifier *id);
|
||||
NameId *nameId(const Identifier *id);
|
||||
|
||||
/// Returns the canonical template name id.
|
||||
TemplateNameId *templateNameId(Identifier *id,
|
||||
TemplateNameId *templateNameId(const Identifier *id,
|
||||
FullySpecifiedType *const args = 0,
|
||||
unsigned argc = 0);
|
||||
|
||||
/// Returns the canonical destructor name id.
|
||||
DestructorNameId *destructorNameId(Identifier *id);
|
||||
DestructorNameId *destructorNameId(const Identifier *id);
|
||||
|
||||
/// Returns the canonical operator name id.
|
||||
OperatorNameId *operatorNameId(int operatorId);
|
||||
@@ -171,19 +171,18 @@ public:
|
||||
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
|
||||
|
||||
// Objective-C specific context keywords.
|
||||
Identifier *objcGetterId() const;
|
||||
Identifier *objcSetterId() const;
|
||||
Identifier *objcReadwriteId() const;
|
||||
Identifier *objcReadonlyId() const;
|
||||
Identifier *objcAssignId() const;
|
||||
Identifier *objcRetainId() const;
|
||||
Identifier *objcCopyId() const;
|
||||
Identifier *objcNonatomicId() const;
|
||||
const Identifier *objcGetterId() const;
|
||||
const Identifier *objcSetterId() const;
|
||||
const Identifier *objcReadwriteId() const;
|
||||
const Identifier *objcReadonlyId() const;
|
||||
const Identifier *objcAssignId() const;
|
||||
const Identifier *objcRetainId() const;
|
||||
const Identifier *objcCopyId() const;
|
||||
const Identifier *objcNonatomicId() const;
|
||||
|
||||
Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||
|
||||
Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
||||
Identifier *findOrInsertIdentifier(const char *chars);
|
||||
const Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||
const Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
|
||||
const Identifier *findOrInsertIdentifier(const char *chars);
|
||||
|
||||
typedef const Identifier *const *IdentifierIterator;
|
||||
typedef const StringLiteral *const *StringLiteralIterator;
|
||||
@@ -198,11 +197,11 @@ public:
|
||||
NumericLiteralIterator firstNumericLiteral() const;
|
||||
NumericLiteralIterator lastNumericLiteral() const;
|
||||
|
||||
StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
||||
StringLiteral *findOrInsertStringLiteral(const char *chars);
|
||||
const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
|
||||
const StringLiteral *findOrInsertStringLiteral(const char *chars);
|
||||
|
||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
||||
NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
||||
const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
|
||||
const NumericLiteral *findOrInsertNumericLiteral(const char *chars);
|
||||
|
||||
private:
|
||||
class Data;
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
virtual ~DiagnosticClient();
|
||||
|
||||
virtual void report(int level,
|
||||
StringLiteral *fileName,
|
||||
const StringLiteral *fileName,
|
||||
unsigned line, unsigned column,
|
||||
const char *format, va_list ap) = 0;
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ class LiteralTable
|
||||
void operator =(const LiteralTable &other);
|
||||
|
||||
public:
|
||||
typedef _Literal **iterator;
|
||||
typedef _Literal *const *iterator;
|
||||
|
||||
public:
|
||||
LiteralTable()
|
||||
@@ -74,14 +74,14 @@ public:
|
||||
|
||||
~LiteralTable()
|
||||
{
|
||||
if (_literals) {
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
if (_literals) {
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
unsigned size() const
|
||||
{ return _literalCount + 1; }
|
||||
|
||||
_Literal *at(unsigned index) const
|
||||
const _Literal *at(unsigned index) const
|
||||
{ return _literals[index]; }
|
||||
|
||||
iterator begin() const
|
||||
@@ -99,53 +99,53 @@ public:
|
||||
iterator end() const
|
||||
{ return _literals + _literalCount + 1; }
|
||||
|
||||
_Literal *findLiteral(const char *chars, unsigned size) const
|
||||
const _Literal *findLiteral(const char *chars, unsigned size) const
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||
const _Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
_Literal *literal = new _Literal(chars, size);
|
||||
_Literal *literal = new _Literal(chars, size);
|
||||
|
||||
if (++_literalCount == _allocatedLiterals) {
|
||||
_allocatedLiterals <<= 1;
|
||||
if (++_literalCount == _allocatedLiterals) {
|
||||
_allocatedLiterals <<= 1;
|
||||
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 256;
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 256;
|
||||
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
|
||||
_literals[_literalCount] = literal;
|
||||
_literals[_literalCount] = literal;
|
||||
|
||||
if (! _buckets || _literalCount >= _allocatedBuckets * .6)
|
||||
rehash();
|
||||
else {
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
if (! _buckets || _literalCount >= _allocatedBuckets * .6)
|
||||
rehash();
|
||||
else {
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
|
||||
return literal;
|
||||
return literal;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -56,14 +56,11 @@ namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Name
|
||||
{
|
||||
Name(const Name &other);
|
||||
void operator =(const Name &other);
|
||||
|
||||
public:
|
||||
Name();
|
||||
virtual ~Name();
|
||||
|
||||
virtual Identifier *identifier() const = 0;
|
||||
virtual const Identifier *identifier() const = 0;
|
||||
|
||||
bool isNameId() const;
|
||||
bool isTemplateNameId() const;
|
||||
|
||||
@@ -73,7 +73,7 @@ QualifiedNameId::~QualifiedNameId()
|
||||
void QualifiedNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *QualifiedNameId::identifier() const
|
||||
const Identifier *QualifiedNameId::identifier() const
|
||||
{
|
||||
if (Name *u = unqualifiedNameId())
|
||||
return u->identifier();
|
||||
@@ -122,7 +122,7 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
|
||||
return true;
|
||||
}
|
||||
|
||||
NameId::NameId(Identifier *identifier)
|
||||
NameId::NameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
{ }
|
||||
|
||||
@@ -132,7 +132,7 @@ NameId::~NameId()
|
||||
void NameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *NameId::identifier() const
|
||||
const Identifier *NameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
bool NameId::isEqualTo(const Name *other) const
|
||||
@@ -140,12 +140,12 @@ bool NameId::isEqualTo(const Name *other) const
|
||||
const NameId *nameId = other->asNameId();
|
||||
if (! nameId)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = nameId->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = nameId->identifier();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
|
||||
DestructorNameId::DestructorNameId(Identifier *identifier)
|
||||
DestructorNameId::DestructorNameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
{ }
|
||||
|
||||
@@ -155,7 +155,7 @@ DestructorNameId::~DestructorNameId()
|
||||
void DestructorNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *DestructorNameId::identifier() const
|
||||
const Identifier *DestructorNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
@@ -163,12 +163,12 @@ bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
const DestructorNameId *d = other->asDestructorNameId();
|
||||
if (! d)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = d->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = d->identifier();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
|
||||
TemplateNameId::TemplateNameId(Identifier *identifier,
|
||||
TemplateNameId::TemplateNameId(const Identifier *identifier,
|
||||
const FullySpecifiedType templateArguments[],
|
||||
unsigned templateArgumentCount)
|
||||
: _identifier(identifier),
|
||||
@@ -188,7 +188,7 @@ TemplateNameId::~TemplateNameId()
|
||||
void TemplateNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *TemplateNameId::identifier() const
|
||||
const Identifier *TemplateNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
unsigned TemplateNameId::templateArgumentCount() const
|
||||
@@ -205,8 +205,8 @@ bool TemplateNameId::isEqualTo(const Name *other) const
|
||||
const TemplateNameId *t = other->asTemplateNameId();
|
||||
if (! t)
|
||||
return false;
|
||||
Identifier *l = identifier();
|
||||
Identifier *r = t->identifier();
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = t->identifier();
|
||||
if (! l->isEqualTo(r))
|
||||
return false;
|
||||
if (_templateArgumentCount != t->_templateArgumentCount)
|
||||
@@ -233,7 +233,7 @@ void OperatorNameId::accept0(NameVisitor *visitor)
|
||||
int OperatorNameId::kind() const
|
||||
{ return _kind; }
|
||||
|
||||
Identifier *OperatorNameId::identifier() const
|
||||
const Identifier *OperatorNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool OperatorNameId::isEqualTo(const Name *other) const
|
||||
@@ -257,7 +257,7 @@ void ConversionNameId::accept0(NameVisitor *visitor)
|
||||
FullySpecifiedType ConversionNameId::type() const
|
||||
{ return _type; }
|
||||
|
||||
Identifier *ConversionNameId::identifier() const
|
||||
const Identifier *ConversionNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool ConversionNameId::isEqualTo(const Name *other) const
|
||||
@@ -287,7 +287,7 @@ SelectorNameId::~SelectorNameId()
|
||||
void SelectorNameId::accept0(NameVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
Identifier *SelectorNameId::identifier() const
|
||||
const Identifier *SelectorNameId::identifier() const
|
||||
{
|
||||
if (! _nameCount)
|
||||
return 0;
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
bool isGlobal = false);
|
||||
virtual ~QualifiedNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
unsigned nameCount() const;
|
||||
Name *nameAt(unsigned index) const;
|
||||
@@ -92,10 +92,10 @@ private:
|
||||
class CPLUSPLUS_EXPORT NameId: public Name
|
||||
{
|
||||
public:
|
||||
NameId(Identifier *identifier);
|
||||
NameId(const Identifier *identifier);
|
||||
virtual ~NameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
@@ -109,16 +109,16 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
||||
{
|
||||
public:
|
||||
DestructorNameId(Identifier *identifier);
|
||||
DestructorNameId(const Identifier *identifier);
|
||||
virtual ~DestructorNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
@@ -132,18 +132,18 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||
{
|
||||
public:
|
||||
TemplateNameId(Identifier *identifier,
|
||||
TemplateNameId(const Identifier *identifier,
|
||||
const FullySpecifiedType templateArguments[],
|
||||
unsigned templateArgumentCount);
|
||||
virtual ~TemplateNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
// ### find a better name
|
||||
unsigned templateArgumentCount() const;
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor);
|
||||
|
||||
private:
|
||||
Identifier *_identifier;
|
||||
const Identifier *_identifier;
|
||||
FullySpecifiedType *_templateArguments;
|
||||
unsigned _templateArgumentCount;
|
||||
};
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
|
||||
int kind() const;
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const OperatorNameId *asOperatorNameId() const
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
|
||||
FullySpecifiedType type() const;
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const ConversionNameId *asConversionNameId() const
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
bool hasArguments);
|
||||
virtual ~SelectorNameId();
|
||||
|
||||
virtual Identifier *identifier() const;
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
unsigned nameCount() const;
|
||||
Name *nameAt(unsigned index) const;
|
||||
|
||||
@@ -4981,7 +4981,7 @@ bool Parser::parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node)
|
||||
|
||||
node = new (_pool) ObjCPropertyAttributeAST;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
switch (k) {
|
||||
case Token_copy:
|
||||
@@ -5079,7 +5079,7 @@ bool Parser::parseObjCTypeQualifiers(unsigned &type_qualifier)
|
||||
if (LA() != T_IDENTIFIER)
|
||||
return false;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
if (k == Token_identifier)
|
||||
return false;
|
||||
@@ -5092,7 +5092,7 @@ bool Parser::peekAtObjCContextKeyword(int kind)
|
||||
if (LA() != T_IDENTIFIER)
|
||||
return false;
|
||||
|
||||
Identifier *id = tok().identifier;
|
||||
const Identifier *id = tok().identifier;
|
||||
const int k = classifyObjectiveCTypeQualifiers(id->chars(), id->size());
|
||||
return k == kind;
|
||||
}
|
||||
|
||||
@@ -212,14 +212,14 @@ Symbol *Scope::lookat(Name *name) const
|
||||
else if (OperatorNameId *opId = name->asOperatorNameId())
|
||||
return lookat(opId->kind());
|
||||
|
||||
else if (Identifier *id = name->identifier())
|
||||
else if (const Identifier *id = name->identifier())
|
||||
return lookat(id);
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Symbol *Scope::lookat(Identifier *id) const
|
||||
Symbol *Scope::lookat(const Identifier *id) const
|
||||
{
|
||||
if (! _hash || ! id)
|
||||
return 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
iterator lastSymbol() const;
|
||||
|
||||
Symbol *lookat(Name *name) const;
|
||||
Symbol *lookat(Identifier *id) const;
|
||||
Symbol *lookat(const Identifier *id) const;
|
||||
Symbol *lookat(int operatorId) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -232,7 +232,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation)
|
||||
unsigned Symbol::line() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||
return line;
|
||||
}
|
||||
@@ -240,26 +240,26 @@ unsigned Symbol::line() const
|
||||
unsigned Symbol::column() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &fileId);
|
||||
return column;
|
||||
}
|
||||
|
||||
StringLiteral *Symbol::fileId() const
|
||||
const StringLiteral *Symbol::fileId() const
|
||||
{
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileId = 0;
|
||||
const StringLiteral *fileId = 0;
|
||||
translationUnit()->getPosition(_sourceOffset, &line, &column, &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); }
|
||||
|
||||
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); }
|
||||
|
||||
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); }
|
||||
|
||||
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)
|
||||
return _name->identifier();
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
unsigned column() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
StringLiteral *fileId() const;
|
||||
const StringLiteral *fileId() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
const char *fileName() const;
|
||||
@@ -116,9 +116,9 @@ public:
|
||||
unsigned endOffset() const;
|
||||
void setEndOffset(unsigned offset);
|
||||
|
||||
void getPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
||||
void getStartPosition(unsigned *line, unsigned *column = 0, StringLiteral **fileId = 0) const;
|
||||
void getEndPosition(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, const StringLiteral **fileId = 0) const;
|
||||
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
|
||||
|
||||
/// Returns this Symbol's name.
|
||||
Name *name() const;
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
void setName(Name *name); // ### dangerous
|
||||
|
||||
/// Returns this Symbol's (optional) identifier
|
||||
Identifier *identifier() const;
|
||||
const Identifier *identifier() const;
|
||||
|
||||
/// Returns this Symbol's storage class specifier.
|
||||
int storage() const;
|
||||
|
||||
@@ -335,10 +335,10 @@ public:
|
||||
|
||||
union {
|
||||
void *ptr;
|
||||
Literal *literal;
|
||||
NumericLiteral *number;
|
||||
StringLiteral *string;
|
||||
Identifier *identifier;
|
||||
const Literal *literal;
|
||||
const NumericLiteral *number;
|
||||
const StringLiteral *string;
|
||||
const Identifier *identifier;
|
||||
unsigned close_brace;
|
||||
unsigned lineno;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId)
|
||||
TranslationUnit::TranslationUnit(Control *control, const StringLiteral *fileId)
|
||||
: _control(control),
|
||||
_fileId(fileId),
|
||||
_firstSourceChar(0),
|
||||
@@ -96,7 +96,7 @@ void TranslationUnit::setObjCEnabled(bool onoff)
|
||||
Control *TranslationUnit::control() const
|
||||
{ return _control; }
|
||||
|
||||
StringLiteral *TranslationUnit::fileId() const
|
||||
const StringLiteral *TranslationUnit::fileId() const
|
||||
{ return _fileId; }
|
||||
|
||||
const char *TranslationUnit::fileName() const
|
||||
@@ -137,16 +137,16 @@ const char *TranslationUnit::spell(unsigned index) const
|
||||
return _tokens->at(index).spell();
|
||||
}
|
||||
|
||||
Identifier *TranslationUnit::identifier(unsigned index) const
|
||||
const Identifier *TranslationUnit::identifier(unsigned index) const
|
||||
{ return _tokens->at(index).identifier; }
|
||||
|
||||
Literal *TranslationUnit::literal(unsigned index) const
|
||||
const Literal *TranslationUnit::literal(unsigned index) const
|
||||
{ return _tokens->at(index).literal; }
|
||||
|
||||
StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||
const StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).string; }
|
||||
|
||||
NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||
const NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).number; }
|
||||
|
||||
unsigned TranslationUnit::matchingBrace(unsigned index) const
|
||||
@@ -181,8 +181,8 @@ void TranslationUnit::tokenize()
|
||||
pushLineOffset(0);
|
||||
pushPreprocessorLine(0, 1, fileId());
|
||||
|
||||
Identifier *lineId = control()->findOrInsertIdentifier("line");
|
||||
Identifier *genId = control()->findOrInsertIdentifier("gen");
|
||||
const Identifier *lineId = control()->findOrInsertIdentifier("line");
|
||||
const Identifier *genId = control()->findOrInsertIdentifier("gen");
|
||||
|
||||
bool generated = false;
|
||||
Token tk;
|
||||
@@ -211,8 +211,8 @@ void TranslationUnit::tokenize()
|
||||
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
||||
lex(&tk);
|
||||
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
||||
StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
pushPreprocessorLine(offset, line, fileName);
|
||||
lex(&tk);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ void TranslationUnit::pushLineOffset(unsigned offset)
|
||||
|
||||
void TranslationUnit::pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
StringLiteral *fileName)
|
||||
const StringLiteral *fileName)
|
||||
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
|
||||
|
||||
unsigned TranslationUnit::findLineNumber(unsigned offset) const
|
||||
@@ -339,23 +339,23 @@ unsigned TranslationUnit::findColumnNumber(unsigned offset, unsigned lineNumber)
|
||||
void TranslationUnit::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).offset, line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).begin(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).end(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getPosition(unsigned tokenOffset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
StringLiteral **fileName) const
|
||||
const StringLiteral **fileName) const
|
||||
{
|
||||
unsigned lineNumber = findLineNumber(tokenOffset);
|
||||
unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber);
|
||||
@@ -389,7 +389,7 @@ void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
@@ -420,7 +420,7 @@ void TranslationUnit::error(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
@@ -451,7 +451,7 @@ void TranslationUnit::fatal(unsigned index, const char *format, ...)
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
StringLiteral *fileName = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
|
||||
@@ -65,12 +65,12 @@ class CPLUSPLUS_EXPORT TranslationUnit
|
||||
void operator =(const TranslationUnit &other);
|
||||
|
||||
public:
|
||||
TranslationUnit(Control *control, StringLiteral *fileId);
|
||||
TranslationUnit(Control *control, const StringLiteral *fileId);
|
||||
~TranslationUnit();
|
||||
|
||||
Control *control() const;
|
||||
|
||||
StringLiteral *fileId() const;
|
||||
const StringLiteral *fileId() const;
|
||||
const char *fileName() const;
|
||||
unsigned fileNameLength() const;
|
||||
|
||||
@@ -86,10 +86,10 @@ public:
|
||||
const char *spell(unsigned index) const;
|
||||
|
||||
unsigned matchingBrace(unsigned index) const;
|
||||
Identifier *identifier(unsigned index) const;
|
||||
Literal *literal(unsigned index) const;
|
||||
StringLiteral *stringLiteral(unsigned index) const;
|
||||
NumericLiteral *numericLiteral(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
|
||||
MemoryPool *memoryPool() const;
|
||||
AST *ast() const;
|
||||
@@ -129,26 +129,26 @@ public:
|
||||
|
||||
void getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
StringLiteral **fileName = 0) const;
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void pushLineOffset(unsigned offset);
|
||||
void pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
StringLiteral *fileName);
|
||||
const StringLiteral *fileName);
|
||||
|
||||
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
|
||||
|
||||
@@ -156,11 +156,11 @@ public:
|
||||
struct PPLine {
|
||||
unsigned offset;
|
||||
unsigned line;
|
||||
StringLiteral *fileName;
|
||||
const StringLiteral *fileName;
|
||||
|
||||
PPLine(unsigned offset = 0,
|
||||
unsigned line = 0,
|
||||
StringLiteral *fileName = 0)
|
||||
const StringLiteral *fileName = 0)
|
||||
: offset(offset), line(line), fileName(fileName)
|
||||
{ }
|
||||
|
||||
@@ -181,7 +181,7 @@ private:
|
||||
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
||||
|
||||
Control *_control;
|
||||
StringLiteral *_fileId;
|
||||
const StringLiteral *_fileId;
|
||||
const char *_firstSourceChar;
|
||||
const char *_lastSourceChar;
|
||||
Array<Token, 8> *_tokens;
|
||||
|
||||
Reference in New Issue
Block a user