Render an expr if expr_t::text() has no string

This commit is contained in:
John Wiegley 2009-10-28 18:38:33 -04:00
parent 1c9c3ad411
commit 2aef4f8884
2 changed files with 11 additions and 4 deletions

View file

@ -78,6 +78,16 @@ expr_t::ptr_op_t expr_t::get_op() throw()
return ptr;
}
string expr_t::text()
{
if (str.empty()) {
std::ostringstream out;
ptr->print(out);
set_text(out.str());
}
return str;
}
expr_t& expr_t::operator=(const expr_t& _expr)
{
if (this != &_expr) {

View file

@ -116,10 +116,7 @@ public:
}
ptr_op_t get_op() throw();
string text() const throw() {
return str;
}
string text();
// This has special use in the textual parser
void set_text(const string& txt) {