2020-10-06 11:18:44 +03:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2020-10-06 11:18:44 +03:00
|
|
|
|
2016-04-13 12:15:45 +03:00
|
|
|
#include "eval.hh"
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-11-16 14:04:27 +02:00
|
|
|
/**
|
|
|
|
* For functions where we do not expect deep recursion, we can use a sizable
|
|
|
|
* part of the stack a free allocation space.
|
|
|
|
*
|
|
|
|
* Note: this is expected to be multiplied by sizeof(Value), or about 24 bytes.
|
|
|
|
*/
|
2023-11-16 14:23:17 +02:00
|
|
|
constexpr size_t nonRecursiveStackReservation = 128;
|
2023-11-16 14:04:27 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions that maybe applied to self-similar inputs, such as concatMap on a
|
|
|
|
* tree, should reserve a smaller part of the stack for allocation.
|
|
|
|
*
|
|
|
|
* Note: this is expected to be multiplied by sizeof(Value), or about 24 bytes.
|
|
|
|
*/
|
|
|
|
constexpr size_t conservativeStackReservation = 16;
|
|
|
|
|
2016-04-13 12:15:45 +03:00
|
|
|
struct RegisterPrimOp
|
|
|
|
{
|
2023-05-13 20:52:45 +03:00
|
|
|
typedef std::vector<PrimOp> PrimOps;
|
2016-04-13 12:15:45 +03:00
|
|
|
static PrimOps * primOps;
|
2020-06-17 17:54:32 +03:00
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
|
|
|
* You can register a constant by passing an arity of 0. fun
|
|
|
|
* will get called during EvalState initialization, so there
|
|
|
|
* may be primops not yet added and builtins is not yet sorted.
|
|
|
|
*/
|
2023-05-13 20:52:45 +03:00
|
|
|
RegisterPrimOp(PrimOp && primOp);
|
2016-04-13 12:15:45 +03:00
|
|
|
};
|
|
|
|
|
2018-04-09 17:26:50 +03:00
|
|
|
/* These primops are disabled without enableNativeCode, but plugins
|
|
|
|
may wish to use them in limited contexts without globally enabling
|
|
|
|
them. */
|
2022-03-25 15:04:18 +02:00
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
|
|
|
* Load a ValueInitializer from a DSO and return whatever it initializes
|
|
|
|
*/
|
2022-03-04 20:31:59 +02:00
|
|
|
void prim_importNative(EvalState & state, const PosIdx pos, Value * * args, Value & v);
|
2020-03-30 17:04:18 +03:00
|
|
|
|
2023-04-07 16:55:28 +03:00
|
|
|
/**
|
|
|
|
* Execute a program and parse its output
|
|
|
|
*/
|
2022-03-04 20:31:59 +02:00
|
|
|
void prim_exec(EvalState & state, const PosIdx pos, Value * * args, Value & v);
|
2018-04-09 17:26:50 +03:00
|
|
|
|
2024-01-29 07:19:23 +02:00
|
|
|
void makePositionThunks(EvalState & state, const PosIdx pos, Value & line, Value & column);
|
|
|
|
|
2016-04-13 12:15:45 +03:00
|
|
|
}
|