Recompile the amount_expr before summing account totals.
This commit is contained in:
parent
e0fab726c6
commit
3ee3b8f327
3 changed files with 17 additions and 3 deletions
10
src/expr.cc
10
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()) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue