00001 #include <typeinfo> 00002 #include "guardexpression.h" 00003 using namespace std; 00004 00005 Ast& GuardExpression::operator = (const Ast& ast) { 00006 const GuardExpression& guardExpression = dynamic_cast<const GuardExpression&>(ast); 00007 00008 Guard::operator=(ast); 00009 this->expression = guardExpression.expression ? dynamic_cast<Expression*>(&(guardExpression.expression->clone())) : 0; 00010 00011 return *(this); 00012 } 00013 00014 bool GuardExpression::operator == (const Ast& ast) const { 00015 bool result = false; 00016 const GuardExpression& guardExpression = dynamic_cast<const GuardExpression&>(ast); 00017 00018 if (typeid(ast) != typeid(GuardExpression)) 00019 return false; 00020 00021 if (this->expression) 00022 result = (*(this->expression) == *(guardExpression.expression)); 00023 00024 return result && Guard::operator==(ast); 00025 } 00026