00001 #ifndef SIMPLE_DECLARATION_H 00002 #define SIMPLE_DECLARATION_H 00003 00004 #include "declaration.h" 00005 #include "identifierlist.h" 00006 #include "type.h" 00007 #include "expression.h" 00008 00009 class SimpleDeclaration : public Declaration { 00010 private: 00011 IdentifierList *identifierList; 00012 Type *type; 00013 Expression *expression; 00014 bool constant; 00015 00016 public: 00017 SimpleDeclaration(SrcPosition *position, IdentifierList *identifierList, Type *type, 00018 Expression *expression, bool constant) 00019 : Declaration(position), identifierList(identifierList), type(type), 00020 expression(expression), constant(constant) {} 00021 00022 SimpleDeclaration(const SimpleDeclaration& simpleDeclaration) : Declaration(simpleDeclaration.position) { 00023 *(this) = simpleDeclaration; 00024 } 00025 00026 virtual ~SimpleDeclaration() { 00027 delete this->identifierList; 00028 delete this->type; 00029 delete this->expression; 00030 } 00031 00032 IdentifierList *getIdentifierList() { 00033 return this->identifierList; 00034 } 00035 00036 Type *getType() { 00037 return this->type; 00038 } 00039 00040 Expression *getExpression() { 00041 return this->expression; 00042 } 00043 00044 bool isConstant() const { 00045 return this->constant; 00046 } 00047 00048 virtual Ast& operator = (const Ast& ast); 00049 virtual bool operator == (const Ast& ast) const; 00050 00051 virtual VisitorReturn *visit(Visitor& visitor) { 00052 return visitor.visitSimpleDeclaration(this); 00053 } 00054 00055 virtual Ast& clone() const { 00056 return *(new SimpleDeclaration(new SrcPosition(*(this->position)), 00057 this->identifierList ? dynamic_cast<IdentifierList*>(&(this->identifierList->clone())) : 0, 00058 this->type ? dynamic_cast<Type*>(&(this->type->clone())) : 0, 00059 this->expression ? dynamic_cast<Expression*>(&(this->expression->clone())) : 0, 00060 this->constant)); 00061 } 00062 }; 00063 00064 #endif