aboutsummaryrefslogtreecommitdiff
path: root/build/variable.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build/variable.cxx')
-rw-r--r--build/variable.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/build/variable.cxx b/build/variable.cxx
index 4386c6a..6e02816 100644
--- a/build/variable.cxx
+++ b/build/variable.cxx
@@ -57,6 +57,14 @@ namespace build
return *this;
}
+ value& value::
+ prepend (value v, const variable& var)
+ {
+ assert (type == v.type);
+ prepend (move (v.data_), var);
+ return *this;
+ }
+
void value::
append (names v, const variable& var)
{
@@ -84,6 +92,37 @@ namespace build
: state_type::empty;
}
+ void value::
+ prepend (names v, const variable& var)
+ {
+ // Reduce to append.
+ //
+ if (!null () && type != nullptr && type->append != nullptr)
+ {
+ state_ = type->append (v, move (data_), var)
+ ? state_type::filled
+ : state_type::empty;
+ swap (data_, v);
+ return;
+ }
+
+ if (data_.empty ())
+ data_ = move (v);
+ else
+ {
+ v.insert (v.end (),
+ make_move_iterator (data_.begin ()),
+ make_move_iterator (data_.end ()));
+ swap (data_, v);
+ }
+
+ state_ = (type != nullptr && type->assign != nullptr
+ ? type->assign (data_, var)
+ : !data_.empty ())
+ ? state_type::filled
+ : state_type::empty;
+ }
+
// bool value
//
bool value_traits<bool>::