summaryrefslogtreecommitdiff
path: root/valexpr.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-23 02:11:58 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-23 02:11:58 -0400
commit1091f0d07b8fae388202a449239e8de321545a2a (patch)
treec96ec5bc1d63f80b31284c502094db969720f741 /valexpr.cc
parent6365b8b7a807351209330ba65b05e612c5901908 (diff)
downloadfork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.tar.gz
fork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.tar.bz2
fork-ledger-1091f0d07b8fae388202a449239e8de321545a2a.zip
slight cleanup
Diffstat (limited to 'valexpr.cc')
-rw-r--r--valexpr.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/valexpr.cc b/valexpr.cc
index 4c520419..64a0a0f9 100644
--- a/valexpr.cc
+++ b/valexpr.cc
@@ -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);