7#include "lix/libexpr/gc-alloc.hh"
12Value * EvalMemory::allocValue()
19 if (!*valueAllocCache) {
20 *valueAllocCache = GC_malloc_many(
sizeof(Value));
21 if (!*valueAllocCache)
throw std::bad_alloc();
26 void * p = *valueAllocCache;
27 *valueAllocCache = GC_NEXT(p);
30 void * p = gcAllocBytes(
sizeof(Value));
34 return static_cast<Value *
>(p);
39Env & EvalMemory::allocEnv(
size_t size)
42 stats.nrValuesInEnvs += size;
49 if (!*env1AllocCache) {
50 *env1AllocCache = GC_malloc_many(
sizeof(Env) +
sizeof(Value *));
51 if (!*env1AllocCache)
throw std::bad_alloc();
54 void * p = *env1AllocCache;
55 *env1AllocCache = GC_NEXT(p);
57 env =
static_cast<Env *
>(p);
60 env =
static_cast<Env *
>(gcAllocBytes(
sizeof(Env) + size *
sizeof(Value *)));
72 Env * env = v.thunk.env;
73 Expr & expr = *v.thunk.expr;
77 expr.eval(*
this, *env, v);
80 tryFixupBlackHolePos(v, pos);
85 callFunction(*v.app.left, *v.app.right, v, pos);
90inline void EvalState::forceAttrs(
Value & v,
const PosIdx pos, std::string_view errorCtx)
93 if (v.
type() != nAttrs) {
94 ctx.errors.make<TypeError>(
95 "expected a set but found %1%: %2%",
98 ).withTrace(pos, errorCtx).debugThrow();
103[[gnu::always_inline]]
104inline void EvalState::forceList(
Value & v,
const PosIdx pos, std::string_view errorCtx)
108 ctx.errors.make<TypeError>(
109 "expected a list but found %1%: %2%",
111 ValuePrinter(*
this, v, errorPrintOptions)
112 ).withTrace(pos, errorCtx).debugThrow();
void forceValue(Value &v, const PosIdx pos)
Definition eval-inline.hh:69
Common printing functions for the Nix language.
Definition nixexpr.hh:104
ValueType type(bool invalidIsThunk=false) const
Definition value.hh:619