forked from lix-project/lix
libexpr/primops: review
This commit is contained in:
parent
ad7b47dc85
commit
864ef0e93d
|
@ -547,13 +547,13 @@ typedef list<Value *> ValueList;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static Bindings::iterator extractAttrNameFromPrimopCall(
|
static Bindings::iterator getAttr(
|
||||||
EvalState &state,
|
EvalState & state,
|
||||||
string funcName,
|
string funcName,
|
||||||
string attrName,
|
string attrName,
|
||||||
Bindings *attrSet,
|
Bindings * attrSet,
|
||||||
const Pos &pos
|
const Pos & pos)
|
||||||
) {
|
{
|
||||||
Bindings::iterator value = attrSet->find(state.symbols.create(attrName));
|
Bindings::iterator value = attrSet->find(state.symbols.create(attrName));
|
||||||
if (value == attrSet->end()) {
|
if (value == attrSet->end()) {
|
||||||
hintformat errorMsg = hintfmt(
|
hintformat errorMsg = hintfmt(
|
||||||
|
@ -589,7 +589,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
|
||||||
state.forceAttrs(*args[0], pos);
|
state.forceAttrs(*args[0], pos);
|
||||||
|
|
||||||
/* Get the start set. */
|
/* Get the start set. */
|
||||||
Bindings::iterator startSet = extractAttrNameFromPrimopCall(
|
Bindings::iterator startSet = getAttr(
|
||||||
state,
|
state,
|
||||||
"genericClosure",
|
"genericClosure",
|
||||||
"startSet",
|
"startSet",
|
||||||
|
@ -604,7 +604,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
|
||||||
workSet.push_back(startSet->value->listElems()[n]);
|
workSet.push_back(startSet->value->listElems()[n]);
|
||||||
|
|
||||||
/* Get the operator. */
|
/* Get the operator. */
|
||||||
Bindings::iterator op = extractAttrNameFromPrimopCall(
|
Bindings::iterator op = getAttr(
|
||||||
state,
|
state,
|
||||||
"genericClosure",
|
"genericClosure",
|
||||||
"operator",
|
"operator",
|
||||||
|
@ -855,7 +855,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
||||||
state.forceAttrs(*args[0], pos);
|
state.forceAttrs(*args[0], pos);
|
||||||
|
|
||||||
/* Figure out the name first (for stack backtraces). */
|
/* Figure out the name first (for stack backtraces). */
|
||||||
Bindings::iterator attr = extractAttrNameFromPrimopCall(
|
Bindings::iterator attr = getAttr(
|
||||||
state,
|
state,
|
||||||
"derivationStrict",
|
"derivationStrict",
|
||||||
state.sName,
|
state.sName,
|
||||||
|
@ -1410,7 +1410,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
if (i != v2.attrs->end())
|
if (i != v2.attrs->end())
|
||||||
prefix = state.forceStringNoCtx(*i->value, pos);
|
prefix = state.forceStringNoCtx(*i->value, pos);
|
||||||
|
|
||||||
i = extractAttrNameFromPrimopCall(
|
i = getAttr(
|
||||||
state,
|
state,
|
||||||
"findFile",
|
"findFile",
|
||||||
"path",
|
"path",
|
||||||
|
@ -2058,7 +2058,7 @@ void prim_getAttr(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||||
string attr = state.forceStringNoCtx(*args[0], pos);
|
string attr = state.forceStringNoCtx(*args[0], pos);
|
||||||
state.forceAttrs(*args[1], pos);
|
state.forceAttrs(*args[1], pos);
|
||||||
// !!! Should we create a symbol here or just do a lookup?
|
// !!! Should we create a symbol here or just do a lookup?
|
||||||
Bindings::iterator i = extractAttrNameFromPrimopCall(
|
Bindings::iterator i = getAttr(
|
||||||
state,
|
state,
|
||||||
"getAttr",
|
"getAttr",
|
||||||
attr,
|
attr,
|
||||||
|
@ -2191,7 +2191,7 @@ static void prim_listToAttrs(EvalState & state, const Pos & pos, Value * * args,
|
||||||
Value & v2(*args[0]->listElems()[i]);
|
Value & v2(*args[0]->listElems()[i]);
|
||||||
state.forceAttrs(v2, pos);
|
state.forceAttrs(v2, pos);
|
||||||
|
|
||||||
Bindings::iterator j = extractAttrNameFromPrimopCall(
|
Bindings::iterator j = getAttr(
|
||||||
state,
|
state,
|
||||||
"listToAttrs",
|
"listToAttrs",
|
||||||
state.sName,
|
state.sName,
|
||||||
|
@ -2203,7 +2203,7 @@ static void prim_listToAttrs(EvalState & state, const Pos & pos, Value * * args,
|
||||||
|
|
||||||
Symbol sym = state.symbols.create(name);
|
Symbol sym = state.symbols.create(name);
|
||||||
if (seen.insert(sym).second) {
|
if (seen.insert(sym).second) {
|
||||||
Bindings::iterator j2 = extractAttrNameFromPrimopCall(
|
Bindings::iterator j2 = getAttr(
|
||||||
state,
|
state,
|
||||||
"listToAttrs",
|
"listToAttrs",
|
||||||
state.sValue,
|
state.sValue,
|
||||||
|
|
Loading…
Reference in a new issue