aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/attr-path.cc2
-rw-r--r--src/libexpr/eval-cache.cc26
-rw-r--r--src/libexpr/eval-inline.hh4
-rw-r--r--src/libexpr/eval.cc74
-rw-r--r--src/libexpr/flake/flake.cc16
-rw-r--r--src/libexpr/get-drvs.cc30
-rw-r--r--src/libexpr/primops.cc44
-rw-r--r--src/libexpr/primops/fetchMercurial.cc2
-rw-r--r--src/libexpr/primops/fetchTree.cc12
-rw-r--r--src/libexpr/value-to-json.cc2
-rw-r--r--src/libexpr/value-to-xml.cc6
-rw-r--r--src/libexpr/value.hh6
-rw-r--r--src/nix-env/nix-env.cc16
-rw-r--r--src/nix/eval.cc4
-rw-r--r--src/nix/flake.cc2
-rw-r--r--src/nix/repl.cc4
16 files changed, 125 insertions, 125 deletions
diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc
index 54e13e6a2..2d37dcb7e 100644
--- a/src/libexpr/attr-path.cc
+++ b/src/libexpr/attr-path.cc
@@ -67,7 +67,7 @@ std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attr
if (apType == apAttr) {
- if (v->normalType() != nAttrs)
+ if (v->type() != nAttrs)
throw TypeError(
"the expression selected by the selection path '%1%' should be a set but is %2%",
attrPath,
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc
index 3c97f1201..75e9af787 100644
--- a/src/libexpr/eval-cache.cc
+++ b/src/libexpr/eval-cache.cc
@@ -390,14 +390,14 @@ Value & AttrCursor::forceValue()
}
if (root->db && (!cachedValue || std::get_if<placeholder_t>(&cachedValue->second))) {
- if (v.normalType() == nString)
+ if (v.type() == nString)
cachedValue = {root->db->setString(getKey(), v.string.s, v.string.context),
string_t{v.string.s, {}}};
- else if (v.normalType() == nPath)
+ else if (v.type() == nPath)
cachedValue = {root->db->setString(getKey(), v.path), v.path};
- else if (v.normalType() == nBool)
+ else if (v.type() == nBool)
cachedValue = {root->db->setBool(getKey(), v.boolean), v.boolean};
- else if (v.normalType() == nAttrs)
+ else if (v.type() == nAttrs)
; // FIXME: do something?
else
cachedValue = {root->db->setMisc(getKey()), misc_t()};
@@ -442,7 +442,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name, bool forceErro
auto & v = forceValue();
- if (v.normalType() != nAttrs)
+ if (v.type() != nAttrs)
return nullptr;
//throw TypeError("'%s' is not an attribute set", getAttrPathStr());
@@ -512,10 +512,10 @@ std::string AttrCursor::getString()
auto & v = forceValue();
- if (v.normalType() != nString && v.normalType() != nPath)
- throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.normalType()));
+ if (v.type() != nString && v.type() != nPath)
+ throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
- return v.normalType() == nString ? v.string.s : v.path;
+ return v.type() == nString ? v.string.s : v.path;
}
string_t AttrCursor::getStringWithContext()
@@ -543,12 +543,12 @@ string_t AttrCursor::getStringWithContext()
auto & v = forceValue();
- if (v.normalType() == nString)
+ if (v.type() == nString)
return {v.string.s, v.getContext()};
- else if (v.normalType() == nPath)
+ else if (v.type() == nPath)
return {v.path, {}};
else
- throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.normalType()));
+ throw TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
}
bool AttrCursor::getBool()
@@ -567,7 +567,7 @@ bool AttrCursor::getBool()
auto & v = forceValue();
- if (v.normalType() != nBool)
+ if (v.type() != nBool)
throw TypeError("'%s' is not a Boolean", getAttrPathStr());
return v.boolean;
@@ -589,7 +589,7 @@ std::vector<Symbol> AttrCursor::getAttrs()
auto & v = forceValue();
- if (v.normalType() != nAttrs)
+ if (v.type() != nAttrs)
throw TypeError("'%s' is not an attribute set", getAttrPathStr());
std::vector<Symbol> attrs;
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index 8c40c2565..e56ce261c 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -56,7 +56,7 @@ void EvalState::forceValue(Value & v, const Pos & pos)
inline void EvalState::forceAttrs(Value & v)
{
forceValue(v);
- if (v.normalType() != nAttrs)
+ if (v.type() != nAttrs)
throwTypeError("value is %1% while a set was expected", v);
}
@@ -64,7 +64,7 @@ inline void EvalState::forceAttrs(Value & v)
inline void EvalState::forceAttrs(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() != nAttrs)
+ if (v.type() != nAttrs)
throwTypeError(pos, "value is %1% while a set was expected", v);
}
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index e14eb01c7..2f8d6d259 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -197,7 +197,7 @@ string showType(const Value & v)
case tApp: return "a function application";
case tBlackhole: return "a black hole";
default:
- return showType(v.normalType());
+ return showType(v.type());
}
}
@@ -947,7 +947,7 @@ inline bool EvalState::evalBool(Env & env, Expr * e)
{
Value v;
e->eval(*this, env, v);
- if (v.normalType() != nBool)
+ if (v.type() != nBool)
throwTypeError("value is %1% while a Boolean was expected", v);
return v.boolean;
}
@@ -957,7 +957,7 @@ inline bool EvalState::evalBool(Env & env, Expr * e, const Pos & pos)
{
Value v;
e->eval(*this, env, v);
- if (v.normalType() != nBool)
+ if (v.type() != nBool)
throwTypeError(pos, "value is %1% while a Boolean was expected", v);
return v.boolean;
}
@@ -966,7 +966,7 @@ inline bool EvalState::evalBool(Env & env, Expr * e, const Pos & pos)
inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v)
{
e->eval(*this, env, v);
- if (v.normalType() != nAttrs)
+ if (v.type() != nAttrs)
throwTypeError("value is %1% while a set was expected", v);
}
@@ -1066,7 +1066,7 @@ void ExprAttrs::eval(EvalState & state, Env & env, Value & v)
Value nameVal;
i.nameExpr->eval(state, *dynamicEnv, nameVal);
state.forceValue(nameVal, i.pos);
- if (nameVal.normalType() == nNull)
+ if (nameVal.type() == nNull)
continue;
state.forceStringNoCtx(nameVal);
Symbol nameSym = state.symbols.create(nameVal.string.s);
@@ -1151,7 +1151,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
Symbol name = getName(i, state, env);
if (def) {
state.forceValue(*vAttrs, pos);
- if (vAttrs->normalType() != nAttrs ||
+ if (vAttrs->type() != nAttrs ||
(j = vAttrs->attrs->find(name)) == vAttrs->attrs->end())
{
def->eval(state, env, v);
@@ -1191,7 +1191,7 @@ void ExprOpHasAttr::eval(EvalState & state, Env & env, Value & v)
state.forceValue(*vAttrs);
Bindings::iterator j;
Symbol name = getName(i, state, env);
- if (vAttrs->normalType() != nAttrs ||
+ if (vAttrs->type() != nAttrs ||
(j = vAttrs->attrs->find(name)) == vAttrs->attrs->end())
{
mkBool(v, false);
@@ -1269,7 +1269,7 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & po
return;
}
- if (fun.normalType() == nAttrs) {
+ if (fun.type() == nAttrs) {
auto found = fun.attrs->find(sFunctor);
if (found != fun.attrs->end()) {
/* fun may be allocated on the stack of the calling function,
@@ -1368,7 +1368,7 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
{
forceValue(fun);
- if (fun.normalType() == nAttrs) {
+ if (fun.type() == nAttrs) {
auto found = fun.attrs->find(sFunctor);
if (found != fun.attrs->end()) {
Value * v = allocValue();
@@ -1573,14 +1573,14 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
since paths are copied when they are used in a derivation),
and none of the strings are allowed to have contexts. */
if (first) {
- firstType = vTmp.normalType();
+ firstType = vTmp.type();
first = false;
}
if (firstType == nInt) {
- if (vTmp.normalType() == nInt) {
+ if (vTmp.type() == nInt) {
n += vTmp.integer;
- } else if (vTmp.normalType() == nFloat) {
+ } else if (vTmp.type() == nFloat) {
// Upgrade the type from int to float;
firstType = nFloat;
nf = n;
@@ -1588,9 +1588,9 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
} else
throwEvalError(pos, "cannot add %1% to an integer", showType(vTmp));
} else if (firstType == nFloat) {
- if (vTmp.normalType() == nInt) {
+ if (vTmp.type() == nInt) {
nf += vTmp.integer;
- } else if (vTmp.normalType() == nFloat) {
+ } else if (vTmp.type() == nFloat) {
nf += vTmp.fpoint;
} else
throwEvalError(pos, "cannot add %1% to a float", showType(vTmp));
@@ -1629,7 +1629,7 @@ void EvalState::forceValueDeep(Value & v)
forceValue(v);
- if (v.normalType() == nAttrs) {
+ if (v.type() == nAttrs) {
for (auto & i : *v.attrs)
try {
recurse(*i.value);
@@ -1652,7 +1652,7 @@ void EvalState::forceValueDeep(Value & v)
NixInt EvalState::forceInt(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() != nInt)
+ if (v.type() != nInt)
throwTypeError(pos, "value is %1% while an integer was expected", v);
return v.integer;
}
@@ -1661,9 +1661,9 @@ NixInt EvalState::forceInt(Value & v, const Pos & pos)
NixFloat EvalState::forceFloat(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() == nInt)
+ if (v.type() == nInt)
return v.integer;
- else if (v.normalType() != nFloat)
+ else if (v.type() != nFloat)
throwTypeError(pos, "value is %1% while a float was expected", v);
return v.fpoint;
}
@@ -1672,7 +1672,7 @@ NixFloat EvalState::forceFloat(Value & v, const Pos & pos)
bool EvalState::forceBool(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() != nBool)
+ if (v.type() != nBool)
throwTypeError(pos, "value is %1% while a Boolean was expected", v);
return v.boolean;
}
@@ -1680,14 +1680,14 @@ bool EvalState::forceBool(Value & v, const Pos & pos)
bool EvalState::isFunctor(Value & fun)
{
- return fun.normalType() == nAttrs && fun.attrs->find(sFunctor) != fun.attrs->end();
+ return fun.type() == nAttrs && fun.attrs->find(sFunctor) != fun.attrs->end();
}
void EvalState::forceFunction(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() != nFunction && !isFunctor(v))
+ if (v.type() != nFunction && !isFunctor(v))
throwTypeError(pos, "value is %1% while a function was expected", v);
}
@@ -1695,7 +1695,7 @@ void EvalState::forceFunction(Value & v, const Pos & pos)
string EvalState::forceString(Value & v, const Pos & pos)
{
forceValue(v, pos);
- if (v.normalType() != nString) {
+ if (v.type() != nString) {
if (pos)
throwTypeError(pos, "value is %1% while a string was expected", v);
else
@@ -1761,11 +1761,11 @@ string EvalState::forceStringNoCtx(Value & v, const Pos & pos)
bool EvalState::isDerivation(Value & v)
{
- if (v.normalType() != nAttrs) return false;
+ if (v.type() != nAttrs) return false;
Bindings::iterator i = v.attrs->find(sType);
if (i == v.attrs->end()) return false;
forceValue(*i->value);
- if (i->value->normalType() != nString) return false;
+ if (i->value->type() != nString) return false;
return strcmp(i->value->string.s, "derivation") == 0;
}
@@ -1790,17 +1790,17 @@ string EvalState::coerceToString(const Pos & pos, Value & v, PathSet & context,
string s;
- if (v.normalType() == nString) {
+ if (v.type() == nString) {
copyContext(v, context);
return v.string.s;
}
- if (v.normalType() == nPath) {
+ if (v.type() == nPath) {
Path path(canonPath(v.path));
return copyToStore ? copyPathToStore(context, path) : path;
}
- if (v.normalType() == nAttrs) {
+ if (v.type() == nAttrs) {
auto maybeString = tryAttrsToString(pos, v, context, coerceMore, copyToStore);
if (maybeString) {
return *maybeString;
@@ -1810,18 +1810,18 @@ string EvalState::coerceToString(const Pos & pos, Value & v, PathSet & context,
return coerceToString(pos, *i->value, context, coerceMore, copyToStore);
}
- if (v.normalType() == nExternal)
+ if (v.type() == nExternal)
return v.external->coerceToString(pos, context, coerceMore, copyToStore);
if (coerceMore) {
/* Note that `false' is represented as an empty string for
shell scripting convenience, just like `null'. */
- if (v.normalType() == nBool && v.boolean) return "1";
- if (v.normalType() == nBool && !v.boolean) return "";
- if (v.normalType() == nInt) return std::to_string(v.integer);
- if (v.normalType() == nFloat) return std::to_string(v.fpoint);
- if (v.normalType() == nNull) return "";
+ if (v.type() == nBool && v.boolean) return "1";
+ if (v.type() == nBool && !v.boolean) return "";
+ if (v.type() == nInt) return std::to_string(v.integer);
+ if (v.type() == nFloat) return std::to_string(v.fpoint);
+ if (v.type() == nNull) return "";
if (v.isList()) {
string result;
@@ -1884,15 +1884,15 @@ bool EvalState::eqValues(Value & v1, Value & v2)
if (&v1 == &v2) return true;
// Special case type-compatibility between float and int
- if (v1.normalType() == nInt && v2.normalType() == nFloat)
+ if (v1.type() == nInt && v2.type() == nFloat)
return v1.integer == v2.fpoint;
- if (v1.normalType() == nFloat && v2.normalType() == nInt)
+ if (v1.type() == nFloat && v2.type() == nInt)
return v1.fpoint == v2.integer;
// All other types are not compatible with each other.
- if (v1.normalType() != v2.normalType()) return false;
+ if (v1.type() != v2.type()) return false;
- switch (v1.normalType()) {
+ switch (v1.type()) {
case nInt:
return v1.integer == v2.integer;
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 987e7e24b..4f021570c 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -82,9 +82,9 @@ static void expectType(EvalState & state, ValueType type,
Value & value, const Pos & pos)
{
forceTrivialValue(state, value, pos);
- if (value.normalType() != type)
+ if (value.type() != type)
throw Error("expected %s but got %s at %s",
- showType(type), showType(value.normalType()), pos);
+ showType(type), showType(value.type()), pos);
}
static std::map<FlakeId, FlakeInput> parseFlakeInputs(
@@ -120,7 +120,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
expectType(state, nString, *attr.value, *attr.pos);
input.follows = parseInputPath(attr.value->string.s);
} else {
- if (attr.value->normalType() == nString)
+ if (attr.value->type() == nString)
attrs.emplace(attr.name, attr.value->string.s);
else
throw TypeError("flake input attribute '%s' is %s while a string is expected",
@@ -235,17 +235,17 @@ static Flake getFlake(
for (auto & setting : *nixConfig->value->attrs) {
forceTrivialValue(state, *setting.value, *setting.pos);
- if (setting.value->normalType() == nString)
+ if (setting.value->type() == nString)
flake.config.settings.insert({setting.name, state.forceStringNoCtx(*setting.value, *setting.pos)});
- else if (setting.value->normalType() == nInt)
+ else if (setting.value->type() == nInt)
flake.config.settings.insert({setting.name, state.forceInt(*setting.value, *setting.pos)});
- else if (setting.value->normalType() == nBool)
+ else if (setting.value->type() == nBool)
flake.config.settings.insert({setting.name, state.forceBool(*setting.value, *setting.pos)});
- else if (setting.value->normalType() == nList) {
+ else if (setting.value->type() == nList) {
std::vector<std::string> ss;
for (unsigned int n = 0; n < setting.value->listSize(); ++n) {
auto elem = setting.value->listElems()[n];
- if (elem->normalType() != nString)
+ if (elem->type() != nString)
throw TypeError("list element in flake configuration setting '%s' is %s while a string is expected",
setting.name, showType(*setting.value));
ss.push_back(state.forceStringNoCtx(*elem, *setting.pos));
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 93788273f..32c115c12 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -128,7 +128,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(bool onlyOutputsToInstall)
if (!outTI->isList()) throw errMsg;
Outputs result;
for (auto i = outTI->listElems(); i != outTI->listElems() + outTI->listSize(); ++i) {
- if ((*i)->normalType() != nString) throw errMsg;
+ if ((*i)->type() != nString) throw errMsg;
auto out = outputs.find((*i)->string.s);
if (out == outputs.end()) throw errMsg;
result.insert(*out);
@@ -172,20 +172,20 @@ StringSet DrvInfo::queryMetaNames()
bool DrvInfo::checkMeta(Value & v)
{
state->forceValue(v);
- if (v.normalType() == nList) {
+ if (v.type() == nList) {
for (unsigned int n = 0; n < v.listSize(); ++n)
if (!checkMeta(*v.listElems()[n])) return false;
return true;
}
- else if (v.normalType() == nAttrs) {
+ else if (v.type() == nAttrs) {
Bindings::iterator i = v.attrs->find(state->sOutPath);
if (i != v.attrs->end()) return false;
for (auto & i : *v.attrs)
if (!checkMeta(*i.value)) return false;
return true;
}
- else return v.normalType() == nInt || v.normalType() == nBool || v.normalType() == nString ||
- v.normalType() == nFloat;
+ else return v.type() == nInt || v.type() == nBool || v.type() == nString ||
+ v.type() == nFloat;
}
@@ -201,7 +201,7 @@ Value * DrvInfo::queryMeta(const string & name)
string DrvInfo::queryMetaString(const string & name)
{
Value * v = queryMeta(name);
- if (!v || v->normalType() != nString) return "";
+ if (!v || v->type() != nString) return "";
return v->string.s;
}
@@ -210,8 +210,8 @@ NixInt DrvInfo::queryMetaInt(const string & name, NixInt def)
{
Value * v = queryMeta(name);
if (!v) return def;
- if (v->normalType() == nInt) return v->integer;
- if (v->normalType() == nString) {
+ if (v->type() == nInt) return v->integer;
+ if (v->type() == nString) {
/* Backwards compatibility with before we had support for
integer meta fields. */
NixInt n;
@@ -224,8 +224,8 @@ NixFloat DrvInfo::queryMetaFloat(const string & name, NixFloat def)
{
Value * v = queryMeta(name);
if (!v) return def;
- if (v->normalType() == nFloat) return v->fpoint;
- if (v->normalType() == nString) {
+ if (v->type() == nFloat) return v->fpoint;
+ if (v->type() == nString) {
/* Backwards compatibility with before we had support for
float meta fields. */
NixFloat n;
@@ -239,8 +239,8 @@ bool DrvInfo::queryMetaBool(const string & name, bool def)
{
Value * v = queryMeta(name);
if (!v) return def;
- if (v->normalType() == nBool) return v->boolean;
- if (v->normalType() == nString) {
+ if (v->type() == nBool) return v->boolean;
+ if (v->type() == nString) {
/* Backwards compatibility with before we had support for
Boolean meta fields. */
if (strcmp(v->string.s, "true") == 0) return true;
@@ -331,7 +331,7 @@ static void getDerivations(EvalState & state, Value & vIn,
/* Process the expression. */
if (!getDerivation(state, v, pathPrefix, drvs, done, ignoreAssertionFailures)) ;
- else if (v.normalType() == nAttrs) {
+ else if (v.type() == nAttrs) {
/* !!! undocumented hackery to support combining channels in
nix-env.cc. */
@@ -353,7 +353,7 @@ static void getDerivations(EvalState & state, Value & vIn,
/* If the value of this attribute is itself a set,
should we recurse into it? => Only if it has a
`recurseForDerivations = true' attribute. */
- if (i->value->normalType() == nAttrs) {
+ if (i->value->type() == nAttrs) {
Bindings::iterator j = i->value->attrs->find(state.sRecurseForDerivations);
if (j != i->value->attrs->end() && state.forceBool(*j->value, *j->pos))
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
@@ -362,7 +362,7 @@ static void getDerivations(EvalState & state, Value & vIn,
}
}
- else if (v.normalType() == nList) {
+ else if (v.type() == nList) {
for (unsigned int n = 0; n < v.listSize(); ++n) {
string pathPrefix2 = addToPath(pathPrefix, (format("%1%") % n).str());
if (getDerivation(state, *v.listElems()[n], pathPrefix2, drvs, done, ignoreAssertionFailures))
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index f6ca612f4..4106f1ec8 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -356,7 +356,7 @@ static void prim_typeOf(EvalState & state, const Pos & pos, Value * * args, Valu
{
state.forceValue(*args[0], pos);
string t;
- switch (args[0]->normalType()) {
+ switch (args[0]->type()) {
case nInt: t = "int"; break;
case nBool: t = "bool"; break;
case nString: t = "string"; break;
@@ -389,7 +389,7 @@ static RegisterPrimOp primop_typeOf({
static void prim_isNull(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nNull);
+ mkBool(v, args[0]->type() == nNull);
}
static RegisterPrimOp primop_isNull({
@@ -409,7 +409,7 @@ static RegisterPrimOp primop_isNull({
static void prim_isFunction(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nFunction);
+ mkBool(v, args[0]->type() == nFunction);
}
static RegisterPrimOp primop_isFunction({
@@ -425,7 +425,7 @@ static RegisterPrimOp primop_isFunction({
static void prim_isInt(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nInt);
+ mkBool(v, args[0]->type() == nInt);
}
static RegisterPrimOp primop_isInt({
@@ -441,7 +441,7 @@ static RegisterPrimOp primop_isInt({
static void prim_isFloat(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nFloat);
+ mkBool(v, args[0]->type() == nFloat);
}
static RegisterPrimOp primop_isFloat({
@@ -457,7 +457,7 @@ static RegisterPrimOp primop_isFloat({
static void prim_isString(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nString);
+ mkBool(v, args[0]->type() == nString);
}
static RegisterPrimOp primop_isString({
@@ -473,7 +473,7 @@ static RegisterPrimOp primop_isString({
static void prim_isBool(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nBool);
+ mkBool(v, args[0]->type() == nBool);
}
static RegisterPrimOp primop_isBool({
@@ -489,7 +489,7 @@ static RegisterPrimOp primop_isBool({
static void prim_isPath(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nPath);
+ mkBool(v, args[0]->type() == nPath);
}
static RegisterPrimOp primop_isPath({
@@ -505,13 +505,13 @@ struct CompareValues
{
bool operator () (const Value * v1, const Value * v2) const
{
- if (v1->normalType() == nFloat && v2->normalType() == nInt)
+ if (v1->type() == nFloat && v2->type() == nInt)
return v1->fpoint < v2->integer;
- if (v1->normalType() == nInt && v2->normalType() == nFloat)
+ if (v1->type() == nInt && v2->type() == nFloat)
return v1->integer < v2->fpoint;
- if (v1->normalType() != v2->normalType())
+ if (v1->type() != v2->type())
throw EvalError("cannot compare %1% with %2%", showType(*v1), showType(*v2));
- switch (v1->normalType()) {
+ switch (v1->type()) {
case nInt:
return v1->integer < v2->integer;
case nFloat:
@@ -762,7 +762,7 @@ static RegisterPrimOp primop_deepSeq({
static void prim_trace(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- if (args[0]->normalType() == nString)
+ if (args[0]->type() == nString)
printError("trace: %1%", args[0]->string.s);
else
printError("trace: %1%", *args[0]);
@@ -887,7 +887,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (ignoreNulls) {
state.forceValue(*i->value, pos);
- if (i->value->normalType() == nNull) continue;
+ if (i->value->type() == nNull) continue;
}
if (i->name == state.sContentAddressed) {
@@ -1293,7 +1293,7 @@ static void prim_dirOf(EvalState & state, const Pos & pos, Value * * args, Value
{
PathSet context;
Path dir = dirOf(state.coerceToString(pos, *args[0], context, false, false));
- if (args[0]->normalType() == nPath) mkPath(v, dir.c_str()); else mkString(v, dir, context);
+ if (args[0]->type() == nPath) mkPath(v, dir.c_str()); else mkString(v, dir, context);
}
static RegisterPrimOp primop_dirOf({
@@ -1793,7 +1793,7 @@ static void prim_filterSource(EvalState & state, const Pos & pos, Value * * args
});
state.forceValue(*args[0], pos);
- if (args[0]->normalType() != nFunction)
+ if (args[0]->type() != nFunction)
throw TypeError({
.hint = hintfmt(
"first argument in call to 'filterSource' is not a function but %1%",
@@ -2059,7 +2059,7 @@ static RegisterPrimOp primop_hasAttr({
static void prim_isAttrs(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nAttrs);
+ mkBool(v, args[0]->type() == nAttrs);
}
static RegisterPrimOp primop_isAttrs({
@@ -2322,7 +2322,7 @@ static RegisterPrimOp primop_mapAttrs({
static void prim_isList(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
state.forceValue(*args[0], pos);
- mkBool(v, args[0]->normalType() == nList);
+ mkBool(v, args[0]->type() == nList);
}
static RegisterPrimOp primop_isList({
@@ -2816,7 +2816,7 @@ static void prim_add(EvalState & state, const Pos & pos, Value * * args, Value &
{
state.forceValue(*args[0], pos);
state.forceValue(*args[1], pos);
- if (args[0]->normalType() == nFloat || args[1]->normalType() == nFloat)
+ if (args[0]->type() == nFloat || args[1]->type() == nFloat)
mkFloat(v, state.forceFloat(*args[0], pos) + state.forceFloat(*args[1], pos));
else
mkInt(v, state.forceInt(*args[0], pos) + state.forceInt(*args[1], pos));
@@ -2835,7 +2835,7 @@ static void prim_sub(EvalState & state, const Pos & pos, Value * * args, Value &
{
state.forceValue(*args[0], pos);
state.forceValue(*args[1], pos);
- if (args[0]->normalType() == nFloat || args[1]->normalType() == nFloat)
+ if (args[0]->type() == nFloat || args[1]->type() == nFloat)
mkFloat(v, state.forceFloat(*args[0], pos) - state.forceFloat(*args[1], pos));
else
mkInt(v, state.forceInt(*args[0], pos) - state.forceInt(*args[1], pos));
@@ -2854,7 +2854,7 @@ static void prim_mul(EvalState & state, const Pos & pos, Value * * args, Value &
{
state.forceValue(*args[0], pos);
state.forceValue(*args[1], pos);
- if (args[0]->normalType() == nFloat || args[1]->normalType() == nFloat)
+ if (args[0]->type() == nFloat || args[1]->type() == nFloat)
mkFloat(v, state.forceFloat(*args[0], pos) * state.forceFloat(*args[1], pos));
else
mkInt(v, state.forceInt(*args[0], pos) * state.forceInt(*args[1], pos));
@@ -2881,7 +2881,7 @@ static void prim_div(EvalState & state, const Pos & pos, Value * * args, Value &
.errPos = pos
});
- if (args[0]->normalType() == nFloat || args[1]->normalType() == nFloat) {
+ if (args[0]->type() == nFloat || args[1]->type() == nFloat) {
mkFloat(v, state.forceFloat(*args[0], pos) / state.forceFloat(*args[1], pos));
} else {
NixInt i1 = state.forceInt(*args[0], pos);
diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc
index 2461ebc99..845a1ed1b 100644
--- a/src/libexpr/primops/fetchMercurial.cc
+++ b/src/libexpr/primops/fetchMercurial.cc
@@ -17,7 +17,7 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
state.forceValue(*args[0]);
- if (args[0]->normalType() == nAttrs) {
+ if (args[0]->type() == nAttrs) {
state.forceAttrs(*args[0], pos);
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc
index 6d93e1dc2..6e7ddde8e 100644
--- a/src/libexpr/primops/fetchTree.cc
+++ b/src/libexpr/primops/fetchTree.cc
@@ -85,25 +85,25 @@ static void fetchTree(
state.forceValue(*args[0]);
- if (args[0]->normalType() == nAttrs) {
+ if (args[0]->type() == nAttrs) {
state.forceAttrs(*args[0], pos);
fetchers::Attrs attrs;
for (auto & attr : *args[0]->attrs) {
state.forceValue(*attr.value);
- if (attr.value->normalType() == nPath || attr.value->normalType() == nString)
+ if (attr.value->type() == nPath || attr.value->type() == nString)
addURI(
state,
attrs,
attr.name,
state.coerceToString(*attr.pos, *attr.value, context, false, false)
);
- else if (attr.value->normalType() == nString)
+ else if (attr.value->type() == nString)
addURI(state, attrs, attr.name, attr.value->string.s);
- else if (attr.value->normalType() == nBool)
+ else if (attr.value->type() == nBool)
attrs.emplace(attr.name, Explicit<bool>{attr.value->boolean});
- else if (attr.value->normalType() == nInt)
+ else if (attr.value->type() == nInt)
attrs.emplace(attr.name, attr.value->integer);
else
throw TypeError("fetchTree argument '%s' is %s while a string, Boolean or integer is expected",
@@ -163,7 +163,7 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
state.forceValue(*args[0]);
- if (args[0]->normalType() == nAttrs) {
+ if (args[0]->type() == nAttrs) {
state.forceAttrs(*args[0], pos);
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index b5f4c8654..bfea24d40 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -16,7 +16,7 @@ void printValueAsJSON(EvalState & state, bool strict,
if (strict) state.forceValue(v);
- switch (v.normalType()) {
+ switch (v.type()) {
case nInt:
out.write(v.integer);
diff --git a/src/libexpr/value-to-xml.cc b/src/libexpr/value-to-xml.cc
index 26be07cff..7464455d8 100644
--- a/src/libexpr/value-to-xml.cc
+++ b/src/libexpr/value-to-xml.cc
@@ -58,7 +58,7 @@ static void printValueAsXML(EvalState & state, bool strict, bool location,
if (strict) state.forceValue(v);
- switch (v.normalType()) {
+ switch (v.type()) {
case nInt:
doc.writeEmptyElement("int", singletonAttrs("value", (format("%1%") % v.integer).str()));
@@ -92,14 +92,14 @@ static void printValueAsXML(EvalState & state, bool strict, bool location,
a = v.attrs->find(state.sDrvPath);
if (a != v.attrs->end()) {
if (strict) state.forceValue(*a->value);
- if (a->value->normalType() == nString)
+ if (a->value->type() == nString)
xmlAttrs["drvPath"] = drvPath = a->value->string.s;
}
a = v.attrs->find(state.sOutPath);
if (a != v.attrs->end()) {
if (strict) state.forceValue(*a->value);
- if (a->value->normalType() == nString)
+ if (a->value->type() == nString)
xmlAttrs["outPath"] = a->value->string.s;
}
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 8b312bf03..61ea1d64b 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -136,12 +136,12 @@ public:
// These should be removed eventually, by putting the functionality that's
// needed by callers into methods of this type
- // normalType() == nThunk
+ // type() == nThunk
inline bool isThunk() const { return internalType == tThunk; };
inline bool isApp() const { return internalType == tApp; };
inline bool isBlackhole() const { return internalType == tBlackhole; };
- // normalType() == nFunction
+ // type() == nFunction
inline bool isLambda() const { return internalType == tLambda; };
inline bool isPrimOp() const { return internalType == tPrimOp; };
inline bool isPrimOpApp() const { return internalType == tPrimOpApp; };
@@ -204,7 +204,7 @@ public:
// Returns the normal type of a Value. This only returns nThunk if the
// Value hasn't been forceValue'd
- inline ValueType normalType() const
+ inline ValueType type() const
{
switch (internalType) {
case tInt: return nInt;
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 404fd5111..6c2e075ed 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -1138,38 +1138,38 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
i.queryName(), j)
});
else {
- if (v->normalType() == nString) {
+ if (v->type() == nString) {
attrs2["type"] = "string";
attrs2["value"] = v->string.s;
xml.writeEmptyElement("meta", attrs2);
- } else if (v->normalType() == nInt) {
+ } else if (v->type() == nInt) {
attrs2["type"] = "int";
attrs2["value"] = (format("%1%") % v->integer).str();
xml.writeEmptyElement("meta", attrs2);
- } else if (v->normalType() == nFloat) {
+ } else if (v->type() == nFloat) {
attrs2["type"] = "float";
attrs2["value"] = (format("%1%") % v->fpoint).str();
xml.writeEmptyElement("meta", attrs2);
- } else if (v->normalType() == nBool) {
+ } else if (v->type() == nBool) {
attrs2["type"] = "bool";
attrs2["value"] = v->boolean ? "true" : "false";
xml.writeEmptyElement("meta", attrs2);
- } else if (v->normalType() == nList) {
+ } else if (v->type() == nList) {
attrs2["type"] = "strings";
XMLOpenElement m(xml, "meta", attrs2);
for (unsigned int j = 0; j < v->listSize(); ++j) {
- if (v->listElems()[j]->normalType() != nString) continue;
+ if (v->listElems()[j]->type() != nString) continue;
XMLAttrs attrs3;
attrs3["value"] = v->listElems()[j]->string.s;
xml.writeEmptyElement("string", attrs3);
}
- } else if (v->normalType() == nAttrs) {
+ } else if (v->type() == nAttrs) {
attrs2["type"] = "strings";
XMLOpenElement m(xml, "meta", attrs2);
Bindings & attrs = *v->attrs;
for (auto &i : attrs) {
Attr & a(*attrs.find(i.name));
- if(a.value->normalType() != nString) continue;
+ if(a.value->type() != nString) continue;
XMLAttrs attrs3;
attrs3["type"] = i.name;
attrs3["value"] = a.value->string.s;
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index bba3b1bc6..ea82e5300 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -97,10 +97,10 @@ struct CmdEval : MixJSON, InstallableCommand
recurse = [&](Value & v, const Pos & pos, const Path & path)
{
state->forceValue(v);
- if (v.normalType() == nString)
+ if (v.type() == nString)
// FIXME: disallow strings with contexts?
writeFile(path, v.string.s);
- else if (v.normalType() == nAttrs) {
+ else if (v.type() == nAttrs) {
if (mkdir(path.c_str(), 0777) == -1)
throw SysError("creating directory '%s'", path);
for (auto & attr : *v.attrs)
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index e4da0348c..066430c5d 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -279,7 +279,7 @@ struct CmdFlakeCheck : FlakeCommand
if (v.isLambda()) {
if (!v.lambda.fun->matchAttrs || !v.lambda.fun->formals->ellipsis)
throw Error("module must match an open attribute set ('{ config, ... }')");
- } else if (v.normalType() == nAttrs) {
+ } else if (v.type() == nAttrs) {
for (auto & attr : *v.attrs)
try {
state->forceValue(*attr.value, *attr.pos);
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 047e2dc59..673155078 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -446,7 +446,7 @@ bool NixRepl::processLine(string line)
Pos pos;
- if (v.normalType() == nPath || v.normalType() == nString) {
+ if (v.type() == nPath || v.type() == nString) {
PathSet context;
auto filename = state->coerceToString(noPos, v, context);
pos.file = state->symbols.create(filename);
@@ -669,7 +669,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
state->forceValue(v);
- switch (v.normalType()) {
+ switch (v.type()) {
case nInt:
str << ANSI_CYAN << v.integer << ANSI_NORMAL;