summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-09 14:51:45 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-09 14:51:45 -0400
commit3ee3b8f327fa1943dba4ef6043559186b26f86b4 (patch)
tree31809a41826e69aa5ae3c3ed9789d2fb4a2fad52 /src
parente0fab726c6e9e5e9ecc5b8cd6a7be2e8233826a6 (diff)
downloadfork-ledger-3ee3b8f327fa1943dba4ef6043559186b26f86b4.tar.gz
fork-ledger-3ee3b8f327fa1943dba4ef6043559186b26f86b4.tar.bz2
fork-ledger-3ee3b8f327fa1943dba4ef6043559186b26f86b4.zip
Recompile the amount_expr before summing account totals.
Diffstat (limited to 'src')
-rw-r--r--src/expr.cc10
-rw-r--r--src/expr.h4
-rw-r--r--src/report.cc6
3 files changed, 17 insertions, 3 deletions
diff --git a/src/expr.cc b/src/expr.cc
index 14fb2be8..b0262f17 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -107,15 +107,21 @@ void expr_t::parse(std::istream& in, const uint32_t flags,
compiled = false;
}
-void expr_t::compile(scope_t& scope)
+void expr_t::recompile(scope_t& scope)
{
- if (ptr.get() && ! compiled) {
+ if (ptr.get()) {
ptr = ptr->compile(scope);
context = &scope;
compiled = true;
}
}
+void expr_t::compile(scope_t& scope)
+{
+ if (! compiled)
+ recompile(scope);
+}
+
value_t expr_t::calc(scope_t& scope)
{
if (ptr.get()) {
diff --git a/src/expr.h b/src/expr.h
index cebc7740..5b6b650d 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -128,6 +128,10 @@ public:
void parse(std::istream& in, const uint32_t flags = 0,
const string * original_string = NULL);
+ void mark_uncompiled() {
+ compiled = false;
+ }
+ void recompile(scope_t& scope);
void compile(scope_t& scope);
value_t calc(scope_t& scope);
value_t calc(scope_t& scope) const;
diff --git a/src/report.cc b/src/report.cc
index e510ac8d..9966a339 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -107,12 +107,16 @@ void report_t::entry_report(xact_handler_ptr handler, entry_t& entry)
void report_t::sum_all_accounts()
{
+ expr_t& expr(HANDLER(amount_).expr);
+ expr.set_context(this);
+
session_xacts_iterator walker(session);
pass_down_xacts
(chain_xact_handlers(*this, xact_handler_ptr(new set_account_value), false),
walker);
- session.master->calculate_sums(HANDLER(amount_).expr, *this);
+ expr.mark_uncompiled(); // recompile, throw away xact_t bindings
+ session.master->calculate_sums(expr);
}
void report_t::accounts_report(acct_handler_ptr handler)