Commit 41b4af05 authored by Roberto Raggi's avatar Roberto Raggi

Get rid of the prefix findOrInsert for the functions in CPlusPlus::Control.

parent f74ba9da
......@@ -215,7 +215,7 @@ Document::Document(const QString &fileName)
_control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages));
const QByteArray localFileName = fileName.toUtf8();
const StringLiteral *fileId = _control->findOrInsertStringLiteral(localFileName.constData(),
const StringLiteral *fileId = _control->stringLiteral(localFileName.constData(),
localFileName.size());
_translationUnit = new TranslationUnit(_control, fileId);
_translationUnit->setQtMocRunEnabled(true);
......
......@@ -220,7 +220,7 @@ public:
if (! other)
return 0;
return control()->findOrInsertIdentifier(other->chars(), other->size());
return control()->identifier(other->chars(), other->size());
}
public:
......
......@@ -262,7 +262,7 @@ private:
return name;
else if (const Name *nameId = name->asNameId()) {
const Identifier *id = control()->findOrInsertIdentifier(nameId->identifier()->chars(),
const Identifier *id = control()->identifier(nameId->identifier()->chars(),
nameId->identifier()->size());
return control()->nameId(id);
......@@ -272,7 +272,7 @@ private:
FullySpecifiedType argTy = templId->templateArgumentAt(templateArgIndex);
arguments[templateArgIndex] = q->apply(argTy);
}
const Identifier *id = control()->findOrInsertIdentifier(templId->identifier()->chars(),
const Identifier *id = control()->identifier(templId->identifier()->chars(),
templId->identifier()->size());
return control()->templateNameId(id, arguments.data(), arguments.size());
......
......@@ -91,7 +91,7 @@ void FindUsages::operator()(Symbol *symbol)
_declSymbolFullyQualifiedName = LookupContext::fullyQualifiedName(symbol);
// get the canonical id
_id = _doc->control()->findOrInsertIdentifier(_id->chars(), _id->size());
_id = _doc->control()->identifier(_id->chars(), _id->size());
if (AST *ast = _doc->translationUnit()->ast())
translationUnit(ast->asTranslationUnit());
......
......@@ -788,6 +788,11 @@ ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol)
return switchCurrentClassOrNamespace(entity);
}
bool CreateBindings::visit(Template *templ)
{
return false;
}
bool CreateBindings::visit(Namespace *ns)
{
ClassOrNamespace *previous = enterClassOrNamespaceBinding(ns);
......
......@@ -162,6 +162,7 @@ protected:
/// Creates bindings for the symbols reachable from the \a root symbol.
void process(Symbol *root);
virtual bool visit(Template *templ);
virtual bool visit(Namespace *ns);
virtual bool visit(Class *klass);
virtual bool visit(ForwardClassDeclaration *klass);
......
......@@ -234,8 +234,8 @@ bool ResolveExpression::visit(NewExpressionAST *ast)
bool ResolveExpression::visit(TypeidExpressionAST *)
{
const Name *stdName = control()->nameId(control()->findOrInsertIdentifier("std"));
const Name *tiName = control()->nameId(control()->findOrInsertIdentifier("type_info"));
const Name *stdName = control()->nameId(control()->identifier("std"));
const Name *tiName = control()->nameId(control()->identifier("type_info"));
const Name *q = control()->qualifiedNameId(control()->qualifiedNameId(/* :: */ 0, stdName), tiName);
FullySpecifiedType ty(control()->namedType(q));
......
......@@ -140,6 +140,28 @@ void TypePrettyPrinter::visit(Namespace *type)
prependCv(_fullySpecifiedType);
}
void TypePrettyPrinter::visit(Template *type)
{
const unsigned argc = type->templateParameterCount();
QString decl;
decl += QLatin1String("template <");
for (unsigned i = 0; i < argc; ++i) {
if (i != 0)
decl += QLatin1String(", ");
decl += QLatin1String("T");
decl += QString::number(i + 1);
}
decl += QLatin1Char('<');
if (Symbol *d = type->declaration()) {
decl += QLatin1Char(' ');
decl += overview()->prettyType(d->type(), d->name());
}
_text.prepend(decl);
qWarning() << "here:" << decl;
prependCv(_fullySpecifiedType);
}
void TypePrettyPrinter::visit(Class *classTy)
{
_text.prepend(overview()->prettyName(classTy->name()));
......
......@@ -68,6 +68,7 @@ protected:
virtual void visit(NamedType *type);
virtual void visit(Function *type);
virtual void visit(Namespace *type);
virtual void visit(Template *type);
virtual void visit(Class *type);
virtual void visit(Enum *type);
......
......@@ -976,7 +976,7 @@ public:
}
QSharedPointer<Control> control = state.context().control();
const Name *trName = control->nameId(control->findOrInsertIdentifier("tr"));
const Name *trName = control->nameId(control->identifier("tr"));
// Check whether we are in a method:
for (int i = path.size() - 1; i >= 0; --i)
......
......@@ -437,7 +437,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
buffer += ' ';
buffer += tk.spell();
}
const StringLiteral *initializer = control()->findOrInsertStringLiteral(buffer.c_str(), buffer.size());
const StringLiteral *initializer = control()->stringLiteral(buffer.c_str(), buffer.size());
arg->setInitializer(initializer);
}
arg->setType(argTy);
......
......@@ -377,7 +377,7 @@ bool CheckName::visit(ObjCSelectorAST *ast)
bool hasArgs = false;
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
if (it->value->name_token) {
const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
const Identifier *id = control()->identifier(spell(it->value->name_token));
const NameId *nameId = control()->nameId(id);
names.push_back(nameId);
......
......@@ -377,9 +377,9 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
const Name *name = 0;
if (tokenKind(ast->q_token) == T_Q_D)
name = control()->nameId(control()->findOrInsertIdentifier("d"));
name = control()->nameId(control()->identifier("d"));
else
name = control()->nameId(control()->findOrInsertIdentifier("q"));
name = control()->nameId(control()->identifier("q"));
FullySpecifiedType declTy = semantic()->check(ast->type_id, _scope);
......@@ -390,7 +390,7 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
privateClass += nameId->identifier()->chars();
privateClass += "Private";
const Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(),
const Name *privName = control()->nameId(control()->identifier(privateClass.c_str(),
privateClass.size()));
declTy.setType(control()->namedType(privName));
}
......
......@@ -536,17 +536,17 @@ Control::Control()
{
d = new Data(this);
d->deprecatedId = findOrInsertIdentifier("deprecated");
d->unavailableId = findOrInsertIdentifier("unavailable");
d->objcGetterId = findOrInsertIdentifier("getter");
d->objcSetterId = findOrInsertIdentifier("setter");
d->objcReadwriteId = findOrInsertIdentifier("readwrite");
d->objcReadonlyId = findOrInsertIdentifier("readonly");
d->objcAssignId = findOrInsertIdentifier("assign");
d->objcRetainId = findOrInsertIdentifier("retain");
d->objcCopyId = findOrInsertIdentifier("copy");
d->objcNonatomicId = findOrInsertIdentifier("nonatomic");
d->deprecatedId = identifier("deprecated");
d->unavailableId = identifier("unavailable");
d->objcGetterId = identifier("getter");
d->objcSetterId = identifier("setter");
d->objcReadwriteId = identifier("readwrite");
d->objcReadonlyId = identifier("readonly");
d->objcAssignId = identifier("assign");
d->objcRetainId = identifier("retain");
d->objcCopyId = identifier("copy");
d->objcNonatomicId = identifier("nonatomic");
}
Control::~Control()
......@@ -571,13 +571,13 @@ void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
const Identifier *Control::findIdentifier(const char *chars, unsigned size) const
{ return d->identifiers.findLiteral(chars, size); }
const Identifier *Control::findOrInsertIdentifier(const char *chars, unsigned size)
const Identifier *Control::identifier(const char *chars, unsigned size)
{ return d->identifiers.findOrInsertLiteral(chars, size); }
const Identifier *Control::findOrInsertIdentifier(const char *chars)
const Identifier *Control::identifier(const char *chars)
{
unsigned length = std::strlen(chars);
return findOrInsertIdentifier(chars, length);
return identifier(chars, length);
}
Control::IdentifierIterator Control::firstIdentifier() const
......@@ -598,22 +598,22 @@ Control::NumericLiteralIterator Control::firstNumericLiteral() const
Control::NumericLiteralIterator Control::lastNumericLiteral() const
{ return d->numericLiterals.end(); }
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars, unsigned size)
const StringLiteral *Control::stringLiteral(const char *chars, unsigned size)
{ return d->stringLiterals.findOrInsertLiteral(chars, size); }
const StringLiteral *Control::findOrInsertStringLiteral(const char *chars)
const StringLiteral *Control::stringLiteral(const char *chars)
{
unsigned length = std::strlen(chars);
return findOrInsertStringLiteral(chars, length);
return stringLiteral(chars, length);
}
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars, unsigned size)
const NumericLiteral *Control::numericLiteral(const char *chars, unsigned size)
{ return d->numericLiterals.findOrInsertLiteral(chars, size); }
const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
const NumericLiteral *Control::numericLiteral(const char *chars)
{
unsigned length = std::strlen(chars);
return findOrInsertNumericLiteral(chars, length);
return numericLiteral(chars, length);
}
const NameId *Control::nameId(const Identifier *id)
......
......@@ -190,8 +190,8 @@ public:
const Identifier *objcNonatomicId() const;
const Identifier *findIdentifier(const char *chars, unsigned size) const;
const Identifier *findOrInsertIdentifier(const char *chars, unsigned size);
const Identifier *findOrInsertIdentifier(const char *chars);
const Identifier *identifier(const char *chars, unsigned size);
const Identifier *identifier(const char *chars);
typedef const Identifier *const *IdentifierIterator;
typedef const StringLiteral *const *StringLiteralIterator;
......@@ -206,11 +206,11 @@ public:
NumericLiteralIterator firstNumericLiteral() const;
NumericLiteralIterator lastNumericLiteral() const;
const StringLiteral *findOrInsertStringLiteral(const char *chars, unsigned size);
const StringLiteral *findOrInsertStringLiteral(const char *chars);
const StringLiteral *stringLiteral(const char *chars, unsigned size);
const StringLiteral *stringLiteral(const char *chars);
const NumericLiteral *findOrInsertNumericLiteral(const char *chars, unsigned size);
const NumericLiteral *findOrInsertNumericLiteral(const char *chars);
const NumericLiteral *numericLiteral(const char *chars, unsigned size);
const NumericLiteral *numericLiteral(const char *chars);
bool hasSymbol(Symbol *symbol) const;
......
......@@ -281,7 +281,7 @@ void Lexer::scan_helper(Token *tok)
yyinp();
if (control())
tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
tok->string = control()->stringLiteral(yytext, yylen);
} break;
case '{':
......@@ -361,7 +361,7 @@ void Lexer::scan_helper(Token *tok)
int yylen = _currentChar - yytext;
tok->f.kind = T_NUMERIC_LITERAL;
if (control())
tok->number = control()->findOrInsertNumericLiteral(yytext, yylen);
tok->number = control()->numericLiteral(yytext, yylen);
} else {
tok->f.kind = T_DOT;
}
......@@ -564,7 +564,7 @@ void Lexer::scan_helper(Token *tok)
if (_yychar == '>')
yyinp();
if (control())
tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
tok->string = control()->stringLiteral(yytext, yylen);
tok->f.kind = T_ANGLE_STRING_LITERAL;
} else if (_yychar == '<') {
yyinp();
......@@ -642,7 +642,7 @@ void Lexer::scan_helper(Token *tok)
yyinp();
if (control())
tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
tok->string = control()->stringLiteral(yytext, yylen);
break;
}
......@@ -679,7 +679,7 @@ void Lexer::scan_helper(Token *tok)
yyinp();
if (control())
tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
tok->string = control()->stringLiteral(yytext, yylen);
} else if (std::isalpha(ch) || ch == '_' || ch == '$') {
const char *yytext = _currentChar - 1;
while (std::isalnum(_yychar) || _yychar == '_' || _yychar == '$')
......@@ -694,7 +694,7 @@ void Lexer::scan_helper(Token *tok)
tok->f.kind = classifyOperator(yytext, yylen);
if (control())
tok->identifier = control()->findOrInsertIdentifier(yytext, yylen);
tok->identifier = control()->identifier(yytext, yylen);
}
break;
} else if (std::isdigit(ch)) {
......@@ -715,7 +715,7 @@ void Lexer::scan_helper(Token *tok)
int yylen = _currentChar - yytext;
tok->f.kind = T_NUMERIC_LITERAL;
if (control())
tok->number = control()->findOrInsertNumericLiteral(yytext, yylen);
tok->number = control()->numericLiteral(yytext, yylen);
break;
} else {
tok->f.kind = T_ERROR;
......
......@@ -188,8 +188,8 @@ void TranslationUnit::tokenize()
pushLineOffset(0);
pushPreprocessorLine(0, 1, fileId());
const Identifier *lineId = control()->findOrInsertIdentifier("line");
const Identifier *genId = control()->findOrInsertIdentifier("gen");
const Identifier *lineId = control()->identifier("line");
const Identifier *genId = control()->identifier("gen");
bool generated = false;
Token tk;
......@@ -218,7 +218,7 @@ void TranslationUnit::tokenize()
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
lex(&tk);
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
const StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
const StringLiteral *fileName = control()->stringLiteral(tk.string->chars(),
tk.string->size());
pushPreprocessorLine(offset, line, fileName);
lex(&tk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment