Removed TemplateParameters.

This commit is contained in:
Roberto Raggi
2010-08-11 12:47:28 +02:00
parent 354b9712e4
commit 6618a3cd67
12 changed files with 28 additions and 178 deletions

View File

@@ -80,7 +80,6 @@ class StringLiteral;
class NumericLiteral;
class SymbolTable;
class TemplateParameters;
// names
class NameVisitor;

View File

@@ -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());

View File

@@ -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;
};

View File

@@ -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)

View File

@@ -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);

View File

@@ -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); }

View File

@@ -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;
};