diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-28 06:13:49 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-28 06:13:49 -0400 |
commit | 19cfd9e23b7cd4a7976591290b17e7ba20dd5a50 (patch) | |
tree | a8e2ae738d29748b1cf06c2259cf98bd939bce43 /src | |
parent | c87aa9c2ea26333ec9baee6f4466496445eb8db8 (diff) | |
download | fork-ledger-19cfd9e23b7cd4a7976591290b17e7ba20dd5a50.tar.gz fork-ledger-19cfd9e23b7cd4a7976591290b17e7ba20dd5a50.tar.bz2 fork-ledger-19cfd9e23b7cd4a7976591290b17e7ba20dd5a50.zip |
Fixed the printing of O_CONS nodes
Diffstat (limited to 'src')
-rw-r--r-- | src/op.cc | 39 | ||||
-rw-r--r-- | src/op.h | 4 |
2 files changed, 27 insertions, 16 deletions
@@ -312,6 +312,27 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus) } } +namespace { + bool print_cons(std::ostream& out, const expr_t::const_ptr_op_t op, + const expr_t::op_t::context_t& context) + { + bool found = false; + + assert(op->left()); + if (op->left()->print(out, context)) + found = true; + + if (op->has_right()) { + out << ", "; + if (op->right()->kind == expr_t::op_t::O_CONS) + found = print_cons(out, op->right(), context); + else if (op->right()->print(out, context)) + found = true; + } + return found; + } +} + bool expr_t::op_t::print(std::ostream& out, const context_t& context) const { bool found = false; @@ -469,20 +490,10 @@ bool expr_t::op_t::print(std::ostream& out, const context_t& context) const break; case O_CONS: - if (has_right()) { - out << "("; - if (left() && left()->print(out, context)) - found = true; - for (ptr_op_t next = right(); next; next = next->right()) { - out << ", "; - if (next->print(out, context)) - found = true; - } - out << ")"; - } - else if (left() && left()->print(out, context)) { - found = true; - } + assert(has_right()); + out << "("; + found = print_cons(out, this, context); + out << ")"; break; case O_DEFINE: @@ -243,10 +243,10 @@ private: checked_delete(this); } - friend inline void intrusive_ptr_add_ref(op_t * op) { + friend inline void intrusive_ptr_add_ref(const op_t * op) { op->acquire(); } - friend inline void intrusive_ptr_release(op_t * op) { + friend inline void intrusive_ptr_release(const op_t * op) { op->release(); } |