libexpr: Replace Value::mkNull with Value::VNULL
A small step towards fixing #744 Change-Id: If8304d4de20bae07b33eb7825f781e0f6a6a6964
This commit is contained in:
+1
-1
@@ -862,7 +862,7 @@ void EvalState::mkPos(Value & v, PosIdx p)
|
||||
std::tie(line, col) = makePositionThunks(*this, p);
|
||||
v = {NewValueAs::attrs, attrs};
|
||||
} else
|
||||
v.mkNull();
|
||||
v = Value::VNULL;
|
||||
}
|
||||
|
||||
Value EvalPaths::mkStorePathString(const StorePath & p)
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
|
||||
bool null() override
|
||||
{
|
||||
rs->value().mkNull();
|
||||
rs->value() = Value::VNULL;
|
||||
rs->add();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1899,7 +1899,7 @@ static void prim_unsafeGetAttrPos(EvalState & state, Value * * args, Value & v)
|
||||
state.forceAttrs(*args[1], noPos, "while evaluating the second argument passed to builtins.unsafeGetAttrPos");
|
||||
auto i = args[1]->attrs()->get(state.ctx.symbols.create(attr));
|
||||
if (!i) {
|
||||
v.mkNull();
|
||||
v = Value::VNULL;
|
||||
} else {
|
||||
state.mkPos(v, i->pos);
|
||||
}
|
||||
@@ -2853,7 +2853,7 @@ void prim_match(EvalState & state, Value * * args, Value & v)
|
||||
|
||||
std::cmatch match;
|
||||
if (!std::regex_match(str.begin(), str.end(), match, regex)) {
|
||||
v.mkNull();
|
||||
v = Value::VNULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2863,7 +2863,7 @@ void prim_match(EvalState & state, Value * * args, Value & v)
|
||||
v = {NewValueAs::list, result};
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (!match[i+1].matched)
|
||||
result->elems[i].mkNull();
|
||||
result->elems[i] = Value::VNULL;
|
||||
else
|
||||
result->elems[i] = {NewValueAs::string, match[i + 1].str()};
|
||||
}
|
||||
@@ -2916,7 +2916,7 @@ void prim_split(EvalState & state, Value * * args, Value & v)
|
||||
elem = {NewValueAs::list, content};
|
||||
for (size_t si = 0; si < slen; ++si) {
|
||||
if (!match[si + 1].matched)
|
||||
content->elems[si].mkNull();
|
||||
content->elems[si] = Value::VNULL;
|
||||
else
|
||||
content->elems[si] = {NewValueAs::string, match[si + 1].str()};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void prim_fromTOML(EvalState & state, Value ** args, Value & val)
|
||||
throw std::runtime_error("Dates and times are not supported");
|
||||
break;
|
||||
case toml::value_t::empty:
|
||||
v.mkNull();
|
||||
v = Value::VNULL;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -766,11 +766,6 @@ public:
|
||||
*/
|
||||
inline ValueType type(bool invalidIsThunk = false) const;
|
||||
|
||||
inline void mkNull()
|
||||
{
|
||||
*this = {NewValueAs::null};
|
||||
}
|
||||
|
||||
bool isList() const
|
||||
{
|
||||
return internalType() == tList;
|
||||
|
||||
@@ -29,7 +29,7 @@ static void prim_anotherNull (EvalState & state, Value ** args, Value & v)
|
||||
{
|
||||
assert(entryCalled);
|
||||
if (mySettings.settingSet)
|
||||
v.mkNull();
|
||||
v = Value::VNULL;
|
||||
else
|
||||
v = {NewValueAs::boolean, false};
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ namespace nix {
|
||||
};
|
||||
|
||||
TEST_F(JSONValueTest, null) {
|
||||
Value v;
|
||||
v.mkNull();
|
||||
Value v = Value::VNULL;
|
||||
ASSERT_EQ(getJSONValue(v), "null");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,7 @@ TEST_F(ValuePrintingTests, tPath)
|
||||
|
||||
TEST_F(ValuePrintingTests, tNull)
|
||||
{
|
||||
Value vNull;
|
||||
vNull.mkNull();
|
||||
Value vNull = Value::VNULL;
|
||||
test(vNull, "null");
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ TEST_F(ValuePrintingTests, vThunk)
|
||||
TEST_F(ValuePrintingTests, vApp)
|
||||
{
|
||||
EvalMemory mem;
|
||||
Value vFn{NewValueAs::null};
|
||||
Value vFn = Value::VNULL;
|
||||
Value vApp{NewValueAs::app, mem, vFn, vFn};
|
||||
|
||||
test(vApp, "«thunk»");
|
||||
@@ -368,8 +367,7 @@ TEST_F(ValuePrintingTests, ansiColorsPath)
|
||||
|
||||
TEST_F(ValuePrintingTests, ansiColorsNull)
|
||||
{
|
||||
Value v;
|
||||
v.mkNull();
|
||||
Value v = Value::VNULL;
|
||||
|
||||
test(v,
|
||||
ANSI_CYAN "null" ANSI_NORMAL,
|
||||
|
||||
Reference in New Issue
Block a user