libexpr: use std::function rather than C function pointers for primops
In preparation for the C bindings, which use this.
Change-Id: Ic1c58998951e69e66a794976585a381754dfbbeb
This commit is contained in:
parent
7acdcf5511
commit
883d2ad4d2
|
@ -36,7 +36,7 @@ enum RepairFlag : bool;
|
|||
/**
|
||||
* Function that implements a primop.
|
||||
*/
|
||||
typedef void (* PrimOpFun) (EvalState & state, const PosIdx pos, Value * * args, Value & v);
|
||||
typedef std::function<void (EvalState &, const PosIdx, Value **, Value &)> PrimOpFun;
|
||||
|
||||
/**
|
||||
* Info about a primitive operation, and its implementation
|
||||
|
|
|
@ -3279,8 +3279,11 @@ static void prim_sort(EvalState & state, const PosIdx pos, Value * * args, Value
|
|||
callFunction. */
|
||||
/* TODO: (layus) this is absurd. An optimisation like this
|
||||
should be outside the lambda creation */
|
||||
if (args[0]->isPrimOp() && args[0]->primOp->fun == prim_lessThan)
|
||||
return CompareValues(state, noPos, "while evaluating the ordering function passed to builtins.sort")(a, b);
|
||||
if (args[0]->isPrimOp()) {
|
||||
auto target = args[0]->primOp->fun.target<decltype(&prim_lessThan)>();
|
||||
if (target && *target == prim_lessThan)
|
||||
return CompareValues(state, noPos, "while evaluating the ordering function passed to builtins.sort")(a, b);
|
||||
}
|
||||
|
||||
Value * vs[] = {a, b};
|
||||
Value vBool;
|
||||
|
|
Loading…
Reference in a new issue