summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-28 06:13:49 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-28 06:13:49 -0400
commit19cfd9e23b7cd4a7976591290b17e7ba20dd5a50 (patch)
treea8e2ae738d29748b1cf06c2259cf98bd939bce43 /src
parentc87aa9c2ea26333ec9baee6f4466496445eb8db8 (diff)
downloadfork-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.cc39
-rw-r--r--src/op.h4
2 files changed, 27 insertions, 16 deletions
diff --git a/src/op.cc b/src/op.cc
index 9b50c9f7..beffab9e 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -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:
diff --git a/src/op.h b/src/op.h
index 94df154e..ea787d8c 100644
--- a/src/op.h
+++ b/src/op.h
@@ -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();
}