00001 #include "streeconstant.h" 00002 00003 ostream& Constant::print(ostream &os) const{ 00004 return os << value; 00005 }; 00006 00007 ostream& Constant::php(ostream &os) const{ 00008 return os << value; 00009 } 00010 00011 bool Constant::match(const Node *p, Assignment &assign, const NameSpace &nameSpace)const { 00012 if (p->getType()!=SConstant) return false; 00013 return ((Constant*)p)->getValue() == getValue(); 00014 }; 00015 00016 bool Constant::matchToBegining(const List *p, Assignment &assign, const NameSpace &nameSpace) const{ 00017 return false; 00018 }; 00019 00020 bool Constant::compare(const Node *p) const { 00021 if (p->getType()!=SConstant) return false; 00022 return ((Constant*)p)->getValue() == getValue(); 00023 }; 00024 00025 Node* Constant::substitute(const Assignment &assign){ 00026 return this; 00027 }; 00028 00029 Node* Constant::copy() const { 00030 return new Constant(getValue()); 00031 }; 00032 00033 void Constant::getVariables(VariableList &vlist) const{}; 00034 00035 int Constant::toInt() const{ 00036 istringstream is(getValue().c_str()); 00037 int x; 00038 is >> x; 00039 return x; 00040 } 00041 00042 string Constant::evaluate(const NameSpace &nameSpace) const{ 00043 return getValue(); 00044 };