InterfaceType * substitute(const InterfaceType * e, const InterfaceType * repl) const { if (deep_equal(e)) return repl->clone(); return clone(); }
/** @brief If 'e' equals to this unary expression, the replacement 'repl' is returned. Otherwise, the unary expression is cloned. Note that the caller must ensure proper deletion of the returned object. */ InterfaceType * substitute(const InterfaceType * e, const InterfaceType * repl) const { if (deep_equal(e)) return repl->clone(); return new rt_unary_expr(expr_->substitute(e, repl), op_->clone()); };
/** @brief If 'e' is equal to this variable, the corresponding replacement in 'repl' is returned. Otherwise, a copy of the variable is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion. */ InterfaceType * substitute(const InterfaceType * e, const InterfaceType * repl) const { //std::cout << "Comparing variable<" << id << "> with " << e->str() << ", result: "; if (deep_equal(e)) return repl->clone(); //std::cout << "FALSE" << std::endl; return clone(); };
/** @brief If one of the expressions in 'e' equals to this unary expression, the respective replacement 'repl' is returned. Otherwise, a copy of *this is returned. Note that the caller must ensure proper deletion of the returned object. */ InterfaceType * substitute(std::vector<const InterfaceType *> const & e, std::vector<const InterfaceType *> const & repl) const { for (std::size_t i=0; i<e.size(); ++i) if (deep_equal(e[i])) return repl[i]->clone(); return new rt_unary_expr(expr_->substitute(e, repl), op_->clone()); };
InterfaceType * substitute(std::vector<const InterfaceType *> const & e, std::vector<const InterfaceType *> const & repl) const { //std::cout << "Comparing variable<" << id << "> with " << e->str() << ", result: "; for (std::size_t i=0; i<e.size(); ++i) if (deep_equal(e[i])) return repl[i]->clone(); //std::cout << "FALSE" << std::endl; return clone(); }