Commit f7164ae9 authored by Roberto Raggi's avatar Roberto Raggi

Introduced TypenameArgument.

parent 2811d0ca
......@@ -116,6 +116,7 @@ class UsingNamespaceDirective;
class UsingDeclaration;
class Declaration;
class Argument;
class TypenameArgument;
class Function;
class Namespace;
class BaseClass;
......
......@@ -327,6 +327,14 @@ public:
return argument;
}
TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name)
{
TypenameArgument *argument = new TypenameArgument(translationUnit,
sourceLocation, name);
symbols.push_back(argument);
return argument;
}
Function *newFunction(unsigned sourceLocation, const Name *name)
{
Function *function = new Function(translationUnit,
......@@ -641,6 +649,9 @@ NamedType *Control::namedType(const Name *name)
Argument *Control::newArgument(unsigned sourceLocation, const Name *name)
{ return d->newArgument(sourceLocation, name); }
TypenameArgument *Control::newTypenameArgument(unsigned sourceLocation, const Name *name)
{ return d->newTypenameArgument(sourceLocation, name); }
Function *Control::newFunction(unsigned sourceLocation, const Name *name)
{ return d->newFunction(sourceLocation, name); }
......
......@@ -122,6 +122,9 @@ public:
/// Creates a new Argument symbol.
Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Argument symbol.
TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Function symbol.
Function *newFunction(unsigned sourceLocation, const Name *name = 0);
......
......@@ -463,6 +463,9 @@ bool Symbol::isDeclaration() const
bool Symbol::isArgument() const
{ return asArgument() != 0; }
bool Symbol::isTypenameArgument() const
{ return asTypenameArgument() != 0; }
bool Symbol::isBaseClass() const
{ return asBaseClass() != 0; }
......
......@@ -204,6 +204,9 @@ public:
/// Returns true if this Symbol is an Argument.
bool isArgument() const;
/// Returns true if this Symbol is a Typename argument.
bool isTypenameArgument() const;
/// Returns true if this Symbol is a BaseClass.
bool isBaseClass() const;
......@@ -241,6 +244,7 @@ public:
virtual const UsingDeclaration *asUsingDeclaration() const { return 0; }
virtual const Declaration *asDeclaration() const { return 0; }
virtual const Argument *asArgument() const { return 0; }
virtual const TypenameArgument *asTypenameArgument() const { return 0; }
virtual const BaseClass *asBaseClass() const { return 0; }
virtual const ForwardClassDeclaration *asForwardClassDeclaration() const { return 0; }
virtual const ObjCBaseClass *asObjCBaseClass() const { return 0; }
......@@ -262,6 +266,7 @@ public:
virtual UsingDeclaration *asUsingDeclaration() { return 0; }
virtual Declaration *asDeclaration() { return 0; }
virtual Argument *asArgument() { return 0; }
virtual TypenameArgument *asTypenameArgument() { return 0; }
virtual BaseClass *asBaseClass() { return 0; }
virtual ForwardClassDeclaration *asForwardClassDeclaration() { return 0; }
virtual ObjCBaseClass *asObjCBaseClass() { return 0; }
......
......@@ -72,6 +72,7 @@ public:
virtual bool visit(UsingDeclaration *) { return true; }
virtual bool visit(Declaration *) { return true; }
virtual bool visit(Argument *) { return true; }
virtual bool visit(TypenameArgument *) { return true; }
virtual bool visit(BaseClass *) { return true; }
virtual bool visit(Enum *) { return true; }
virtual bool visit(Function *) { return true; }
......
......@@ -152,6 +152,22 @@ FullySpecifiedType Argument::type() const
void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
TypenameArgument::TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ }
TypenameArgument::~TypenameArgument()
{ }
void TypenameArgument::setType(const FullySpecifiedType &type)
{ _type = type; }
FullySpecifiedType TypenameArgument::type() const
{ return _type; }
void TypenameArgument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name),
_templateParameters(0),
......
......@@ -169,6 +169,30 @@ private:
const StringLiteral *_initializer;
};
class CPLUSPLUS_EXPORT TypenameArgument: public Symbol
{
public:
TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~TypenameArgument();
void setType(const FullySpecifiedType &type);
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const TypenameArgument *asTypenameArgument() const
{ return this; }
virtual TypenameArgument *asTypenameArgument()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
private:
FullySpecifiedType _type;
};
class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol
{
public:
......
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