mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
primops: change to std::function, allowing the passing of user data
This commit is contained in:
parent
9e423dee11
commit
48aa57549d
2 changed files with 7 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -72,7 +73,7 @@ struct PrimOp
|
|||
/**
|
||||
* Implementation of the primop.
|
||||
*/
|
||||
PrimOpFun fun;
|
||||
std::function<std::remove_pointer<PrimOpFun>::type> fun;
|
||||
|
||||
/**
|
||||
* Optional experimental for this to be gated on.
|
||||
|
|
|
@ -3402,8 +3402,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 ptr = args[0]->primOp->fun.target<decltype(&prim_lessThan)>();
|
||||
if (ptr && *ptr == 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