summaryrefslogtreecommitdiff
path: root/src/op.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-01-23 01:09:23 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-01-23 01:09:23 -0400
commit5ba81765eabcb0fe0b7a865b7a2c9c6affab4a59 (patch)
treec5c55dcfebebd713035b2d029af6d3672a30dfb3 /src/op.cc
parent8156e341361a03958a217d1a457eff47212661ee (diff)
downloadfork-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.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/op.cc b/src/op.cc
index e8c2a8e6..2d71f8b5 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -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));