00001 #ifndef SIMPLE_FIELD_DECLARATION_H 00002 #define SIMPLE_FIELD_DECLARATION_H 00003 00004 #include "fielddeclaration.h" 00005 #include "identifier.h" 00006 #include "fieldtype.h" 00007 #include "expression.h" 00008 #include "stringliteral.h" 00009 00010 class SimpleFieldDeclaration : public FieldDeclaration { 00011 private: 00012 Identifier *identifier; 00013 FieldType *fieldType; 00014 Expression *expression; 00015 StringLiteral *stringLiteral; 00016 00017 public: 00018 SimpleFieldDeclaration(SrcPosition *position, Identifier *identifier, FieldType *fieldType, Expression *expression, StringLiteral *stringLiteral) 00019 : FieldDeclaration(position), identifier(identifier), fieldType(fieldType), expression(expression), stringLiteral(stringLiteral) {} 00020 00021 SimpleFieldDeclaration(const SimpleFieldDeclaration& simpleFieldDeclaration) : FieldDeclaration(simpleFieldDeclaration.position) { 00022 *(this) = simpleFieldDeclaration; 00023 } 00024 00025 virtual ~SimpleFieldDeclaration() { 00026 delete this->identifier; 00027 delete this->fieldType; 00028 delete this->expression; 00029 delete this->stringLiteral; 00030 } 00031 00032 Identifier *getIdentifier() { 00033 return this->identifier; 00034 } 00035 00036 FieldType *getFieldType() { 00037 return this->fieldType; 00038 } 00039 00040 Expression *getExpression() { 00041 return this->expression; 00042 } 00043 00044 StringLiteral *getStringLiteral() { 00045 return this->stringLiteral; 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.visitSimpleFieldDeclaration(this); 00053 } 00054 00055 virtual Ast& clone() const { 00056 return *(new SimpleFieldDeclaration(new SrcPosition(*(this->position)), 00057 this->identifier ? dynamic_cast<Identifier*>(&(this->identifier->clone())) : 0, 00058 this->fieldType ? dynamic_cast<FieldType*>(&(this->fieldType->clone())) : 0, 00059 this->expression ? dynamic_cast<Expression*>(&(this->expression->clone())) : 0, 00060 this->stringLiteral ? dynamic_cast<StringLiteral*>(&(this->stringLiteral->clone())) : 0)); 00061 } 00062 }; 00063 00064 #endif