diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index c50fa8e12..c90bccc97 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -18,6 +18,114 @@ namespace nix { +/** + * List of primops to be regisered explicitely + */ + +extern PrimOp primop_abort; +extern PrimOp primop_add; +extern PrimOp primop_addDrvOutputDependencies; +extern PrimOp primop_addErrorContext; +extern PrimOp primop_all; +extern PrimOp primop_any; +extern PrimOp primop_appendContext; +extern PrimOp primop_attrNames; +extern PrimOp primop_attrValues; +extern PrimOp primop_baseNameOf; +extern PrimOp primop_bitAnd; +extern PrimOp primop_bitOr; +extern PrimOp primop_bitXor; +extern PrimOp primop_break; +extern PrimOp primop_catAttrs; +extern PrimOp primop_ceil; +extern PrimOp primop_compareVersions; +extern PrimOp primop_concatLists; +extern PrimOp primop_concatMap; +extern PrimOp primop_concatStringsSep; +extern PrimOp primop_deepSeq; +extern PrimOp primop_derivationStrict; +extern PrimOp primop_dirOf; +extern PrimOp primop_div; +extern PrimOp primop_elem; +extern PrimOp primop_elemAt; +extern PrimOp primop_fetchClosure; +extern PrimOp primop_fetchGit; +extern PrimOp primop_fetchMercurial; +extern PrimOp primop_fetchTarball; +extern PrimOp primop_fetchTree; +extern PrimOp primop_fetchurl; +extern PrimOp primop_filter; +extern PrimOp primop_filterSource; +extern PrimOp primop_findFile; +extern PrimOp primop_floor; +extern PrimOp primop_foldlStrict; +extern PrimOp primop_fromJSON; +extern PrimOp primop_fromTOML; +extern PrimOp primop_functionArgs; +extern PrimOp primop_genericClosure; +extern PrimOp primop_genList; +extern PrimOp primop_getAttr; +extern PrimOp primop_getContext; +extern PrimOp primop_getEnv; +extern PrimOp primop_groupBy; +extern PrimOp primop_hasAttr; +extern PrimOp primop_hasContext; +extern PrimOp primop_hashFile; +extern PrimOp primop_hashString; +extern PrimOp primop_head; +extern PrimOp primop_import; +extern PrimOp primop_intersectAttrs; +extern PrimOp primop_isAttrs; +extern PrimOp primop_isBool; +extern PrimOp primop_isFloat; +extern PrimOp primop_isFunction; +extern PrimOp primop_isInt; +extern PrimOp primop_isList; +extern PrimOp primop_isNull; +extern PrimOp primop_isPath; +extern PrimOp primop_isString; +extern PrimOp primop_length; +extern PrimOp primop_lessThan; +extern PrimOp primop_listToAttrs; +extern PrimOp primop_map; +extern PrimOp primop_mapAttrs; +extern PrimOp primop_match; +extern PrimOp primop_mul; +extern PrimOp primop_outputOf; +extern PrimOp primop_parseDrvName; +extern PrimOp primop_partition; +extern PrimOp primop_path; +extern PrimOp primop_pathExists; +extern PrimOp primop_placeholder; +extern PrimOp primop_readDir; +extern PrimOp primop_readFile; +extern PrimOp primop_readFileType; +extern PrimOp primop_removeAttrs; +extern PrimOp primop_replaceStrings; +extern PrimOp primop_scopedImport; +extern PrimOp primop_seq; +extern PrimOp primop_sort; +extern PrimOp primop_split; +extern PrimOp primop_splitVersion; +extern PrimOp primop_storePath; +extern PrimOp primop_stringLength; +extern PrimOp primop_sub; +extern PrimOp primop_substring; +extern PrimOp primop_tail; +extern PrimOp primop_throw; +extern PrimOp primop_toFile; +extern PrimOp primop_toJSON; +extern PrimOp primop_toPath; +extern PrimOp primop_toString; +extern PrimOp primop_toXML; +extern PrimOp primop_trace; +extern PrimOp primop_tryEval; +extern PrimOp primop_typeOf; +extern PrimOp primop_unsafeDiscardOutputDependency; +extern PrimOp primop_unsafeDiscardStringContext; +extern PrimOp primop_unsafeGetAttrPos; +extern PrimOp primop_zipAttrsWith; + RegisterPrimOp::PrimOps * RegisterPrimOp::primOps; RegisterPrimOp::RegisterPrimOp(PrimOp && primOp) @@ -312,6 +420,124 @@ void EvalState::createBaseEnv() } ); + auto registerPrimOp = [this](PrimOp & p) { + // Only register the primop if the associated experimental feature is enabled + if (experimentalFeatureSettings.isEnabled(p.experimentalFeature)) { + auto adjusted = p; + adjusted.arity = std::max(p.args.size(), p.arity); // Don't trust what is defined + addPrimOp(std::move(adjusted)); + } + }; + + /** + * Register the primops explicitely + */ + + registerPrimOp(primop_abort); + registerPrimOp(primop_add); + registerPrimOp(primop_addDrvOutputDependencies); + registerPrimOp(primop_addErrorContext); + registerPrimOp(primop_all); + registerPrimOp(primop_any); + registerPrimOp(primop_appendContext); + registerPrimOp(primop_attrNames); + registerPrimOp(primop_attrValues); + registerPrimOp(primop_baseNameOf); + registerPrimOp(primop_bitAnd); + registerPrimOp(primop_bitOr); + registerPrimOp(primop_bitXor); + registerPrimOp(primop_break); + registerPrimOp(primop_catAttrs); + registerPrimOp(primop_ceil); + registerPrimOp(primop_compareVersions); + registerPrimOp(primop_concatLists); + registerPrimOp(primop_concatMap); + registerPrimOp(primop_concatStringsSep); + registerPrimOp(primop_deepSeq); + registerPrimOp(primop_derivationStrict); + registerPrimOp(primop_dirOf); + registerPrimOp(primop_div); + registerPrimOp(primop_elem); + registerPrimOp(primop_elemAt); + registerPrimOp(primop_fetchClosure); + registerPrimOp(primop_fetchGit); + registerPrimOp(primop_fetchMercurial); + registerPrimOp(primop_fetchTarball); + registerPrimOp(primop_fetchTree); + registerPrimOp(primop_fetchurl); + registerPrimOp(primop_filter); + registerPrimOp(primop_filterSource); + registerPrimOp(primop_findFile); + registerPrimOp(primop_floor); + registerPrimOp(primop_foldlStrict); + registerPrimOp(primop_fromJSON); + registerPrimOp(primop_fromTOML); + registerPrimOp(primop_functionArgs); + registerPrimOp(primop_genericClosure); + registerPrimOp(primop_genList); + registerPrimOp(primop_getAttr); + registerPrimOp(primop_getContext); + registerPrimOp(primop_getEnv); + registerPrimOp(primop_groupBy); + registerPrimOp(primop_hasAttr); + registerPrimOp(primop_hasContext); + registerPrimOp(primop_hashFile); + registerPrimOp(primop_hashString); + registerPrimOp(primop_head); + registerPrimOp(primop_import); + registerPrimOp(primop_intersectAttrs); + registerPrimOp(primop_isAttrs); + registerPrimOp(primop_isBool); + registerPrimOp(primop_isFloat); + registerPrimOp(primop_isFunction); + registerPrimOp(primop_isInt); + registerPrimOp(primop_isList); + registerPrimOp(primop_isNull); + registerPrimOp(primop_isPath); + registerPrimOp(primop_isString); + registerPrimOp(primop_length); + registerPrimOp(primop_lessThan); + registerPrimOp(primop_listToAttrs); + registerPrimOp(primop_map); + registerPrimOp(primop_mapAttrs); + registerPrimOp(primop_match); + registerPrimOp(primop_mul); + registerPrimOp(primop_outputOf); + registerPrimOp(primop_parseDrvName); + registerPrimOp(primop_partition); + registerPrimOp(primop_path); + registerPrimOp(primop_pathExists); + registerPrimOp(primop_placeholder); + registerPrimOp(primop_readDir); + registerPrimOp(primop_readFile); + registerPrimOp(primop_readFileType); + registerPrimOp(primop_removeAttrs); + registerPrimOp(primop_replaceStrings); + registerPrimOp(primop_scopedImport); + registerPrimOp(primop_seq); + registerPrimOp(primop_sort); + registerPrimOp(primop_split); + registerPrimOp(primop_splitVersion); + registerPrimOp(primop_storePath); + registerPrimOp(primop_stringLength); + registerPrimOp(primop_sub); + registerPrimOp(primop_substring); + registerPrimOp(primop_tail); + registerPrimOp(primop_throw); + registerPrimOp(primop_toFile); + registerPrimOp(primop_toJSON); + registerPrimOp(primop_toPath); + registerPrimOp(primop_toString); + registerPrimOp(primop_toXML); + registerPrimOp(primop_trace); + registerPrimOp(primop_tryEval); + registerPrimOp(primop_typeOf); + registerPrimOp(primop_unsafeDiscardOutputDependency); + registerPrimOp(primop_unsafeDiscardStringContext); + registerPrimOp(primop_unsafeGetAttrPos); + registerPrimOp(primop_zipAttrsWith); + + // Legacy way of registering primops, using c++ arcanes if (RegisterPrimOp::primOps) { for (auto & primOp : *RegisterPrimOp::primOps) { if (experimentalFeatureSettings.isEnabled(primOp.experimentalFeature)) { diff --git a/src/libexpr/primops/arithmetic.cc b/src/libexpr/primops/arithmetic.cc index 4b3857728..327fbb81c 100644 --- a/src/libexpr/primops/arithmetic.cc +++ b/src/libexpr/primops/arithmetic.cc @@ -25,7 +25,7 @@ static void prim_add(EvalState & state, const PosIdx pos, Value ** args, Value & } } -static RegisterPrimOp primop_add({ +PrimOp primop_add({ .name = "__add", .args = {"e1", "e2"}, .doc = R"( @@ -52,7 +52,7 @@ static void prim_bitAnd(EvalState & state, const PosIdx pos, Value ** args, Valu ); } -static RegisterPrimOp primop_bitAnd({ +PrimOp primop_bitAnd({ .name = "__bitAnd", .args = {"e1", "e2"}, .doc = R"( @@ -77,7 +77,7 @@ static void prim_bitOr(EvalState & state, const PosIdx pos, Value ** args, Value ); } -static RegisterPrimOp primop_bitOr({ +PrimOp primop_bitOr({ .name = "__bitOr", .args = {"e1", "e2"}, .doc = R"( @@ -102,7 +102,7 @@ static void prim_bitXor(EvalState & state, const PosIdx pos, Value ** args, Valu ); } -static RegisterPrimOp primop_bitXor({ +PrimOp primop_bitXor({ .name = "__bitXor", .args = {"e1", "e2"}, .doc = R"( @@ -125,7 +125,7 @@ static void prim_ceil(EvalState & state, const PosIdx pos, Value ** args, Value v.mkInt(ceil(value)); } -static RegisterPrimOp primop_ceil({ +PrimOp primop_ceil({ .name = "__ceil", .args = {"double"}, .doc = R"( @@ -172,7 +172,7 @@ static void prim_div(EvalState & state, const PosIdx pos, Value ** args, Value & } } -static RegisterPrimOp primop_div({ +PrimOp primop_div({ .name = "__div", .args = {"e1", "e2"}, .doc = R"( @@ -195,7 +195,7 @@ static void prim_floor(EvalState & state, const PosIdx pos, Value ** args, Value v.mkInt(floor(value)); } -static RegisterPrimOp primop_floor({ +PrimOp primop_floor({ .name = "__floor", .args = {"double"}, .doc = R"( @@ -221,7 +221,7 @@ void prim_lessThan(EvalState & state, const PosIdx pos, Value ** args, Value & v v.mkBool(comp(args[0], args[1])); } -static RegisterPrimOp primop_lessThan({ +PrimOp primop_lessThan({ .name = "__lessThan", .args = {"e1", "e2"}, .doc = R"( @@ -259,7 +259,7 @@ static void prim_mul(EvalState & state, const PosIdx pos, Value ** args, Value & } } -static RegisterPrimOp primop_mul({ +PrimOp primop_mul({ .name = "__mul", .args = {"e1", "e2"}, .doc = R"( @@ -295,7 +295,7 @@ static void prim_sub(EvalState & state, const PosIdx pos, Value ** args, Value & } } -static RegisterPrimOp primop_sub({ +PrimOp primop_sub({ .name = "__sub", .args = {"e1", "e2"}, .doc = R"( diff --git a/src/libexpr/primops/attrset.cc b/src/libexpr/primops/attrset.cc index 6f500f7a6..9bd55da9c 100644 --- a/src/libexpr/primops/attrset.cc +++ b/src/libexpr/primops/attrset.cc @@ -35,7 +35,7 @@ static void prim_attrNames(EvalState & state, const PosIdx pos, Value ** args, V }); } -static RegisterPrimOp primop_attrNames({ +PrimOp primop_attrNames({ .name = "__attrNames", .args = {"set"}, .doc = R"( @@ -72,7 +72,7 @@ static void prim_attrValues(EvalState & state, const PosIdx pos, Value ** args, } } -static RegisterPrimOp primop_attrValues({ +PrimOp primop_attrValues({ .name = "__attrValues", .args = {"set"}, .doc = R"( @@ -116,7 +116,7 @@ static void prim_catAttrs(EvalState & state, const PosIdx pos, Value ** args, Va } } -static RegisterPrimOp primop_catAttrs({ +PrimOp primop_catAttrs({ .name = "__catAttrs", .args = {"attr", "list"}, .doc = R"( @@ -239,7 +239,7 @@ static void prim_genericClosure(EvalState & state, const PosIdx pos, Value ** ar } } -static RegisterPrimOp primop_genericClosure(PrimOp{ +PrimOp primop_genericClosure(PrimOp{ .name = "__genericClosure", .args = {"attrset"}, .arity = 1, @@ -298,7 +298,7 @@ void prim_getAttr(EvalState & state, const PosIdx pos, Value ** args, Value & v) v = *i->value; } -static RegisterPrimOp primop_getAttr({ +PrimOp primop_getAttr({ .name = "__getAttr", .args = {"s", "set"}, .doc = R"( @@ -350,7 +350,7 @@ static void prim_groupBy(EvalState & state, const PosIdx pos, Value ** args, Val v.mkAttrs(attrs2.alreadySorted()); } -static RegisterPrimOp primop_groupBy({ +PrimOp primop_groupBy({ .name = "__groupBy", .args = {"f", "list"}, .doc = R"( @@ -389,7 +389,7 @@ static void prim_hasAttr(EvalState & state, const PosIdx pos, Value ** args, Val v.mkBool(args[1]->attrs->find(state.symbols.create(attr)) != args[1]->attrs->end()); } -static RegisterPrimOp primop_hasAttr({ +PrimOp primop_hasAttr({ .name = "__hasAttr", .args = {"s", "set"}, .doc = R"( @@ -475,7 +475,7 @@ static void prim_intersectAttrs(EvalState & state, const PosIdx pos, Value ** ar v.mkAttrs(attrs.alreadySorted()); } -static RegisterPrimOp primop_intersectAttrs({ +PrimOp primop_intersectAttrs({ .name = "__intersectAttrs", .args = {"e1", "e2"}, .doc = R"( @@ -510,7 +510,7 @@ static void prim_mapAttrs(EvalState & state, const PosIdx pos, Value ** args, Va v.mkAttrs(attrs.alreadySorted()); } -static RegisterPrimOp primop_mapAttrs({ +PrimOp primop_mapAttrs({ .name = "__mapAttrs", .args = {"f", "attrset"}, .doc = R"( @@ -568,7 +568,7 @@ static void prim_removeAttrs(EvalState & state, const PosIdx pos, Value ** args, v.mkAttrs(attrs.alreadySorted()); } -static RegisterPrimOp primop_removeAttrs({ +PrimOp primop_removeAttrs({ .name = "removeAttrs", .args = {"set", "list"}, .doc = R"( @@ -647,7 +647,7 @@ static void prim_zipAttrsWith(EvalState & state, const PosIdx pos, Value ** args } } -static RegisterPrimOp primop_zipAttrsWith({ +PrimOp primop_zipAttrsWith({ .name = "__zipAttrsWith", .args = {"f", "list"}, .doc = R"( diff --git a/src/libexpr/primops/context.cc b/src/libexpr/primops/context.cc index 3483989f1..93ddd064c 100644 --- a/src/libexpr/primops/context.cc +++ b/src/libexpr/primops/context.cc @@ -159,7 +159,7 @@ prim_addDrvOutputDependencies(EvalState & state, const PosIdx pos, Value ** args v.mkString(*s, context2); } -static RegisterPrimOp primop_addDrvOutputDependencies( +PrimOp primop_addDrvOutputDependencies( {.name = "__addDrvOutputDependencies", .args = {"s"}, .doc = R"( @@ -202,7 +202,7 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value ** a } } -static RegisterPrimOp primop_addErrorContext(PrimOp{ +PrimOp primop_addErrorContext(PrimOp{ .name = "__addErrorContext", .arity = 2, .fun = prim_addErrorContext, @@ -310,7 +310,7 @@ static void prim_appendContext(EvalState & state, const PosIdx pos, Value ** arg v.mkString(orig, context); } -static RegisterPrimOp primop_appendContext({ +PrimOp primop_appendContext({ .name = "__appendContext", .arity = 2, .fun = prim_appendContext, @@ -397,7 +397,7 @@ static void prim_getContext(EvalState & state, const PosIdx pos, Value ** args, v.mkAttrs(attrs); } -static RegisterPrimOp primop_getContext({ +PrimOp primop_getContext({ .name = "__getContext", .args = {"s"}, .doc = R"( @@ -435,7 +435,7 @@ static void prim_hasContext(EvalState & state, const PosIdx pos, Value ** args, v.mkBool(!context.empty()); } -static RegisterPrimOp primop_hasContext( +PrimOp primop_hasContext( {.name = "__hasContext", .args = {"s"}, .doc = R"( @@ -487,7 +487,7 @@ prim_unsafeDiscardOutputDependency(EvalState & state, const PosIdx pos, Value ** v.mkString(*s, context2); } -static RegisterPrimOp primop_unsafeDiscardOutputDependency( +PrimOp primop_unsafeDiscardOutputDependency( {.name = "__unsafeDiscardOutputDependency", .args = {"s"}, .doc = R"( @@ -523,7 +523,7 @@ prim_unsafeDiscardStringContext(EvalState & state, const PosIdx pos, Value ** ar v.mkString(*s); } -static RegisterPrimOp primop_unsafeDiscardStringContext({ +PrimOp primop_unsafeDiscardStringContext({ .name = "__unsafeDiscardStringContext", .arity = 1, .fun = prim_unsafeDiscardStringContext, diff --git a/src/libexpr/primops/control.cc b/src/libexpr/primops/control.cc index 71d6ff6ed..a1cd299c1 100644 --- a/src/libexpr/primops/control.cc +++ b/src/libexpr/primops/control.cc @@ -22,7 +22,7 @@ static void prim_abort(EvalState & state, const PosIdx pos, Value ** args, Value .debugThrow(); } -static RegisterPrimOp primop_abort({ +PrimOp primop_abort({ .name = "abort", .args = {"s"}, .doc = R"( @@ -52,7 +52,7 @@ static void prim_break(EvalState & state, const PosIdx pos, Value ** args, Value v = *args[0]; } -static RegisterPrimOp primop_break({ +PrimOp primop_break({ .name = "break", .args = {"v"}, .doc = R"( @@ -78,7 +78,7 @@ static void prim_throw(EvalState & state, const PosIdx pos, Value ** args, Value state.error(s).debugThrow(); } -static RegisterPrimOp primop_throw({ +PrimOp primop_throw({ .name = "throw", .args = {"s"}, .doc = R"( @@ -126,7 +126,7 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value ** args, Val v.mkAttrs(attrs); } -static RegisterPrimOp primop_tryEval({ +PrimOp primop_tryEval({ .name = "__tryEval", .args = {"e"}, .doc = R"( diff --git a/src/libexpr/primops/debug.cc b/src/libexpr/primops/debug.cc index 3964335b5..aa45998b2 100644 --- a/src/libexpr/primops/debug.cc +++ b/src/libexpr/primops/debug.cc @@ -72,7 +72,7 @@ static void prim_deepSeq(EvalState & state, const PosIdx pos, Value ** args, Val v = *args[1]; } -static RegisterPrimOp primop_deepSeq({ +PrimOp primop_deepSeq({ .name = "__deepSeq", .args = {"e1", "e2"}, .doc = R"( @@ -94,7 +94,7 @@ static void prim_seq(EvalState & state, const PosIdx pos, Value ** args, Value & v = *args[1]; } -static RegisterPrimOp primop_seq({ +PrimOp primop_seq({ .name = "__seq", .args = {"e1", "e2"}, .doc = R"( @@ -124,7 +124,7 @@ void prim_trace(EvalState & state, const PosIdx pos, Value ** args, Value & v) v = *args[1]; } -static RegisterPrimOp primop_trace({ +PrimOp primop_trace({ .name = "__trace", .args = {"e1", "e2"}, .doc = R"( @@ -161,7 +161,7 @@ static void prim_unsafeGetAttrPos(EvalState & state, const PosIdx pos, Value ** } } -static RegisterPrimOp primop_unsafeGetAttrPos(PrimOp{ +PrimOp primop_unsafeGetAttrPos(PrimOp{ .name = "__unsafeGetAttrPos", .arity = 2, .fun = prim_unsafeGetAttrPos, diff --git a/src/libexpr/primops/derivation.cc b/src/libexpr/primops/derivation.cc index 83a028856..201df528b 100644 --- a/src/libexpr/primops/derivation.cc +++ b/src/libexpr/primops/derivation.cc @@ -389,7 +389,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * * } } -static RegisterPrimOp primop_derivationStrict(PrimOp { +PrimOp primop_derivationStrict(PrimOp { .name = "derivationStrict", .arity = 1, .fun = prim_derivationStrict, diff --git a/src/libexpr/primops/fetchClosure.cc b/src/libexpr/primops/fetchClosure.cc index 3804db6eb..ee49cda10 100644 --- a/src/libexpr/primops/fetchClosure.cc +++ b/src/libexpr/primops/fetchClosure.cc @@ -207,7 +207,7 @@ static void prim_fetchClosure(EvalState & state, const PosIdx pos, Value * * arg runFetchClosureWithContentAddressedPath(state, pos, *fromStore, *fromPath, v); } -static RegisterPrimOp primop_fetchClosure({ +PrimOp primop_fetchClosure({ .name = "__fetchClosure", .args = {"args"}, .doc = R"( diff --git a/src/libexpr/primops/fetchMercurial.cc b/src/libexpr/primops/fetchMercurial.cc index 261722d1b..1ee81b524 100644 --- a/src/libexpr/primops/fetchMercurial.cc +++ b/src/libexpr/primops/fetchMercurial.cc @@ -83,7 +83,7 @@ static void prim_fetchMercurial(EvalState & state, const PosIdx pos, Value * * a state.allowPath(tree.storePath); } -static RegisterPrimOp r_fetchMercurial({ +PrimOp primop_fetchMercurial({ .name = "fetchMercurial", .arity = 1, .fun = prim_fetchMercurial diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 2e58be45d..2392c2ce5 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -198,7 +198,7 @@ static void prim_fetchTree(EvalState & state, const PosIdx pos, Value * * args, } // FIXME: document -static RegisterPrimOp primop_fetchTree({ +PrimOp primop_fetchTree({ .name = "fetchTree", .arity = 1, .fun = prim_fetchTree @@ -290,7 +290,7 @@ static void prim_fetchurl(EvalState & state, const PosIdx pos, Value * * args, V fetch(state, pos, args, v, "fetchurl", false, ""); } -static RegisterPrimOp primop_fetchurl({ +PrimOp primop_fetchurl({ .name = "__fetchurl", .args = {"url"}, .doc = R"( @@ -306,7 +306,7 @@ static void prim_fetchTarball(EvalState & state, const PosIdx pos, Value * * arg fetch(state, pos, args, v, "fetchTarball", true, "source"); } -static RegisterPrimOp primop_fetchTarball({ +PrimOp primop_fetchTarball({ .name = "fetchTarball", .args = {"args"}, .doc = R"( @@ -356,7 +356,7 @@ static void prim_fetchGit(EvalState & state, const PosIdx pos, Value * * args, V fetchTree(state, pos, args, v, "git", FetchTreeParams { .emptyRevFallback = true, .allowNameArgument = true }); } -static RegisterPrimOp primop_fetchGit({ +PrimOp primop_fetchGit({ .name = "fetchGit", .args = {"args"}, .doc = R"( diff --git a/src/libexpr/primops/fromTOML.cc b/src/libexpr/primops/fromTOML.cc index c51683df7..1d4fa8dfd 100644 --- a/src/libexpr/primops/fromTOML.cc +++ b/src/libexpr/primops/fromTOML.cc @@ -86,7 +86,7 @@ static void prim_fromTOML(EvalState & state, const PosIdx pos, Value * * args, V } } -static RegisterPrimOp primop_fromTOML({ +PrimOp primop_fromTOML({ .name = "fromTOML", .args = {"e"}, .doc = R"( diff --git a/src/libexpr/primops/hash.cc b/src/libexpr/primops/hash.cc index be73fa30a..b62e82a5e 100644 --- a/src/libexpr/primops/hash.cc +++ b/src/libexpr/primops/hash.cc @@ -22,7 +22,7 @@ static void prim_hashFile(EvalState & state, const PosIdx pos, Value ** args, Va v.mkString(hashString(*ht, path.readFile()).to_string(Base16, false)); } -static RegisterPrimOp primop_hashFile({ +PrimOp primop_hashFile({ .name = "__hashFile", .args = {"type", "p"}, .doc = R"( @@ -55,7 +55,7 @@ static void prim_hashString(EvalState & state, const PosIdx pos, Value ** args, v.mkString(hashString(*ht, s).to_string(Base16, false)); } -static RegisterPrimOp primop_hashString({ +PrimOp primop_hashString({ .name = "__hashString", .args = {"type", "s"}, .doc = R"( diff --git a/src/libexpr/primops/import.cc b/src/libexpr/primops/import.cc index fbabc0bc4..f4c95b2ad 100644 --- a/src/libexpr/primops/import.cc +++ b/src/libexpr/primops/import.cc @@ -150,7 +150,7 @@ static void prim_import(EvalState & state, const PosIdx pos, Value ** args, Valu import(state, pos, *args[0], nullptr, v); } -static RegisterPrimOp primop_import({ +PrimOp primop_import({ .name = "import", .args = {"path"}, // TODO turn "normal path values" into link below @@ -261,7 +261,7 @@ static void prim_scopedImport(EvalState & state, const PosIdx pos, Value ** args import(state, pos, *args[1], args[0], v); } -static RegisterPrimOp primop_scopedImport(PrimOp{ +PrimOp primop_scopedImport(PrimOp{ .name = "scopedImport", .arity = 2, .fun = prim_scopedImport, diff --git a/src/libexpr/primops/json.cc b/src/libexpr/primops/json.cc index 2dab1fbe2..172eb47b4 100644 --- a/src/libexpr/primops/json.cc +++ b/src/libexpr/primops/json.cc @@ -21,7 +21,7 @@ static void prim_fromJSON(EvalState & state, const PosIdx pos, Value ** args, Va } } -static RegisterPrimOp primop_fromJSON({ +PrimOp primop_fromJSON({ .name = "__fromJSON", .args = {"e"}, .doc = R"( @@ -48,7 +48,7 @@ static void prim_toJSON(EvalState & state, const PosIdx pos, Value ** args, Valu v.mkString(out.str(), context); } -static RegisterPrimOp primop_toJSON({ +PrimOp primop_toJSON({ .name = "__toJSON", .args = {"e"}, .doc = R"( diff --git a/src/libexpr/primops/list.cc b/src/libexpr/primops/list.cc index 110e2077b..792d88e21 100644 --- a/src/libexpr/primops/list.cc +++ b/src/libexpr/primops/list.cc @@ -45,7 +45,7 @@ static void prim_all(EvalState & state, const PosIdx pos, Value ** args, Value & anyOrAll(false, state, pos, args, v); } -static RegisterPrimOp primop_all({ +PrimOp primop_all({ .name = "__all", .args = {"pred", "list"}, .doc = R"( @@ -64,7 +64,7 @@ static void prim_any(EvalState & state, const PosIdx pos, Value ** args, Value & anyOrAll(true, state, pos, args, v); } -static RegisterPrimOp primop_any({ +PrimOp primop_any({ .name = "__any", .args = {"pred", "list"}, .doc = R"( @@ -92,7 +92,7 @@ static void prim_concatLists(EvalState & state, const PosIdx pos, Value ** args, ); } -static RegisterPrimOp primop_concatLists({ +PrimOp primop_concatLists({ .name = "__concatLists", .args = {"lists"}, .doc = R"( @@ -142,7 +142,7 @@ static void prim_concatMap(EvalState & state, const PosIdx pos, Value ** args, V } } -static RegisterPrimOp primop_concatMap({ +PrimOp primop_concatMap({ .name = "__concatMap", .args = {"f", "list"}, .doc = R"( @@ -175,7 +175,7 @@ static void prim_elem(EvalState & state, const PosIdx pos, Value ** args, Value v.mkBool(res); } -static RegisterPrimOp primop_elem({ +PrimOp primop_elem({ .name = "__elem", .args = {"x", "xs"}, .doc = R"( @@ -202,7 +202,7 @@ static void prim_elemAt(EvalState & state, const PosIdx pos, Value ** args, Valu ); } -static RegisterPrimOp primop_elemAt({ +PrimOp primop_elemAt({ .name = "__elemAt", .args = {"xs", "n"}, .doc = R"( @@ -287,7 +287,7 @@ static void prim_foldlStrict(EvalState & state, const PosIdx pos, Value ** args, } } -static RegisterPrimOp primop_foldlStrict({ +PrimOp primop_foldlStrict({ .name = "__foldl'", .args = {"op", "nul", "list"}, .doc = R"( @@ -325,7 +325,7 @@ static void prim_genList(EvalState & state, const PosIdx pos, Value ** args, Val } } -static RegisterPrimOp primop_genList({ +PrimOp primop_genList({ .name = "__genList", .args = {"generator", "length"}, .doc = R"( @@ -348,7 +348,7 @@ static void prim_head(EvalState & state, const PosIdx pos, Value ** args, Value elemAt(state, pos, *args[0], 0, v); } -static RegisterPrimOp primop_head({ +PrimOp primop_head({ .name = "__head", .args = {"list"}, .doc = R"( @@ -368,7 +368,7 @@ static void prim_length(EvalState & state, const PosIdx pos, Value ** args, Valu state.forceList(*args[0], pos, "while evaluating the first argument passed to builtins.length"); v.mkInt(args[0]->listSize()); } -static RegisterPrimOp primop_length({ +PrimOp primop_length({ .name = "__length", .args = {"e"}, .doc = R"( @@ -377,7 +377,7 @@ static RegisterPrimOp primop_length({ .fun = prim_length, }); -static RegisterPrimOp primop_filter({ +PrimOp primop_filter({ .name = "__filter", .args = {"f", "list"}, .doc = R"( @@ -425,7 +425,7 @@ static void prim_listToAttrs(EvalState & state, const PosIdx pos, Value ** args, v.mkAttrs(attrs); } -static RegisterPrimOp primop_listToAttrs({ +PrimOp primop_listToAttrs({ .name = "__listToAttrs", .args = {"e"}, .doc = R"( @@ -479,7 +479,7 @@ static void prim_map(EvalState & state, const PosIdx pos, Value ** args, Value & } } -static RegisterPrimOp primop_map({ +PrimOp primop_map({ .name = "map", .args = {"f", "list"}, .doc = R"( @@ -549,7 +549,7 @@ static void prim_partition(EvalState & state, const PosIdx pos, Value ** args, V v.mkAttrs(attrs); } -static RegisterPrimOp primop_partition({ +PrimOp primop_partition({ .name = "__partition", .args = {"pred", "list"}, .doc = R"( @@ -624,7 +624,7 @@ static void prim_sort(EvalState & state, const PosIdx pos, Value ** args, Value std::stable_sort(v.listElems(), v.listElems() + len, comparator); } -static RegisterPrimOp primop_sort({ +PrimOp primop_sort({ .name = "__sort", .args = {"comparator", "list"}, .doc = R"( @@ -662,7 +662,7 @@ static void prim_tail(EvalState & state, const PosIdx pos, Value ** args, Value } } -static RegisterPrimOp primop_tail({ +PrimOp primop_tail({ .name = "__tail", .args = {"list"}, .doc = R"( diff --git a/src/libexpr/primops/path.cc b/src/libexpr/primops/path.cc index 5402b5812..a538768e4 100644 --- a/src/libexpr/primops/path.cc +++ b/src/libexpr/primops/path.cc @@ -154,7 +154,7 @@ static void prim_dirOf(EvalState & state, const PosIdx pos, Value ** args, Value } } -static RegisterPrimOp primop_dirOf({ +PrimOp primop_dirOf({ .name = "dirOf", .args = {"s"}, .doc = R"( @@ -194,7 +194,7 @@ static void prim_filterSource(EvalState & state, const PosIdx pos, Value ** args ); } -static RegisterPrimOp primop_filterSource({ +PrimOp primop_filterSource({ .name = "__filterSource", .args = {"e1", "e2"}, .doc = R"( @@ -314,7 +314,7 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value ** args, Va v.mkPath(state.checkSourcePath(state.findFile(searchPath, path, pos))); } -static RegisterPrimOp primop_findFile(PrimOp{ +PrimOp primop_findFile(PrimOp{ .name = "__findFile", .args = {"search path", "lookup path"}, .doc = R"( @@ -386,7 +386,7 @@ static void prim_outputOf(EvalState & state, const PosIdx pos, Value ** args, Va ); } -static RegisterPrimOp primop_outputOf({ +PrimOp primop_outputOf({ .name = "__outputOf", .args = {"derivation-reference", "output-name"}, .doc = R"( @@ -488,7 +488,7 @@ static void prim_path(EvalState & state, const PosIdx pos, Value ** args, Value addPath(state, pos, name, path->path.abs(), filterFun, method, expectedHash, v, context); } -static RegisterPrimOp primop_path({ +PrimOp primop_path({ .name = "__path", .args = {"args"}, .doc = R"( @@ -559,7 +559,7 @@ static void prim_pathExists(EvalState & state, const PosIdx pos, Value ** args, } } -static RegisterPrimOp primop_pathExists({ +PrimOp primop_pathExists({ .name = "__pathExists", .args = {"path"}, .doc = R"( @@ -587,7 +587,7 @@ static void prim_placeholder(EvalState & state, const PosIdx pos, Value ** args, ))); } -static RegisterPrimOp primop_placeholder({ +PrimOp primop_placeholder({ .name = "placeholder", .args = {"output"}, .doc = R"( @@ -612,7 +612,7 @@ static void prim_toPath(EvalState & state, const PosIdx pos, Value ** args, Valu v.mkString(path.path.abs(), context); } -static RegisterPrimOp primop_toPath({ +PrimOp primop_toPath({ .name = "__toPath", .args = {"s"}, .doc = R"( @@ -664,7 +664,7 @@ static void prim_readDir(EvalState & state, const PosIdx pos, Value ** args, Val v.mkAttrs(attrs); } -static RegisterPrimOp primop_readDir({ +PrimOp primop_readDir({ .name = "__readDir", .args = {"path"}, .doc = R"( @@ -720,7 +720,7 @@ static void prim_readFile(EvalState & state, const PosIdx pos, Value ** args, Va v.mkString(s, context); } -static RegisterPrimOp primop_readFile({ +PrimOp primop_readFile({ .name = "__readFile", .args = {"path"}, .doc = R"( @@ -740,7 +740,7 @@ static void prim_readFileType(EvalState & state, const PosIdx pos, Value ** args v.mkString(fileTypeToString(path.lstat().type)); } -static RegisterPrimOp primop_readFileType({ +PrimOp primop_readFileType({ .name = "__readFileType", .args = {"p"}, .doc = R"( @@ -788,7 +788,7 @@ static void prim_storePath(EvalState & state, const PosIdx pos, Value ** args, V v.mkString(path.abs(), context); } -static RegisterPrimOp primop_storePath({ +PrimOp primop_storePath({ .name = "__storePath", .args = {"path"}, .doc = R"( @@ -852,7 +852,7 @@ static void prim_toFile(EvalState & state, const PosIdx pos, Value ** args, Valu state.allowAndSetStorePathString(storePath, v); } -static RegisterPrimOp primop_toFile({ +PrimOp primop_toFile({ .name = "__toFile", .args = {"name", "s"}, .doc = R"( diff --git a/src/libexpr/primops/string.cc b/src/libexpr/primops/string.cc index 19dc067ac..2e35b5677 100644 --- a/src/libexpr/primops/string.cc +++ b/src/libexpr/primops/string.cc @@ -28,7 +28,7 @@ static void prim_baseNameOf(EvalState & state, const PosIdx pos, Value ** args, ); } -static RegisterPrimOp primop_baseNameOf({ +PrimOp primop_baseNameOf({ .name = "baseNameOf", .args = {"s"}, .doc = R"( @@ -54,7 +54,7 @@ static void prim_compareVersions(EvalState & state, const PosIdx pos, Value ** a v.mkInt(compareVersions(version1, version2)); } -static RegisterPrimOp primop_compareVersions({ +PrimOp primop_compareVersions({ .name = "__compareVersions", .args = {"s1", "s2"}, .doc = R"( @@ -111,7 +111,7 @@ static void prim_concatStringsSep(EvalState & state, const PosIdx pos, Value ** v.mkString(res, context); } -static RegisterPrimOp primop_concatStringsSep( +PrimOp primop_concatStringsSep( {.name = "__concatStringsSep", .args = {"separator", "list"}, .doc = R"( @@ -170,7 +170,7 @@ void prim_match(EvalState & state, const PosIdx pos, Value ** args, Value & v) } } -static RegisterPrimOp primop_match({ +PrimOp primop_match({ .name = "__match", .args = {"regex", "str"}, .doc = R"s( @@ -222,7 +222,7 @@ static void prim_parseDrvName(EvalState & state, const PosIdx pos, Value ** args v.mkAttrs(attrs); } -static RegisterPrimOp primop_parseDrvName({ +PrimOp primop_parseDrvName({ .name = "__parseDrvName", .args = {"s"}, .doc = R"( @@ -326,7 +326,7 @@ static void prim_replaceStrings(EvalState & state, const PosIdx pos, Value ** ar v.mkString(res, context); } -static RegisterPrimOp primop_replaceStrings({ +PrimOp primop_replaceStrings({ .name = "__replaceStrings", .args = {"from", "to", "s"}, .doc = R"( @@ -419,7 +419,7 @@ void prim_split(EvalState & state, const PosIdx pos, Value ** args, Value & v) } } -static RegisterPrimOp primop_split({ +PrimOp primop_split({ .name = "__split", .args = {"regex", "str"}, .doc = R"s( @@ -480,7 +480,7 @@ static void prim_splitVersion(EvalState & state, const PosIdx pos, Value ** args } } -static RegisterPrimOp primop_splitVersion({ +PrimOp primop_splitVersion({ .name = "__splitVersion", .args = {"s"}, .doc = R"( @@ -504,7 +504,7 @@ static void prim_stringLength(EvalState & state, const PosIdx pos, Value ** args v.mkInt(s->size()); } -static RegisterPrimOp primop_stringLength({ +PrimOp primop_stringLength({ .name = "__stringLength", .args = {"e"}, .doc = R"( @@ -557,7 +557,7 @@ static void prim_substring(EvalState & state, const PosIdx pos, Value ** args, V v.mkString((unsigned int) start >= s->size() ? "" : s->substr(start, len), context); } -static RegisterPrimOp primop_substring({ +PrimOp primop_substring({ .name = "__substring", .args = {"start", "len", "s"}, .doc = R"( @@ -595,7 +595,7 @@ static void prim_toString(EvalState & state, const PosIdx pos, Value ** args, Va v.mkString(*s, context); } -static RegisterPrimOp primop_toString({ +PrimOp primop_toString({ .name = "toString", .args = {"e"}, .doc = R"( diff --git a/src/libexpr/primops/system.cc b/src/libexpr/primops/system.cc index 23c9804b6..f9490994d 100644 --- a/src/libexpr/primops/system.cc +++ b/src/libexpr/primops/system.cc @@ -81,7 +81,7 @@ static void prim_getEnv(EvalState & state, const PosIdx pos, Value ** args, Valu v.mkString(evalSettings.restrictEval || evalSettings.pureEval ? "" : getEnv(name).value_or("")); } -static RegisterPrimOp primop_getEnv({ +PrimOp primop_getEnv({ .name = "__getEnv", .args = {"s"}, .doc = R"( diff --git a/src/libexpr/primops/toXML.cc b/src/libexpr/primops/toXML.cc index 6965c8254..cd044c4c3 100644 --- a/src/libexpr/primops/toXML.cc +++ b/src/libexpr/primops/toXML.cc @@ -15,7 +15,7 @@ static void prim_toXML(EvalState & state, const PosIdx pos, Value ** args, Value v.mkString(out.str(), context); } -static RegisterPrimOp primop_toXML({ +PrimOp primop_toXML({ .name = "__toXML", .args = {"e"}, .doc = R"( diff --git a/src/libexpr/primops/types.cc b/src/libexpr/primops/types.cc index 08be0c7f4..a30048b58 100644 --- a/src/libexpr/primops/types.cc +++ b/src/libexpr/primops/types.cc @@ -42,7 +42,7 @@ static void prim_functionArgs(EvalState & state, const PosIdx pos, Value ** args v.mkAttrs(attrs); } -static RegisterPrimOp primop_functionArgs({ +PrimOp primop_functionArgs({ .name = "__functionArgs", .args = {"f"}, .doc = R"( @@ -63,7 +63,7 @@ static RegisterPrimOp primop_functionArgs({ * builtins.isAttrs */ -static RegisterPrimOp primop_isAttrs({ +PrimOp primop_isAttrs({ .name = "__isAttrs", .args = {"e"}, .doc = R"( @@ -76,7 +76,7 @@ static RegisterPrimOp primop_isAttrs({ * builtins.isBool */ -static RegisterPrimOp primop_isBool({ +PrimOp primop_isBool({ .name = "__isBool", .args = {"e"}, .doc = R"( @@ -89,7 +89,7 @@ static RegisterPrimOp primop_isBool({ * builtins.Float */ -static RegisterPrimOp primop_isFloat({ +PrimOp primop_isFloat({ .name = "__isFloat", .args = {"e"}, .doc = R"( @@ -102,7 +102,7 @@ static RegisterPrimOp primop_isFloat({ * builtins.isFunction */ -static RegisterPrimOp primop_isFunction({ +PrimOp primop_isFunction({ .name = "__isFunction", .args = {"e"}, .doc = R"( @@ -115,7 +115,7 @@ static RegisterPrimOp primop_isFunction({ * builtins.isInt */ -static RegisterPrimOp primop_isInt({ +PrimOp primop_isInt({ .name = "__isInt", .args = {"e"}, .doc = R"( @@ -128,7 +128,7 @@ static RegisterPrimOp primop_isInt({ * builtins.isList */ -static RegisterPrimOp primop_isList({ +PrimOp primop_isList({ .name = "__isList", .args = {"e"}, .doc = R"( @@ -141,7 +141,7 @@ static RegisterPrimOp primop_isList({ * builtins.isNull */ -static RegisterPrimOp primop_isNull({ +PrimOp primop_isNull({ .name = "isNull", .args = {"e"}, .doc = R"( @@ -156,7 +156,7 @@ static RegisterPrimOp primop_isNull({ * builtins.isPath */ -static RegisterPrimOp primop_isPath({ +PrimOp primop_isPath({ .name = "__isPath", .args = {"e"}, .doc = R"( @@ -169,7 +169,7 @@ static RegisterPrimOp primop_isPath({ * builtins.isString */ -static RegisterPrimOp primop_isString({ +PrimOp primop_isString({ .name = "__isString", .args = {"e"}, .doc = R"( @@ -223,7 +223,7 @@ static void prim_typeOf(EvalState & state, const PosIdx pos, Value ** args, Valu v.mkString(t); } -static RegisterPrimOp primop_typeOf({ +PrimOp primop_typeOf({ .name = "__typeOf", .args = {"e"}, .doc = R"(