From ae20570f2ad55b2fa8e71cf450457cb9c4b21b1b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Apr 2016 10:17:37 +0200 Subject: Add support for using value attributes in eval context For example: if ($x == [null]) Or: if ([uint64] 01 == [uint64] 1) --- build2/variable.ixx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'build2/variable.ixx') 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 v) { @@ -146,7 +155,7 @@ namespace build2 value_type& t (value_traits::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 () : v.type->reverse (v, storage); } + inline vector_view + reverse (value& v, names& storage) + { + names_view cv (reverse (static_cast (v), storage)); + return vector_view (const_cast (cv.data ()), cv.size ()); + } + // value_traits // template @@ -610,7 +626,7 @@ namespace build2 // First access after being assigned a type? // if (var.type != nullptr && val.type != var.type) - typify (const_cast (val), *var.type, var); + typify (const_cast (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 (val), *var.type, var); + typify (const_cast (val), *var.type, &var); return p; } -- cgit v1.1