diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-23 02:11:58 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-23 02:11:58 -0400 |
commit | 1091f0d07b8fae388202a449239e8de321545a2a (patch) | |
tree | c96ec5bc1d63f80b31284c502094db969720f741 /valexpr.cc | |
parent | 6365b8b7a807351209330ba65b05e612c5901908 (diff) | |
download | fork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.tar.gz fork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.tar.bz2 fork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.zip |
slight cleanup
Diffstat (limited to 'valexpr.cc')
-rw-r--r-- | valexpr.cc | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -66,8 +66,7 @@ bool mask_t::match(const std::string& str) const } -void value_expr_t::compute(value_t& result, const details_t& details, - value_t::type_t type) const +void value_expr_t::compute(value_t& result, const details_t& details) const { switch (kind) { case CONSTANT_I: @@ -249,7 +248,7 @@ void value_expr_t::compute(value_t& result, const details_t& details, case F_VALUE: { assert(left); - left->compute(result, details, value_t::BALANCE); + left->compute(result, details); std::time_t moment = now; if (right) { @@ -258,21 +257,33 @@ void value_expr_t::compute(value_t& result, const details_t& details, if (details.entry) moment = details.entry->date; break; - case CONSTANT_T: moment = right->constant_t; break; - default: throw compute_error("Invalid date passed to P(value,date)"); } } - result = (*((balance_t *)result.data)).value(moment); + + switch (result.type) { + case value_t::BOOLEAN: + case value_t::INTEGER: + break; + case value_t::AMOUNT: + result = ((amount_t *)result.data)->value(moment); + break; + case value_t::BALANCE: + result = ((balance_t *)result.data)->value(moment); + break; + case value_t::BALANCE_PAIR: + result = ((balance_pair_t *)result.data)->quantity.value(moment); + break; + } break; } case O_NOT: - left->compute(result, details, value_t::BOOLEAN); + left->compute(result, details); result.negate(); break; @@ -280,7 +291,7 @@ void value_expr_t::compute(value_t& result, const details_t& details, assert(left); assert(right); assert(right->kind == O_COL); - left->compute(result, details, value_t::BOOLEAN); + left->compute(result, details); if (result) right->left->compute(result, details); else @@ -290,17 +301,17 @@ void value_expr_t::compute(value_t& result, const details_t& details, case O_AND: assert(left); assert(right); - left->compute(result, details, value_t::BOOLEAN); + left->compute(result, details); if (result) - right->compute(result, details, value_t::BOOLEAN); + right->compute(result, details); break; case O_OR: assert(left); assert(right); - left->compute(result, details, value_t::BOOLEAN); + left->compute(result, details); if (! result) - right->compute(result, details, value_t::BOOLEAN); + right->compute(result, details); break; case O_EQ: @@ -348,9 +359,6 @@ void value_expr_t::compute(value_t& result, const details_t& details, assert(0); break; } - - if (type < value_t::ANY && type != result.type) - result.cast(type); } value_expr_t * parse_value_term(std::istream& in); |