Commit ce22a960 authored by hjk's avatar hjk
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 65638f7c 17d047ce
This diff is collapsed.
This diff is collapsed.
......@@ -190,6 +190,110 @@ public:
virtual bool visit(IdentifierListAST *) { return true; }
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
virtual void endVisit(AccessDeclarationAST *) { }
virtual void endVisit(ArrayAccessAST *) { }
virtual void endVisit(ArrayDeclaratorAST *) { }
virtual void endVisit(ArrayInitializerAST *) { }
virtual void endVisit(AsmDefinitionAST *) { }
virtual void endVisit(AttributeSpecifierAST *) { }
virtual void endVisit(AttributeAST *) { }
virtual void endVisit(BaseSpecifierAST *) { }
virtual void endVisit(BinaryExpressionAST *) { }
virtual void endVisit(BoolLiteralAST *) { }
virtual void endVisit(BreakStatementAST *) { }
virtual void endVisit(CallAST *) { }
virtual void endVisit(CaseStatementAST *) { }
virtual void endVisit(CastExpressionAST *) { }
virtual void endVisit(CatchClauseAST *) { }
virtual void endVisit(ClassSpecifierAST *) { }
virtual void endVisit(CompoundLiteralAST *) { }
virtual void endVisit(CompoundStatementAST *) { }
virtual void endVisit(ConditionAST *) { }
virtual void endVisit(ConditionalExpressionAST *) { }
virtual void endVisit(ContinueStatementAST *) { }
virtual void endVisit(ConversionFunctionIdAST *) { }
virtual void endVisit(CppCastExpressionAST *) { }
virtual void endVisit(CtorInitializerAST *) { }
virtual void endVisit(DeclaratorAST *) { }
virtual void endVisit(DeclarationStatementAST *) { }
virtual void endVisit(DeclaratorIdAST *) { }
virtual void endVisit(DeclaratorListAST *) { }
virtual void endVisit(DeleteExpressionAST *) { }
virtual void endVisit(DestructorNameAST *) { }
virtual void endVisit(DoStatementAST *) { }
virtual void endVisit(ElaboratedTypeSpecifierAST *) { }
virtual void endVisit(EmptyDeclarationAST *) { }
virtual void endVisit(EnumSpecifierAST *) { }
virtual void endVisit(EnumeratorAST *) { }
virtual void endVisit(ExceptionDeclarationAST *) { }
virtual void endVisit(ExceptionSpecificationAST *) { }
virtual void endVisit(ExpressionListAST *) { }
virtual void endVisit(ExpressionOrDeclarationStatementAST *) { }
virtual void endVisit(ExpressionStatementAST *) { }
virtual void endVisit(ForStatementAST *) { }
virtual void endVisit(FunctionDeclaratorAST *) { }
virtual void endVisit(FunctionDefinitionAST *) { }
virtual void endVisit(GotoStatementAST *) { }
virtual void endVisit(IfStatementAST *) { }
virtual void endVisit(LabeledStatementAST *) { }
virtual void endVisit(LinkageBodyAST *) { }
virtual void endVisit(LinkageSpecificationAST *) { }
virtual void endVisit(MemInitializerAST *) { }
virtual void endVisit(MemberAccessAST *) { }
virtual void endVisit(NamedTypeSpecifierAST *) { }
virtual void endVisit(NamespaceAST *) { }
virtual void endVisit(NamespaceAliasDefinitionAST *) { }
virtual void endVisit(NestedDeclaratorAST *) { }
virtual void endVisit(NestedExpressionAST *) { }
virtual void endVisit(NestedNameSpecifierAST *) { }
virtual void endVisit(NewDeclaratorAST *) { }
virtual void endVisit(NewExpressionAST *) { }
virtual void endVisit(NewInitializerAST *) { }
virtual void endVisit(NewTypeIdAST *) { }
virtual void endVisit(NumericLiteralAST *) { }
virtual void endVisit(OperatorAST *) { }
virtual void endVisit(OperatorFunctionIdAST *) { }
virtual void endVisit(ParameterDeclarationAST *) { }
virtual void endVisit(ParameterDeclarationClauseAST *) { }
virtual void endVisit(PointerAST *) { }
virtual void endVisit(PointerToMemberAST *) { }
virtual void endVisit(PostIncrDecrAST *) { }
virtual void endVisit(PostfixExpressionAST *) { }
virtual void endVisit(QualifiedNameAST *) { }
virtual void endVisit(ReferenceAST *) { }
virtual void endVisit(ReturnStatementAST *) { }
virtual void endVisit(SimpleDeclarationAST *) { }
virtual void endVisit(SimpleNameAST *) { }
virtual void endVisit(SimpleSpecifierAST *) { }
virtual void endVisit(SizeofExpressionAST *) { }
virtual void endVisit(StringLiteralAST *) { }
virtual void endVisit(SwitchStatementAST *) { }
virtual void endVisit(TemplateArgumentListAST *) { }
virtual void endVisit(TemplateDeclarationAST *) { }
virtual void endVisit(TemplateIdAST *) { }
virtual void endVisit(TemplateTypeParameterAST *) { }
virtual void endVisit(ThisExpressionAST *) { }
virtual void endVisit(ThrowExpressionAST *) { }
virtual void endVisit(TranslationUnitAST *) { }
virtual void endVisit(TryBlockStatementAST *) { }
virtual void endVisit(TypeConstructorCallAST *) { }
virtual void endVisit(TypeIdAST *) { }
virtual void endVisit(TypeidExpressionAST *) { }
virtual void endVisit(TypeofSpecifierAST *) { }
virtual void endVisit(TypenameCallExpressionAST *) { }
virtual void endVisit(TypenameTypeParameterAST *) { }
virtual void endVisit(UnaryExpressionAST *) { }
virtual void endVisit(UsingAST *) { }
virtual void endVisit(UsingDirectiveAST *) { }
virtual void endVisit(WhileStatementAST *) { }
virtual void endVisit(QtMethodAST *) { }
// ObjC++
virtual void endVisit(IdentifierListAST *) { }
virtual void endVisit(ObjCClassDeclarationAST *) { }
private:
Control *_control;
};
......
......@@ -103,6 +103,7 @@ bool CheckStatement::visit(CaseStatementAST *ast)
bool CheckStatement::visit(CompoundStatementAST *ast)
{
Block *block = control()->newBlock(ast->lbrace_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
for (StatementAST *it = ast->statements; it; it = it->next) {
......@@ -145,6 +146,7 @@ bool CheckStatement::visit(ExpressionStatementAST *ast)
bool CheckStatement::visit(ForStatementAST *ast)
{
Block *block = control()->newBlock(ast->for_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
semantic()->check(ast->initializer, _scope);
......@@ -158,6 +160,7 @@ bool CheckStatement::visit(ForStatementAST *ast)
bool CheckStatement::visit(IfStatementAST *ast)
{
Block *block = control()->newBlock(ast->if_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
FullySpecifiedType exprTy = semantic()->check(ast->condition, _scope);
......@@ -197,6 +200,7 @@ bool CheckStatement::visit(ReturnStatementAST *ast)
bool CheckStatement::visit(SwitchStatementAST *ast)
{
Block *block = control()->newBlock(ast->switch_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
......@@ -217,6 +221,7 @@ bool CheckStatement::visit(TryBlockStatementAST *ast)
bool CheckStatement::visit(CatchClauseAST *ast)
{
Block *block = control()->newBlock(ast->catch_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
semantic()->check(ast->exception_declaration, _scope);
......@@ -228,6 +233,7 @@ bool CheckStatement::visit(CatchClauseAST *ast)
bool CheckStatement::visit(WhileStatementAST *ast)
{
Block *block = control()->newBlock(ast->while_token);
ast->symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
......
......@@ -63,58 +63,22 @@ Name::~Name()
{ }
bool Name::isNameId() const
{ return dynamic_cast<const NameId *>(this) != 0; }
{ return asNameId() != 0; }
bool Name::isTemplateNameId() const
{ return dynamic_cast<const TemplateNameId *>(this) != 0; }
{ return asTemplateNameId() != 0; }
bool Name::isDestructorNameId() const
{ return dynamic_cast<const DestructorNameId *>(this) != 0; }
{ return asDestructorNameId() != 0; }
bool Name::isOperatorNameId() const
{ return dynamic_cast<const OperatorNameId *>(this) != 0; }
{ return asOperatorNameId() != 0; }
bool Name::isConversionNameId() const
{ return dynamic_cast<const ConversionNameId *>(this) != 0; }
{ return asConversionNameId() != 0; }
bool Name::isQualifiedNameId() const
{ return dynamic_cast<const QualifiedNameId *>(this) != 0; }
const NameId *Name::asNameId() const
{ return dynamic_cast<const NameId *>(this); }
const TemplateNameId *Name::asTemplateNameId() const
{ return dynamic_cast<const TemplateNameId *>(this); }
const DestructorNameId *Name::asDestructorNameId() const
{ return dynamic_cast<const DestructorNameId *>(this); }
const OperatorNameId *Name::asOperatorNameId() const
{ return dynamic_cast<const OperatorNameId *>(this); }
const ConversionNameId *Name::asConversionNameId() const
{ return dynamic_cast<const ConversionNameId *>(this); }
const QualifiedNameId *Name::asQualifiedNameId() const
{ return dynamic_cast<const QualifiedNameId *>(this); }
NameId *Name::asNameId()
{ return dynamic_cast<NameId *>(this); }
TemplateNameId *Name::asTemplateNameId()
{ return dynamic_cast<TemplateNameId *>(this); }
DestructorNameId *Name::asDestructorNameId()
{ return dynamic_cast<DestructorNameId *>(this); }
OperatorNameId *Name::asOperatorNameId()
{ return dynamic_cast<OperatorNameId *>(this); }
ConversionNameId *Name::asConversionNameId()
{ return dynamic_cast<ConversionNameId *>(this); }
QualifiedNameId *Name::asQualifiedNameId()
{ return dynamic_cast<QualifiedNameId *>(this); }
{ return asQualifiedNameId() != 0; }
void Name::accept(NameVisitor *visitor)
{
......
......@@ -74,19 +74,19 @@ public:
bool isConversionNameId() const;
bool isQualifiedNameId() const;
const NameId *asNameId() const;
const TemplateNameId *asTemplateNameId() const;
const DestructorNameId *asDestructorNameId() const;
const OperatorNameId *asOperatorNameId() const;
const ConversionNameId *asConversionNameId() const;
const QualifiedNameId *asQualifiedNameId() const;
virtual const NameId *asNameId() const { return 0; }
virtual const TemplateNameId *asTemplateNameId() const { return 0; }
virtual const DestructorNameId *asDestructorNameId() const { return 0; }
virtual const OperatorNameId *asOperatorNameId() const { return 0; }
virtual const ConversionNameId *asConversionNameId() const { return 0; }
virtual const QualifiedNameId *asQualifiedNameId() const { return 0; }
NameId *asNameId();
TemplateNameId *asTemplateNameId();
DestructorNameId *asDestructorNameId();
OperatorNameId *asOperatorNameId();
ConversionNameId *asConversionNameId();
QualifiedNameId *asQualifiedNameId();
virtual NameId *asNameId() { return 0; }
virtual TemplateNameId *asTemplateNameId() { return 0; }
virtual DestructorNameId *asDestructorNameId() { return 0; }
virtual OperatorNameId *asOperatorNameId() { return 0; }
virtual ConversionNameId *asConversionNameId() { return 0; }
virtual QualifiedNameId *asQualifiedNameId() { return 0; }
virtual bool isEqualTo(const Name *other) const = 0;
......
......@@ -77,6 +77,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const QualifiedNameId *asQualifiedNameId() const
{ return this; }
virtual QualifiedNameId *asQualifiedNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......@@ -96,6 +102,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const NameId *asNameId() const
{ return this; }
virtual NameId *asNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......@@ -113,6 +125,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const DestructorNameId *asDestructorNameId() const
{ return this; }
virtual DestructorNameId *asDestructorNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......@@ -137,6 +155,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const TemplateNameId *asTemplateNameId() const
{ return this; }
virtual TemplateNameId *asTemplateNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......@@ -211,6 +235,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const OperatorNameId *asOperatorNameId() const
{ return this; }
virtual OperatorNameId *asOperatorNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......@@ -228,6 +258,12 @@ public:
virtual bool isEqualTo(const Name *other) const;
virtual const ConversionNameId *asConversionNameId() const
{ return this; }
virtual ConversionNameId *asConversionNameId()
{ return this; }
protected:
virtual void accept0(NameVisitor *visitor);
......
......@@ -320,102 +320,36 @@ bool Symbol::isPrivate() const
{ return _visibility == Private; }
bool Symbol::isScopedSymbol() const
{ return dynamic_cast<const ScopedSymbol *>(this) != 0; }
{ return asScopedSymbol() != 0; }
bool Symbol::isEnum() const
{ return dynamic_cast<const Enum *>(this) != 0; }
{ return asEnum() != 0; }
bool Symbol::isFunction() const
{ return dynamic_cast<const Function *>(this) != 0; }
{ return asFunction() != 0; }
bool Symbol::isNamespace() const
{ return dynamic_cast<const Namespace *>(this) != 0; }
{ return asNamespace() != 0; }
bool Symbol::isClass() const
{ return dynamic_cast<const Class *>(this) != 0; }
{ return asClass() != 0; }
bool Symbol::isBlock() const
{ return dynamic_cast<const Block *>(this) != 0; }
{ return asBlock() != 0; }
bool Symbol::isUsingNamespaceDirective() const
{ return dynamic_cast<const UsingNamespaceDirective *>(this) != 0; }
{ return asUsingNamespaceDirective() != 0; }
bool Symbol::isUsingDeclaration() const
{ return dynamic_cast<const UsingDeclaration *>(this) != 0; }
{ return asUsingDeclaration() != 0; }
bool Symbol::isDeclaration() const
{ return dynamic_cast<const Declaration *>(this) != 0; }
{ return asDeclaration() != 0; }
bool Symbol::isArgument() const
{ return dynamic_cast<const Argument *>(this) != 0; }
{ return asArgument() != 0; }
bool Symbol::isBaseClass() const
{ return dynamic_cast<const BaseClass *>(this) != 0; }
const ScopedSymbol *Symbol::asScopedSymbol() const
{ return dynamic_cast<const ScopedSymbol *>(this); }
const Enum *Symbol::asEnum() const
{ return dynamic_cast<const Enum *>(this); }
const Function *Symbol::asFunction() const
{ return dynamic_cast<const Function *>(this); }
const Namespace *Symbol::asNamespace() const
{ return dynamic_cast<const Namespace *>(this); }
const Class *Symbol::asClass() const
{ return dynamic_cast<const Class *>(this); }
const Block *Symbol::asBlock() const
{ return dynamic_cast<const Block *>(this); }
const UsingNamespaceDirective *Symbol::asUsingNamespaceDirective() const
{ return dynamic_cast<const UsingNamespaceDirective *>(this); }
const UsingDeclaration *Symbol::asUsingDeclaration() const
{ return dynamic_cast<const UsingDeclaration *>(this); }
const Declaration *Symbol::asDeclaration() const
{ return dynamic_cast<const Declaration *>(this); }
const Argument *Symbol::asArgument() const
{ return dynamic_cast<const Argument *>(this); }
const BaseClass *Symbol::asBaseClass() const
{ return dynamic_cast<const BaseClass *>(this); }
ScopedSymbol *Symbol::asScopedSymbol()
{ return dynamic_cast<ScopedSymbol *>(this); }
Enum *Symbol::asEnum()
{ return dynamic_cast<Enum *>(this); }
Function *Symbol::asFunction()
{ return dynamic_cast<Function *>(this); }
Namespace *Symbol::asNamespace()
{ return dynamic_cast<Namespace *>(this); }
Class *Symbol::asClass()
{ return dynamic_cast<Class *>(this); }
Block *Symbol::asBlock()
{ return dynamic_cast<Block *>(this); }
UsingNamespaceDirective *Symbol::asUsingNamespaceDirective()
{ return dynamic_cast<UsingNamespaceDirective *>(this); }
UsingDeclaration *Symbol::asUsingDeclaration()
{ return dynamic_cast<UsingDeclaration *>(this); }
Declaration *Symbol::asDeclaration()
{ return dynamic_cast<Declaration *>(this); }
Argument *Symbol::asArgument()
{ return dynamic_cast<Argument *>(this); }
BaseClass *Symbol::asBaseClass()
{ return dynamic_cast<BaseClass *>(this); }
{ return asBaseClass() != 0; }
CPLUSPLUS_END_NAMESPACE
......@@ -197,29 +197,29 @@ public:
/// Returns true if this Symbol is a BaseClass.
bool isBaseClass() const;
const ScopedSymbol *asScopedSymbol() const;
const Enum *asEnum() const;
const Function *asFunction() const;
const Namespace *asNamespace() const;
const Class *asClass() const;
const Block *asBlock() const;
const UsingNamespaceDirective *asUsingNamespaceDirective() const;
const UsingDeclaration *asUsingDeclaration() const;
const Declaration *asDeclaration() const;
const Argument *asArgument() const;
const BaseClass *asBaseClass() const;
ScopedSymbol *asScopedSymbol();
Enum *asEnum();
Function *asFunction();
Namespace *asNamespace();
Class *asClass();
Block *asBlock();
UsingNamespaceDirective *asUsingNamespaceDirective();
UsingDeclaration *asUsingDeclaration();
Declaration *asDeclaration();
Argument *asArgument();
BaseClass *asBaseClass();
virtual const ScopedSymbol *asScopedSymbol() const { return 0; }
virtual const Enum *asEnum() const { return 0; }
virtual const Function *asFunction() const { return 0; }
virtual const Namespace *asNamespace() const { return 0; }
virtual const Class *asClass() const { return 0; }
virtual const Block *asBlock() const { return 0; }
virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const { return 0; }
virtual const UsingDeclaration *asUsingDeclaration() const { return 0; }
virtual const Declaration *asDeclaration() const { return 0; }
virtual const Argument *asArgument() const { return 0; }
virtual const BaseClass *asBaseClass() const { return 0; }
virtual ScopedSymbol *asScopedSymbol() { return 0; }
virtual Enum *asEnum() { return 0; }
virtual Function *asFunction() { return 0; }
virtual Namespace *asNamespace() { return 0; }
virtual Class *asClass() { return 0; }
virtual Block *asBlock() { return 0; }
virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return 0; }
virtual UsingDeclaration *asUsingDeclaration() { return 0; }
virtual Declaration *asDeclaration() { return 0; }
virtual Argument *asArgument() { return 0; }
virtual BaseClass *asBaseClass() { return 0; }
/// Returns this Symbol's type.
virtual FullySpecifiedType type() const = 0;
......
......@@ -71,6 +71,12 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const
{ return this; }
virtual UsingNamespaceDirective *asUsingNamespaceDirective()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
};
......@@ -84,6 +90,12 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const UsingDeclaration *asUsingDeclaration() const
{ return this; }
virtual UsingDeclaration *asUsingDeclaration()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
};
......@@ -105,6 +117,12 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const Declaration *asDeclaration() const
{ return this; }
virtual Declaration *asDeclaration()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
......@@ -127,6 +145,12 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const Argument *asArgument() const
{ return this; }
virtual Argument *asArgument()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
......@@ -146,6 +170,12 @@ public:
Scope *members() const;
void addMember(Symbol *member);
virtual const ScopedSymbol *asScopedSymbol() const
{ return this; }
virtual ScopedSymbol *asScopedSymbol()
{ return this; }
private:
Scope *_members;
};
......@@ -159,6 +189,12 @@ public:
// Symbol's interface
virtual FullySpecifiedType type() const;
virtual const Block *asBlock() const
{ return this; }
virtual Block *asBlock()
{ return this; }
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
};
......@@ -175,6 +211,12 @@ public:
// Type's interface
virtual bool isEqualTo(const Type *other) const;
virtual const Enum *asEnum() const
{ return this; }