Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Value Struct Reference
Inheritance diagram for nix::Value:
nix::ValueStorage< sizeof(void *)> nix::detail::ValueBase

Public Member Functions

void print (EvalState &state, std::ostream &str, PrintOptions options=PrintOptions{})
bool isThunk () const
bool isApp () const
bool isBlackhole () const
bool isLambda () const
bool isPrimOp () const
bool isPrimOpApp () const
bool isFailed () const
template<bool invalidIsThunk = false>
ValueType type () const
bool isValid () const noexcept
bool isWHNF () const noexcept
void mkInt (NixInt::Inner n) noexcept
void mkInt (NixInt n) noexcept
void mkBool (bool b) noexcept
void mkStringNoCopy (const StringData &s, const Value::StringWithContext::Context *context=nullptr) noexcept
void mkString (std::string_view s, EvalMemory &mem)
void mkString (std::string_view s, const NixStringContext &context, EvalMemory &mem)
void mkStringMove (const StringData &s, const NixStringContext &context, EvalMemory &mem)
void mkPath (const SourcePath &path, EvalMemory &mem)
void mkPath (SourceAccessor *accessor, const StringData &path) noexcept
void mkNull () noexcept
void mkAttrs (const Bindings *a) noexcept
Value & mkAttrs (BindingsBuilder &bindings)
void mkList (const ListBuilder &builder) noexcept
void mkThunk (Env *e, Expr *ex) noexcept
void mkApp (Value *l, Value *r) noexcept
void mkLambda (Env *e, ExprLambda *f) noexcept
void mkBlackhole ()
void mkPrimOp (PrimOp *p)
void mkPrimOpApp (Value *l, Value *r) noexcept
const PrimOp * primOpAppPrimOp () const
void mkExternal (ExternalValueBase *e) noexcept
void mkFloat (NixFloat n) noexcept
void mkFailed (std::exception_ptr e, Value *recovery) noexcept
bool isList () const noexcept
ListView listView () const noexcept
size_t listSize () const noexcept
PosIdx determinePos (const PosIdx pos) const
bool isTrivial () const
SourcePath path () const
const StringData & string_data () const noexcept
const char * c_str () const noexcept
std::string_view string_view () const noexcept
nix::Symbol symbol () const noexcept
const Value::StringWithContext::Context * context () const noexcept
ExternalValueBase * external () const noexcept
const Bindings * attrs () const noexcept
const PrimOp * primOp () const noexcept
bool boolean () const noexcept
NixInt integer () const noexcept
NixFloat fpoint () const noexcept
Lambda lambda () const noexcept
ClosureThunk thunk () const noexcept
PrimOpApplicationThunk primOpApp () const noexcept
FunctionApplicationThunk app () const noexcept
const char * pathStr () const noexcept
std::string_view pathStrView () const noexcept
SourceAccessor * pathAccessor () const noexcept
Failed & failed () const noexcept

Static Public Member Functions

static Value * toPtr (SymbolStr str) noexcept

Static Public Attributes

static Value vEmptyList
static Value vNull
static Value vTrue
static Value vFalse

Friends

class SymbolStr
std::string showType (const Value &v)

Additional Inherited Members

Public Types inherited from nix::detail::ValueBase
using SmallList = std::array<Value *, 2>
Protected Types inherited from nix::ValueStorage< sizeof(void *)>
using Payload
Protected Member Functions inherited from nix::ValueStorage< sizeof(void *)>
bool isAtomic ()
void getStorage (NixInt &val) const noexcept
void setStorage (NixInt val) noexcept
InternalType getInternalType () const noexcept

Member Function Documentation

◆ isTrivial()

bool nix::Value::isTrivial ( ) const

Check whether forcing this value requires a trivial amount of computation. In particular, function applications are non-trivial.

◆ isValid()

bool nix::Value::isValid ( ) const
inlinenoexcept

A value becomes valid when it is initialized. We don't use this in the evaluator; only in the bindings, where the slight extra cost is warranted because of inexperienced callers.

◆ isWHNF()

bool nix::Value::isWHNF ( ) const
inlinenoexcept

Whether the value has been evaluated to WHNF, i.e. non-deep successful evaluation result, or successful "root of a value". See https://nix.dev/manual/nix/latest/language/evaluation.html?highlight=whnf#values

◆ primOpAppPrimOp()

const PrimOp * nix::Value::primOpAppPrimOp ( ) const

For a tPrimOpApp value, get the original PrimOp value.

◆ symbol()

Symbol nix::Value::symbol ( ) const
inlinenoexcept

If this string comes from the symbol table, returns its symbol, otherwise the null symbol.

Precondition
type() == nString
Note
Defined in symbol-table.hh, which defines nix::Symbol.

◆ toPtr()

Value * nix::Value::toPtr ( SymbolStr str)
staticnoexcept

Never modify the backing Value object!

◆ type()

template<bool invalidIsThunk = false>
ValueType nix::Value::type ( ) const
inline

Returns the normal type of a Value. This only returns nThunk if the Value hasn't been forceValue'd

Template Parameters
invalidIsThunkInstead of UB an an invalid (probably 0, so uninitialized) internal type, return nThunk.

Member Data Documentation

◆ vEmptyList

Value nix::Value::vEmptyList
static
Initial value:
= []() {
Value res;
res.setStorage(List{.size = 0, .elems = nullptr});
return res;
}()
Definition value.hh:1166
Definition value.hh:438

Empty list constant.

This is not a singleton. Pointer equality is not sufficient.

◆ vFalse

Value nix::Value::vFalse
static
Initial value:
= []() {
Value res;
res.mkBool(false);
return res;
}()

true constant.

This is not a singleton. Pointer equality is not sufficient.

◆ vNull

Value nix::Value::vNull
static
Initial value:
= []() {
Value res;
res.mkNull();
return res;
}()

null constant.

This is not a singleton. Pointer equality is not sufficient.

◆ vTrue

Value nix::Value::vTrue
static
Initial value:
= []() {
Value res;
res.mkBool(true);
return res;
}()

true constant.

This is not a singleton. Pointer equality is not sufficient.


The documentation for this struct was generated from the following files:
  • libexpr/include/nix/expr/value.hh
  • libexpr/attr-set.cc
  • libexpr/eval.cc
  • libexpr/include/nix/expr/symbol-table.hh
  • libexpr/value.cc