aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-18 10:17:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-18 10:17:37 +0200
commitae20570f2ad55b2fa8e71cf450457cb9c4b21b1b (patch)
tree4db6740878ffb28fb00c5fc323a1891300db749e /build2/variable.ixx
parente2501db05c9e9f139d22f3748584992679954721 (diff)
Add support for using value attributes in eval context
For example: if ($x == [null]) Or: if ([uint64] 01 == [uint64] 1)
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r--build2/variable.ixx22
1 files changed, 19 insertions, 3 deletions
diff --git a/build2/variable.ixx b/build2/variable.ixx
index 9b29608..3184108 100644
--- a/build2/variable.ixx
+++ b/build2/variable.ixx
@@ -8,6 +8,15 @@ namespace build2
{
// value
//
+ inline value::
+ value (names&& ns)
+ : type (nullptr),
+ state (ns.empty () ? value_state::empty : value_state::filled),
+ extra (0)
+ {
+ new (&data_) names (move (ns));
+ }
+
inline value& value::
operator= (reference_wrapper<value> v)
{
@@ -146,7 +155,7 @@ namespace build2
value_type& t (value_traits<T>::value_type);
if (v.type != &t)
- typify (v, t, var);
+ typify (v, t, &var);
}
inline names_view
@@ -158,6 +167,13 @@ namespace build2
return v.type == nullptr ? v.as<names> () : v.type->reverse (v, storage);
}
+ inline vector_view<name>
+ reverse (value& v, names& storage)
+ {
+ names_view cv (reverse (static_cast<const value&> (v), storage));
+ return vector_view<name> (const_cast<name*> (cv.data ()), cv.size ());
+ }
+
// value_traits
//
template <typename T>
@@ -610,7 +626,7 @@ namespace build2
// First access after being assigned a type?
//
if (var.type != nullptr && val.type != var.type)
- typify (const_cast<value&> (val), *var.type, var);
+ typify (const_cast<value&> (val), *var.type, &var);
return r;
}
@@ -626,7 +642,7 @@ namespace build2
// First access after being assigned a type?
//
if (var.type != nullptr && val.type != var.type)
- typify (const_cast<value&> (val), *var.type, var);
+ typify (const_cast<value&> (val), *var.type, &var);
return p;
}