diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-04 20:07:44 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-04 20:40:45 -0500 |
commit | 4a14f3224b9063202ca39a67c9aff42ae4274942 (patch) | |
tree | 2b4f556ea845debe967c0f4b7c5d7782961fdccb | |
parent | b14c814fec11ab450c552bccf5fe7d96dc2c4e18 (diff) | |
download | fork-ledger-4a14f3224b9063202ca39a67c9aff42ae4274942.tar.gz fork-ledger-4a14f3224b9063202ca39a67c9aff42ae4274942.tar.bz2 fork-ledger-4a14f3224b9063202ca39a67c9aff42ae4274942.zip |
Added value_t::push_front
-rw-r--r-- | src/option.h | 1 | ||||
-rw-r--r-- | src/scope.h | 3 | ||||
-rw-r--r-- | src/value.h | 10 |
3 files changed, 13 insertions, 1 deletions
diff --git a/src/option.h b/src/option.h index 0600779c..7e2e0629 100644 --- a/src/option.h +++ b/src/option.h @@ -190,6 +190,7 @@ public: virtual value_t operator()(call_scope_t& args) { if (! args.empty()) { + args.push_front(string_value("?expr")); return handler_wrapper(args); } else if (wants_arg) { diff --git a/src/scope.h b/src/scope.h index f7c2f46b..36eb54f1 100644 --- a/src/scope.h +++ b/src/scope.h @@ -196,6 +196,9 @@ public: return args[index]; } + void push_front(const value_t& val) { + args.push_front(val); + } void push_back(const value_t& val) { args.push_back(val); } diff --git a/src/value.h b/src/value.h index a0bb533d..0993305e 100644 --- a/src/value.h +++ b/src/value.h @@ -87,7 +87,7 @@ public: * The sequence_t member type abstracts the type used to represent a * resizable "array" of value_t objects. */ - typedef std::vector<value_t> sequence_t; + typedef std::deque<value_t> sequence_t; typedef sequence_t::iterator iterator; typedef sequence_t::const_iterator const_iterator; typedef sequence_t::difference_type difference_type; @@ -800,6 +800,14 @@ public: return null; } + void push_front(const value_t& val) { + if (is_null()) + *this = sequence_t(); + if (! is_sequence()) + in_place_cast(SEQUENCE); + as_sequence_lval().push_front(val); + } + void push_back(const value_t& val) { if (is_null()) *this = sequence_t(); |