forked from lix-project/lix
Use callFunction() with an array for some calls with arity > 1
This commit is contained in:
parent
bcf4780006
commit
cbfbf71e08
|
@ -1883,9 +1883,6 @@ static void addPath(
|
||||||
Value arg1;
|
Value arg1;
|
||||||
mkString(arg1, path);
|
mkString(arg1, path);
|
||||||
|
|
||||||
Value fun2;
|
|
||||||
state.callFunction(*filterFun, arg1, fun2, noPos);
|
|
||||||
|
|
||||||
Value arg2;
|
Value arg2;
|
||||||
mkString(arg2,
|
mkString(arg2,
|
||||||
S_ISREG(st.st_mode) ? "regular" :
|
S_ISREG(st.st_mode) ? "regular" :
|
||||||
|
@ -1893,8 +1890,9 @@ static void addPath(
|
||||||
S_ISLNK(st.st_mode) ? "symlink" :
|
S_ISLNK(st.st_mode) ? "symlink" :
|
||||||
"unknown" /* not supported, will fail! */);
|
"unknown" /* not supported, will fail! */);
|
||||||
|
|
||||||
|
Value * args []{&arg1, &arg2};
|
||||||
Value res;
|
Value res;
|
||||||
state.callFunction(fun2, arg2, res, noPos);
|
state.callFunction(*filterFun, 2, args, res, pos);
|
||||||
|
|
||||||
return state.forceBool(res, pos);
|
return state.forceBool(res, pos);
|
||||||
}) : defaultPathFilter;
|
}) : defaultPathFilter;
|
||||||
|
@ -2695,10 +2693,9 @@ static void prim_foldlStrict(EvalState & state, const Pos & pos, Value * * args,
|
||||||
Value * vCur = args[1];
|
Value * vCur = args[1];
|
||||||
|
|
||||||
for (unsigned int n = 0; n < args[2]->listSize(); ++n) {
|
for (unsigned int n = 0; n < args[2]->listSize(); ++n) {
|
||||||
Value vTmp;
|
Value * vs []{vCur, args[2]->listElems()[n]};
|
||||||
state.callFunction(*args[0], *vCur, vTmp, pos);
|
|
||||||
vCur = n == args[2]->listSize() - 1 ? &v : state.allocValue();
|
vCur = n == args[2]->listSize() - 1 ? &v : state.allocValue();
|
||||||
state.callFunction(vTmp, *args[2]->listElems()[n], *vCur, pos);
|
state.callFunction(*args[0], 2, vs, *vCur, pos);
|
||||||
}
|
}
|
||||||
state.forceValue(v, pos);
|
state.forceValue(v, pos);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2819,17 +2816,16 @@ static void prim_sort(EvalState & state, const Pos & pos, Value * * args, Value
|
||||||
v.listElems()[n] = args[1]->listElems()[n];
|
v.listElems()[n] = args[1]->listElems()[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto comparator = [&](Value * a, Value * b) {
|
auto comparator = [&](Value * a, Value * b) {
|
||||||
/* Optimization: if the comparator is lessThan, bypass
|
/* Optimization: if the comparator is lessThan, bypass
|
||||||
callFunction. */
|
callFunction. */
|
||||||
if (args[0]->isPrimOp() && args[0]->primOp->fun == prim_lessThan)
|
if (args[0]->isPrimOp() && args[0]->primOp->fun == prim_lessThan)
|
||||||
return CompareValues()(a, b);
|
return CompareValues()(a, b);
|
||||||
|
|
||||||
Value vTmp1, vTmp2;
|
Value * vs[] = {a, b};
|
||||||
state.callFunction(*args[0], *a, vTmp1, pos);
|
Value vBool;
|
||||||
state.callFunction(vTmp1, *b, vTmp2, pos);
|
state.callFunction(*args[0], 2, vs, vBool, pos);
|
||||||
return state.forceBool(vTmp2, pos);
|
return state.forceBool(vBool, pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* FIXME: std::sort can segfault if the comparator is not a strict
|
/* FIXME: std::sort can segfault if the comparator is not a strict
|
||||||
|
|
Loading…
Reference in a new issue