diff options
author | John Wiegley <johnw@newartisans.com> | 2012-03-09 01:29:11 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2012-03-09 01:29:11 -0600 |
commit | b0cf90ab50ac42d3184d70cb1906778df034ddaa (patch) | |
tree | fef013c20589f8c9eb47c3ba3401525812c69b05 /src | |
parent | c62ceeef5a577731eb1921bd860e2c4c0b715eca (diff) | |
download | fork-ledger-b0cf90ab50ac42d3184d70cb1906778df034ddaa.tar.gz fork-ledger-b0cf90ab50ac42d3184d70cb1906778df034ddaa.tar.bz2 fork-ledger-b0cf90ab50ac42d3184d70cb1906778df034ddaa.zip |
Added int and str value expression functions
Diffstat (limited to 'src')
-rw-r--r-- | src/session.cc | 19 | ||||
-rw-r--r-- | src/session.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/session.cc b/src/session.cc index 3e7cdb3d..7c546b82 100644 --- a/src/session.cc +++ b/src/session.cc @@ -268,6 +268,15 @@ value_t session_t::fn_max(call_scope_t& args) return args[1] > args[0] ? args[1] : args[0]; } +value_t session_t::fn_int(call_scope_t& args) +{ + return args[0].to_long(); +} +value_t session_t::fn_str(call_scope_t& args) +{ + return string_value(args[0].to_string()); +} + value_t session_t::fn_lot_price(call_scope_t& args) { amount_t amt(args.get<amount_t>(1, false)); @@ -360,6 +369,11 @@ expr_t::ptr_op_t session_t::lookup(const symbol_t::kind_t kind, return MAKE_FUNCTOR(session_t::fn_lot_tag); break; + case 'i': + if (is_eq(p, "int")) + return MAKE_FUNCTOR(session_t::fn_int); + break; + case 'm': if (is_eq(p, "min")) return MAKE_FUNCTOR(session_t::fn_min); @@ -367,6 +381,11 @@ expr_t::ptr_op_t session_t::lookup(const symbol_t::kind_t kind, return MAKE_FUNCTOR(session_t::fn_max); break; + case 's': + if (is_eq(p, "str")) + return MAKE_FUNCTOR(session_t::fn_str); + break; + default: break; } diff --git a/src/session.h b/src/session.h index cfeced39..b06c4a42 100644 --- a/src/session.h +++ b/src/session.h @@ -86,6 +86,8 @@ public: value_t fn_account(call_scope_t& scope); value_t fn_min(call_scope_t& scope); value_t fn_max(call_scope_t& scope); + value_t fn_int(call_scope_t& scope); + value_t fn_str(call_scope_t& scope); value_t fn_lot_price(call_scope_t& scope); value_t fn_lot_date(call_scope_t& scope); value_t fn_lot_tag(call_scope_t& scope); |