1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-01 16:41:47 +02:00

Rename "attribute sets" to "sets"

We don't have any other kind of sets so calling them attribute sets is
unnecessarily verbose.
This commit is contained in:
Eelco Dolstra 2013-10-24 16:41:04 +02:00
parent 9e4bb20455
commit 5bc41d78ff
13 changed files with 152 additions and 160 deletions

View file

@ -35,15 +35,14 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath,
v = vNew;
state.forceValue(*v);
/* It should evaluate to either an attribute set or an
expression, according to what is specified in the
attrPath. */
/* It should evaluate to either a set or an expression,
according to what is specified in the attrPath. */
if (apType == apAttr) {
if (v->type != tAttrs)
throw TypeError(
format("the expression selected by the selection path `%1%' should be an attribute set but is %2%")
format("the expression selected by the selection path `%1%' should be a set but is %2%")
% curPath % showType(*v));
Bindings::iterator a = v->attrs->find(state.symbols.create(attr));

View file

@ -45,7 +45,7 @@ inline void EvalState::forceAttrs(Value & v)
{
forceValue(v);
if (v.type != tAttrs)
throwTypeError("value is %1% while an attribute set was expected", showType(v));
throwTypeError("value is %1% while a set was expected", showType(v));
}

View file

@ -116,7 +116,7 @@ string showType(const Value & v)
case tString: return "a string";
case tPath: return "a path";
case tNull: return "null";
case tAttrs: return "an attribute set";
case tAttrs: return "a set";
case tList: return "a list";
case tThunk: return "a thunk";
case tApp: return "a function application";
@ -488,7 +488,7 @@ inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v)
{
e->eval(*this, env, v);
if (v.type != tAttrs)
throwTypeError("value is %1% while an attribute set was expected", showType(v));
throwTypeError("value is %1% while a set was expected", showType(v));
}
@ -898,9 +898,8 @@ void ExprOpUpdate::eval(EvalState & state, Env & env, Value & v)
state.mkAttrs(v, v1.attrs->size() + v2.attrs->size());
/* Merge the attribute sets, preferring values from the second
set. Make sure to keep the resulting vector in sorted
order. */
/* Merge the sets, preferring values from the second set. Make
sure to keep the resulting vector in sorted order. */
Bindings::iterator i = v1.attrs->begin();
Bindings::iterator j = v2.attrs->begin();
@ -1125,8 +1124,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
if (v.type == tAttrs) {
Bindings::iterator i = v.attrs->find(sOutPath);
if (i == v.attrs->end())
throwTypeError("cannot coerce an attribute set (except a derivation) to a string");
if (i == v.attrs->end()) throwTypeError("cannot coerce a set to a string");
return coerceToString(*i->value, context, coerceMore, copyToStore);
}
@ -1172,9 +1170,8 @@ bool EvalState::eqValues(Value & v1, Value & v2)
forceValue(v2);
/* !!! Hack to support some old broken code that relies on pointer
equality tests between attribute sets. (Specifically,
builderDefs calls uniqList on a list of attribute sets.) Will
remove this eventually. */
equality tests between sets. (Specifically, builderDefs calls
uniqList on a list of sets.) Will remove this eventually. */
if (&v1 == &v2) return true;
if (v1.type != v2.type) return false;
@ -1212,8 +1209,8 @@ bool EvalState::eqValues(Value & v1, Value & v2)
return true;
case tAttrs: {
/* If both attribute sets denote a derivation (type =
"derivation"), then compare their outPaths. */
/* If both sets denote a derivation (type = "derivation"),
then compare their outPaths. */
if (isDerivation(v1) && isDerivation(v2)) {
Bindings::iterator i = v1.attrs->find(sOutPath);
Bindings::iterator j = v2.attrs->find(sOutPath);
@ -1263,7 +1260,7 @@ void EvalState::printStats()
printMsg(v, format(" list concatenations: %1%") % nrListConcats);
printMsg(v, format(" values allocated: %1% (%2% bytes)")
% nrValues % (nrValues * sizeof(Value)));
printMsg(v, format(" attribute sets allocated: %1%") % nrAttrsets);
printMsg(v, format(" sets allocated: %1%") % nrAttrsets);
printMsg(v, format(" right-biased unions: %1%") % nrOpUpdates);
printMsg(v, format(" values copied in right-biased unions: %1%") % nrOpUpdateValuesCopied);
printMsg(v, format(" symbols in symbol table: %1%") % symbols.size());

View file

@ -19,8 +19,8 @@ class EvalState;
struct Attr;
/* Attribute sets are represented as a vector of attributes, sorted by
symbol (i.e. pointer to the attribute name in the symbol table). */
/* Sets are represented as a vector of attributes, sorted by symbol
(i.e. pointer to the attribute name in the symbol table). */
#if HAVE_BOEHMGC
typedef std::vector<Attr, gc_allocator<Attr> > BindingsBase;
#else

View file

@ -41,7 +41,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(EvalState & state)
/* For each output... */
for (unsigned int j = 0; j < i->value->list.length; ++j) {
/* Evaluate the corresponding attribute set. */
/* Evaluate the corresponding set. */
string name = state.forceStringNoCtx(*i->value->list.elems[j]);
Bindings::iterator out = attrs->find(state.symbols.create(name));
if (out == attrs->end()) continue; // FIXME: throw error?
@ -119,11 +119,10 @@ void DrvInfo::setMetaInfo(const MetaInfo & meta)
typedef set<Bindings *> Done;
/* Evaluate value `v'. If it evaluates to an attribute set of type
`derivation', then put information about it in `drvs' (unless it's
already in `doneExprs'). The result boolean indicates whether it
makes sense for the caller to recursively search for derivations in
`v'. */
/* Evaluate value `v'. If it evaluates to a set of type `derivation',
then put information about it in `drvs' (unless it's already in
`doneExprs'). The result boolean indicates whether it makes sense
for the caller to recursively search for derivations in `v'. */
static bool getDerivation(EvalState & state, Value & v,
const string & attrPath, DrvInfos & drvs, Done & done,
bool ignoreAssertionFailures)
@ -132,8 +131,8 @@ static bool getDerivation(EvalState & state, Value & v,
state.forceValue(v);
if (!state.isDerivation(v)) return true;
/* Remove spurious duplicates (e.g., an attribute set like
`rec { x = derivation {...}; y = x;}'. */
/* Remove spurious duplicates (e.g., a set like `rec { x =
derivation {...}; y = x;}'. */
if (done.find(v.attrs) != done.end()) return false;
done.insert(v.attrs);
@ -218,10 +217,9 @@ static void getDerivations(EvalState & state, Value & vIn,
if (combineChannels)
getDerivations(state, v2, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
else if (getDerivation(state, v2, pathPrefix2, drvs, done, ignoreAssertionFailures)) {
/* If the value of this attribute is itself an
attribute set, should we recurse into it? => Only
if it has a `recurseForDerivations = true'
attribute. */
/* If the value of this attribute is itself a set,
should we recurse into it? => Only if it has a
`recurseForDerivations = true' attribute. */
if (v2.type == tAttrs) {
Bindings::iterator j = v2.attrs->find(state.symbols.create("recurseForDerivations"));
if (j != v2.attrs->end() && state.forceBool(*j->value))

View file

@ -123,8 +123,8 @@ struct ExprVar : Expr
levels up from the current environment and getting the
`displ'th value in that environment. In the latter case, the
value is obtained by getting the attribute named `name' from
the attribute set stored in the environment that is `level'
levels up from the current one.*/
the set stored in the environment that is `level' levels up
from the current one.*/
unsigned int level;
unsigned int displ;

View file

@ -103,7 +103,7 @@ static void prim_typeOf(EvalState & state, Value * * args, Value & v)
case tString: t = "string"; break;
case tPath: t = "path"; break;
case tNull: t = "null"; break;
case tAttrs: t = "attrs"; break;
case tAttrs: t = "set"; break;
case tList: t = "list"; break;
case tLambda:
case tPrimOp:
@ -729,12 +729,12 @@ static void prim_filterSource(EvalState & state, Value * * args, Value & v)
/*************************************************************
* Attribute sets
* Sets
*************************************************************/
/* Return the names of the attributes in an attribute set as a sorted
list of strings. */
/* Return the names of the attributes in a set as a sorted list of
strings. */
static void prim_attrNames(EvalState & state, Value * * args, Value & v)
{
state.forceAttrs(*args[0]);
@ -776,7 +776,7 @@ static void prim_hasAttr(EvalState & state, Value * * args, Value & v)
}
/* Determine whether the argument is an attribute set. */
/* Determine whether the argument is a set. */
static void prim_isAttrs(EvalState & state, Value * * args, Value & v)
{
state.forceValue(*args[0]);
@ -807,10 +807,10 @@ static void prim_removeAttrs(EvalState & state, Value * * args, Value & v)
}
/* Builds an attribute set from a list specifying (name, value)
pairs. To be precise, a list [{name = "name1"; value = value1;}
... {name = "nameN"; value = valueN;}] is transformed to {name1 =
value1; ... nameN = valueN;}. */
/* Builds a set from a list specifying (name, value) pairs. To be
precise, a list [{name = "name1"; value = value1;} ... {name =
"nameN"; value = valueN;}] is transformed to {name1 = value1;
... nameN = valueN;}. */
static void prim_listToAttrs(EvalState & state, Value * * args, Value & v)
{
state.forceList(*args[0]);
@ -844,9 +844,9 @@ static void prim_listToAttrs(EvalState & state, Value * * args, Value & v)
}
/* Return the right-biased intersection of two attribute sets as1 and
as2, i.e. a set that contains every attribute from as2 that is also
a member of as1. */
/* Return the right-biased intersection of two sets as1 and as2,
i.e. a set that contains every attribute from as2 that is also a
member of as1. */
static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v)
{
state.forceAttrs(*args[0]);
@ -1240,7 +1240,7 @@ void EvalState::createBaseEnv()
addPrimOp("__toFile", 2, prim_toFile);
addPrimOp("__filterSource", 2, prim_filterSource);
// Attribute sets
// Sets
addPrimOp("__attrNames", 1, prim_attrNames);
addPrimOp("__getAttr", 2, prim_getAttr);
addPrimOp("__hasAttr", 2, prim_hasAttr);
@ -1290,8 +1290,8 @@ void EvalState::createBaseEnv()
evalFile(path, v);
addConstant("derivation", v);
/* Now that we've added all primops, sort the `builtins' attribute
set, because attribute lookups expect it to be sorted. */
/* Now that we've added all primops, sort the `builtins' set,
because attribute lookups expect it to be sorted. */
baseEnv.values[0]->attrs->sort();
}

View file

@ -13,11 +13,10 @@
namespace nix {
/* Symbol table used by the parser and evaluator to represent and look
up identifiers and attribute sets efficiently.
SymbolTable::create() converts a string into a symbol. Symbols
have the property that they can be compared efficiently (using a
pointer equality test), because the symbol table stores only one
copy of each string. */
up identifiers and attributes efficiently. SymbolTable::create()
converts a string into a symbol. Symbols have the property that
they can be compared efficiently (using a pointer equality test),
because the symbol table stores only one copy of each string. */
class Symbol
{

View file

@ -159,11 +159,11 @@ static void loadSourceExpr(EvalState & state, const Path & path, Value & v)
}
/* The path is a directory. Put the Nix expressions in the
directory in an attribute set, with the file name of each
expression as the attribute name. Recurse into subdirectories
(but keep the attribute set flat, not nested, to make it easier
for a user to have a ~/.nix-defexpr directory that includes
some system-wide directory). */
directory in a set, with the file name of each expression as
the attribute name. Recurse into subdirectories (but keep the
set flat, not nested, to make it easier for a user to have a
~/.nix-defexpr directory that includes some system-wide
directory). */
if (S_ISDIR(st.st_mode)) {
state.mkAttrs(v, 16);
state.mkList(*state.allocAttr(v, state.symbols.create("_combineChannels")), 0);