summaryrefslogtreecommitdiff
path: root/src/op.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-07 12:46:46 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-07 12:46:46 -0600
commit7e250696e02e0392bc865f66570da296ced124ab (patch)
tree8195a38ca7c6e04610f2ca3cecea900ff08f66de /src/op.cc
parent77292ac3cda2f1052559991b9d53f1ad7c1fec9a (diff)
downloadfork-ledger-7e250696e02e0392bc865f66570da296ced124ab.tar.gz
fork-ledger-7e250696e02e0392bc865f66570da296ced124ab.tar.bz2
fork-ledger-7e250696e02e0392bc865f66570da296ced124ab.zip
Many options now have additive effect
For example, -A and -V used to override each other, whereas now: -A report the average amount -V report all amounts at current value -AV report the current value of the average -VA report the average of all current values
Diffstat (limited to 'src/op.cc')
-rw-r--r--src/op.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/op.cc b/src/op.cc
index a8b71468..a5db1690 100644
--- a/src/op.cc
+++ b/src/op.cc
@@ -89,8 +89,9 @@ namespace {
expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth,
scope_t * param_scope)
{
- scope_t * scope_ptr = &scope;
- expr_t::ptr_op_t result;
+ scope_t * scope_ptr = &scope;
+ unique_ptr<scope_t> bound_scope;
+ expr_t::ptr_op_t result;
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) {
@@ -129,9 +130,10 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth,
}
}
else if (is_scope()) {
- shared_ptr<scope_t> subscope(new symbol_scope_t(scope));
+ shared_ptr<scope_t> subscope(new symbol_scope_t(*scope_t::empty_scope));
set_scope(subscope);
- scope_ptr = subscope.get();
+ bound_scope.reset(new bind_scope_t(*scope_ptr, *subscope.get()));
+ scope_ptr = bound_scope.get();
}
else if (kind < TERMINALS) {
result = this;
@@ -153,8 +155,8 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth,
node->set_left(left()->right());
node->set_right(right());
- empty_scope_t empty_scope;
- symbol_scope_t params(param_scope ? *param_scope : empty_scope);
+ symbol_scope_t params(param_scope ?
+ *param_scope : *scope_t::empty_scope);
for (ptr_op_t sym = node->left();
sym;
sym = sym->has_right() ? sym->right() : NULL) {
@@ -330,8 +332,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus, const int depth)
call_scope_t& call_args(find_scope<call_scope_t>(scope, true));
std::size_t args_count(call_args.size());
std::size_t args_index(0);
- empty_scope_t empty_scope;
- symbol_scope_t args_scope(empty_scope);
+ symbol_scope_t args_scope(*scope_t::empty_scope);
for (ptr_op_t sym = left();
sym;