Commit 6618a3cd authored by Roberto Raggi's avatar Roberto Raggi

Removed TemplateParameters.

parent 354b9712
......@@ -399,6 +399,8 @@ FullySpecifiedType DeprecatedGenTemplateInstance::gen(Symbol *symbol)
FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *className, Symbol *candidate,
QSharedPointer<Control> control)
{
#warning robe: enable template instantiation
#if 0
if (className) {
if (const TemplateNameId *templId = className->asTemplateNameId()) {
if (Class *klass = candidate->scope()->asClass()) {
......@@ -422,6 +424,6 @@ FullySpecifiedType DeprecatedGenTemplateInstance::instantiate(const Name *classN
}
}
}
#endif
return candidate->type();
}
......@@ -283,8 +283,11 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
} else if (Function *fun = scope->asFunction()) {
bindings()->lookupInScope(name, fun, &candidates, /*templateId = */ 0, /*binding=*/ 0);
#warning robe: lookup in template parameters
#if 0
for (TemplateParameters *it = fun->templateParameters(); it && candidates.isEmpty(); it = it->previous())
bindings()->lookupInScope(name, it->scope(), &candidates, /* templateId = */ 0, /*binding=*/ 0);
#endif
if (! candidates.isEmpty())
break; // it's an argument or a template parameter.
......@@ -307,8 +310,11 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const
break; // it's a formal argument.
} else if (Class *klass = scope->asClass()) {
#warning robe: lookup in template parameters
#if 0
for (TemplateParameters *it = klass->templateParameters(); it && candidates.isEmpty(); it = it->previous())
bindings()->lookupInScope(name, it->scope(), &candidates, /* templateId = */ 0, /*binding=*/ 0);
#endif
if (! candidates.isEmpty())
break; // it's an argument or a template parameter.
......
......@@ -550,7 +550,8 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const Name *memberName) const
{
QList<LookupItem> members;
#warning robe: enable template instantiation
#if 0
const QList<LookupItem> originalMembers = binding->find(memberName);
foreach (const LookupItem &m, originalMembers) {
......@@ -593,7 +594,7 @@ QList<LookupItem> ResolveExpression::getMembers(ClassOrNamespace *binding, const
}
}
}
#endif
return members;
}
......
......@@ -179,12 +179,6 @@ protected:
if (symbol->isVirtual())
addVirtualMethod(symbol->name());
for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) {
Scope *scope = p->scope();
for (unsigned i = 0; i < scope->memberCount(); ++i)
accept(scope->memberAt(i));
}
return true;
}
......@@ -237,24 +231,12 @@ protected:
virtual bool visit(Class *symbol)
{
for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) {
Scope *scope = p->scope();
for (unsigned i = 0; i < scope->memberCount(); ++i)
accept(scope->memberAt(i));
}
addType(symbol->name());
return true;
}
virtual bool visit(ForwardClassDeclaration *symbol)
{
for (TemplateParameters *p = symbol->templateParameters(); p; p = p->previous()) {
Scope *scope = p->scope();
for (unsigned i = 0; i < scope->memberCount(); ++i)
accept(scope->memberAt(i));
}
addType(symbol->name());
return true;
}
......
......@@ -1852,11 +1852,14 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item, QChar t
if (! function->hasReturnType() && (function->identity() && !function->identity()->isDestructorNameId())) {
// Don't insert any magic, since the user might have just wanted to select the class
#warning robe: "don't insert matching ( when the selected symbol is a template"
#if 0
} else if (function->templateParameterCount() != 0 && typedChar != QLatin1Char('(')) {
// If there are no arguments, then we need the template specification
if (function->argumentCount() == 0) {
extraChars += QLatin1Char('<');
}
#endif
} else if (! function->isAmbiguous()) {
if (completionSettings().m_spaceAfterFunctionName)
extraChars += QLatin1Char(' ');
......
......@@ -80,7 +80,6 @@ class StringLiteral;
class NumericLiteral;
class SymbolTable;
class TemplateParameters;
// names
class NameVisitor;
......
......@@ -66,22 +66,18 @@ CheckDeclaration::CheckDeclaration(Semantic *semantic)
: SemanticCheck(semantic),
_declaration(0),
_scope(0),
_templateParameters(0),
_checkAnonymousArguments(false)
{ }
CheckDeclaration::~CheckDeclaration()
{ }
void CheckDeclaration::check(DeclarationAST *declaration,
Scope *scope, TemplateParameters *templateParameters)
void CheckDeclaration::check(DeclarationAST *declaration, Scope *scope)
{
Scope *previousScope = switchScope(scope);
TemplateParameters *previousTemplateParameters = switchTemplateParameters(templateParameters);
DeclarationAST *previousDeclaration = switchDeclaration(declaration);
accept(declaration);
(void) switchDeclaration(previousDeclaration);
(void) switchTemplateParameters(previousTemplateParameters);
(void) switchScope(previousScope);
}
......@@ -106,13 +102,6 @@ Scope *CheckDeclaration::switchScope(Scope *scope)
return previousScope;
}
TemplateParameters *CheckDeclaration::switchTemplateParameters(TemplateParameters *templateParameters)
{
TemplateParameters *previousTemplateParameters = _templateParameters;
_templateParameters = templateParameters;
return previousTemplateParameters;
}
void CheckDeclaration::setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers)
{
if (! symbol)
......@@ -172,13 +161,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
FullySpecifiedType declSpecifiers = semantic()->check(ast->decl_specifier_list, _scope);
FullySpecifiedType qualTy = declSpecifiers.qualifiedType();
if (_templateParameters && declSpecifiers) {
if (Class *klass = declSpecifiers->asClassType()) {
klass->setTemplateParameters(_templateParameters);
_templateParameters = 0; // consume the template parameters
}
}
if (ast->decl_specifier_list && ! ast->declarator_list) {
ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_list->value->asElaboratedTypeSpecifier();
......@@ -194,11 +176,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
ForwardClassDeclaration *symbol =
control()->newForwardClassDeclaration(sourceLocation, name);
if (_templateParameters) {
symbol->setTemplateParameters(_templateParameters);
_templateParameters = 0;
}
setDeclSpecifiers(symbol, declSpecifiers);
_scope->addMember(symbol);
......@@ -247,11 +224,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
setDeclSpecifiers(symbol, declSpecifiers);
if (_templateParameters && it == ast->declarator_list) {
symbol->setTemplateParameters(_templateParameters);
_templateParameters = 0; // consume the template parameters
}
symbol->setVisibility(semantic()->currentVisibility());
if (it->value && it->value->initializer) {
......@@ -345,7 +317,6 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
fun->setSourceLocation(loc, translationUnit());
}
fun->setName(name);
fun->setTemplateParameters(_templateParameters);
fun->setVisibility(semantic()->currentVisibility());
fun->setMethodKey(semantic()->currentMethodKey());
......
......@@ -61,13 +61,12 @@ public:
CheckDeclaration(Semantic *semantic);
virtual ~CheckDeclaration();
void check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters);
void check(DeclarationAST *declaration, Scope *scope);
void check(CtorInitializerAST *ast, Scope *scope);
protected:
DeclarationAST *switchDeclaration(DeclarationAST *declaration);
Scope *switchScope(Scope *scope);
TemplateParameters *switchTemplateParameters(TemplateParameters *templateParameters);
void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers);
......@@ -117,7 +116,6 @@ private:
private:
DeclarationAST *_declaration;
Scope *_scope;
TemplateParameters *_templateParameters;
bool _checkAnonymousArguments: 1;
};
......
......@@ -155,15 +155,14 @@ FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope,
const FullySpecifiedType &type)
{ return d->checkSpecifier->check(specifier, scope, type); }
void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters)
{ d->checkDeclaration->check(declaration, scope, templateParameters); }
void Semantic::check(DeclarationAST *declaration, Scope *scope)
{ d->checkDeclaration->check(declaration, scope); }
FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type,
Scope *scope, const Name **name)
{ return d->checkDeclarator->check(declarator, type, scope, name); }
FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
Scope *scope)
FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, Scope *scope)
{ return d->checkDeclarator->check(ptrOperators, type, scope); }
FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope)
......
......@@ -99,7 +99,7 @@ public:
FullySpecifiedType check(ExpressionAST *expression, Scope *scope);
void check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters = 0);
void check(DeclarationAST *declaration, Scope *scope);
FullySpecifiedType check(StatementAST *statement, Scope *scope);
......
......@@ -55,26 +55,6 @@
using namespace CPlusPlus;
TemplateParameters::TemplateParameters(Scope *scope)
: _previous(0), _scope(scope)
{ }
TemplateParameters::TemplateParameters(TemplateParameters *previous, Scope *scope)
: _previous(previous), _scope(scope)
{ }
TemplateParameters::~TemplateParameters()
{
delete _previous;
delete _scope;
}
TemplateParameters *TemplateParameters::previous() const
{ return _previous; }
Scope *TemplateParameters::scope() const
{ return _scope; }
UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit,
unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
......@@ -125,18 +105,11 @@ void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_templateParameters(0)
: Symbol(translationUnit, sourceLocation, name)
{ }
Declaration::~Declaration()
{ delete _templateParameters; }
TemplateParameters *Declaration::templateParameters() const
{ return _templateParameters; }
void Declaration::setTemplateParameters(TemplateParameters *templateParameters)
{ _templateParameters = templateParameters; }
{ }
void Declaration::setType(const FullySpecifiedType &type)
{ _type = type; }
......@@ -191,15 +164,12 @@ void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name),
_templateParameters(0),
_block(0),
_flags(0)
{ }
Function::~Function()
{
delete _templateParameters;
}
{ }
bool Function::isNormal() const
{ return f._methodKey == NormalMethod; }
......@@ -225,23 +195,6 @@ Block *Function::block() const
void Function::setBlock(Block *block)
{ _block = block; }
unsigned Function::templateParameterCount() const
{
if (! _templateParameters)
return 0;
return _templateParameters->scope()->memberCount();
}
Symbol *Function::templateParameterAt(unsigned index) const
{ return _templateParameters->scope()->memberAt(index); }
TemplateParameters *Function::templateParameters() const
{ return _templateParameters; }
void Function::setTemplateParameters(TemplateParameters *templateParameters)
{ _templateParameters = templateParameters; }
bool Function::isEqualTo(const Type *other) const
{
const Function *o = other->asFunctionType();
......@@ -544,18 +497,11 @@ void BaseClass::visitSymbol0(SymbolVisitor *visitor)
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_templateParameters(0)
: Symbol(translationUnit, sourceLocation, name)
{ }
ForwardClassDeclaration::~ForwardClassDeclaration()
{ delete _templateParameters; }
TemplateParameters *ForwardClassDeclaration::templateParameters() const
{ return _templateParameters; }
void ForwardClassDeclaration::setTemplateParameters(TemplateParameters *templateParameters)
{ _templateParameters = templateParameters; }
{ }
FullySpecifiedType ForwardClassDeclaration::type() const
{ return FullySpecifiedType(const_cast<ForwardClassDeclaration *>(this)); }
......@@ -589,12 +535,11 @@ bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *mat
Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name),
_key(ClassKey),
_templateParameters(0)
_key(ClassKey)
{ }
Class::~Class()
{ delete _templateParameters; }
{ }
bool Class::isClass() const
{ return _key == ClassKey; }
......@@ -611,23 +556,6 @@ Class::Key Class::classKey() const
void Class::setClassKey(Key key)
{ _key = key; }
unsigned Class::templateParameterCount() const
{
if (! _templateParameters)
return 0;
return _templateParameters->scope()->memberCount();
}
Symbol *Class::templateParameterAt(unsigned index) const
{ return _templateParameters->scope()->memberAt(index); }
TemplateParameters *Class::templateParameters() const
{ return _templateParameters; }
void Class::setTemplateParameters(TemplateParameters *templateParameters)
{ _templateParameters = templateParameters; }
void Class::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }
......
......@@ -58,21 +58,6 @@
namespace CPlusPlus {
class CPLUSPLUS_EXPORT TemplateParameters
{
public:
TemplateParameters(Scope *scope);
TemplateParameters(TemplateParameters *previous, Scope *scope);
~TemplateParameters();
TemplateParameters *previous() const;
Scope *scope() const;
private:
TemplateParameters *_previous;
Scope *_scope;
};
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
{
public:
......@@ -142,9 +127,6 @@ public:
Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Declaration();
TemplateParameters *templateParameters() const;
void setTemplateParameters(TemplateParameters *templateParameters);
void setType(const FullySpecifiedType &type);
// Symbol's interface
......@@ -161,7 +143,6 @@ protected:
private:
FullySpecifiedType _type;
TemplateParameters *_templateParameters;
};
class CPLUSPLUS_EXPORT Argument: public Symbol
......@@ -243,9 +224,6 @@ public:
ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ForwardClassDeclaration();
TemplateParameters *templateParameters() const;
void setTemplateParameters(TemplateParameters *templateParameters);
virtual FullySpecifiedType type() const;
virtual bool isEqualTo(const Type *other) const;
......@@ -266,9 +244,6 @@ protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
virtual void accept0(TypeVisitor *visitor);
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private:
TemplateParameters *_templateParameters;
};
class CPLUSPLUS_EXPORT Enum: public Scope, public Type
......@@ -325,12 +300,6 @@ public:
Block *block() const;
void setBlock(Block *block);
unsigned templateParameterCount() const; // ### remove me
Symbol *templateParameterAt(unsigned index) const; // ### remove me
TemplateParameters *templateParameters() const;
void setTemplateParameters(TemplateParameters *templateParameters);
FullySpecifiedType returnType() const;
void setReturnType(const FullySpecifiedType &returnType);
......@@ -391,7 +360,6 @@ protected:
private:
FullySpecifiedType _returnType;
TemplateParameters *_templateParameters;
Block *_block;
struct Flags {
unsigned _isVirtual: 1;
......@@ -483,12 +451,6 @@ public:
Key classKey() const;
void setClassKey(Key key);
unsigned templateParameterCount() const; // ### remove me
Symbol *templateParameterAt(unsigned index) const; // ### remove me
TemplateParameters *templateParameters() const;
void setTemplateParameters(TemplateParameters *templateParameters);
unsigned baseClassCount() const;
BaseClass *baseClassAt(unsigned index) const;
void addBaseClass(BaseClass *baseClass);
......@@ -518,7 +480,6 @@ protected:
private:
Key _key;
TemplateParameters *_templateParameters;
std::vector<BaseClass *> _baseClasses;
};
......
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