mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
Simplify RegisterPrimOp
This commit is contained in:
parent
b7add9736c
commit
4de7a986d4
2 changed files with 13 additions and 14 deletions
|
@ -27,7 +27,12 @@ constexpr size_t conservativeStackReservation = 16;
|
|||
struct RegisterPrimOp
|
||||
{
|
||||
typedef std::vector<PrimOp> PrimOps;
|
||||
static PrimOps * primOps;
|
||||
|
||||
static PrimOps & primOps()
|
||||
{
|
||||
static PrimOps primOps;
|
||||
return primOps;
|
||||
}
|
||||
|
||||
/**
|
||||
* You can register a constant by passing an arity of 0. fun
|
||||
|
|
|
@ -4713,13 +4713,9 @@ static RegisterPrimOp primop_splitVersion({
|
|||
*************************************************************/
|
||||
|
||||
|
||||
RegisterPrimOp::PrimOps * RegisterPrimOp::primOps;
|
||||
|
||||
|
||||
RegisterPrimOp::RegisterPrimOp(PrimOp && primOp)
|
||||
{
|
||||
if (!primOps) primOps = new PrimOps;
|
||||
primOps->push_back(std::move(primOp));
|
||||
primOps().push_back(std::move(primOp));
|
||||
}
|
||||
|
||||
|
||||
|
@ -4973,14 +4969,12 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings)
|
|||
)",
|
||||
});
|
||||
|
||||
if (RegisterPrimOp::primOps)
|
||||
for (auto & primOp : *RegisterPrimOp::primOps)
|
||||
if (experimentalFeatureSettings.isEnabled(primOp.experimentalFeature))
|
||||
{
|
||||
auto primOpAdjusted = primOp;
|
||||
primOpAdjusted.arity = std::max(primOp.args.size(), primOp.arity);
|
||||
addPrimOp(std::move(primOpAdjusted));
|
||||
}
|
||||
for (auto & primOp : RegisterPrimOp::primOps())
|
||||
if (experimentalFeatureSettings.isEnabled(primOp.experimentalFeature)) {
|
||||
auto primOpAdjusted = primOp;
|
||||
primOpAdjusted.arity = std::max(primOp.args.size(), primOp.arity);
|
||||
addPrimOp(std::move(primOpAdjusted));
|
||||
}
|
||||
|
||||
for (auto & primOp : evalSettings.extraPrimOps) {
|
||||
auto primOpAdjusted = primOp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue