diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-23 01:09:23 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-23 01:09:23 -0400 |
commit | 5ba81765eabcb0fe0b7a865b7a2c9c6affab4a59 (patch) | |
tree | c5c55dcfebebd713035b2d029af6d3672a30dfb3 /src/op.cc | |
parent | 8156e341361a03958a217d1a457eff47212661ee (diff) | |
download | fork-ledger-5ba81765eabcb0fe0b7a865b7a2c9c6affab4a59.tar.gz fork-ledger-5ba81765eabcb0fe0b7a865b7a2c9c6affab4a59.tar.bz2 fork-ledger-5ba81765eabcb0fe0b7a865b7a2c9c6affab4a59.zip |
Added some debug code.
Diffstat (limited to 'src/op.cc')
-rw-r--r-- | src/op.cc | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -37,32 +37,34 @@ namespace ledger { expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope) { - switch (kind) { - case IDENT: + if (kind == IDENT) { + DEBUG("expr.compile", "Looking up identifier '" << as_ident() << "'"); + if (ptr_op_t def = scope.lookup(as_ident())) { // Identifier references are first looked up at the point of // definition, and then at the point of every use if they could // not be found there. + if (SHOW_DEBUG("expr.compile")) { + DEBUG("expr.compile", "Found definition:"); + def->dump(*_log_stream, 0); + } return copy(def); } return this; - - default: - break; } if (kind < TERMINALS) return this; ptr_op_t lhs(left()->compile(scope)); - ptr_op_t rhs(kind > UNARY_OPERATORS && has_right() ? - right()->compile(scope) : ptr_op_t()); + ptr_op_t rhs(has_right() ? right()->compile(scope) : ptr_op_t()); if (lhs == left() && (! rhs || rhs == right())) return this; ptr_op_t intermediate(copy(lhs, rhs)); + // Reduce constants immediately if possible if (lhs->is_value() && (! rhs || rhs->is_value())) return wrap_value(intermediate->calc(scope)); |