From 2aef4f8884d96375a506f90fe163d90d6346b43c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 28 Oct 2009 18:38:33 -0400 Subject: Render an expr if expr_t::text() has no string --- src/expr.cc | 10 ++++++++++ src/expr.h | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/expr.cc b/src/expr.cc index 89214d51..4f12a648 100644 --- a/src/expr.cc +++ b/src/expr.cc @@ -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) { diff --git a/src/expr.h b/src/expr.h index 24276cd1..b880fd79 100644 --- a/src/expr.h +++ b/src/expr.h @@ -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) { -- cgit v1.2.3