pub enum VMValue {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(String),
Path(String),
List(Vec<VMValue>),
Attrs(BTreeMap<Symbol, VMValue>),
Closure(VMClosure),
Builtin(VMBuiltin),
Thunk(VMThunk),
HigherOrderBuiltin(HigherOrderBuiltin),
}Expand description
A value in the bytecode VM.
Intentionally simpler than the tree-walker’s Value type: no thunks
(the VM manages laziness via its call stack), no rnix AST nodes.
Attribute sets use Symbol keys for O(1) comparisons. Use
VMValue::attrs_to_strings to convert back to BTreeMap<String, VMValue>
for external consumption.
Variants§
Null
Nix null.
Bool(bool)
Nix boolean.
Int(i64)
Nix integer (64-bit signed).
Float(f64)
Nix float (64-bit IEEE 754).
String(String)
Nix string (context tracking deferred to Phase 2).
Path(String)
Nix path literal.
List(Vec<VMValue>)
Nix list.
Attrs(BTreeMap<Symbol, VMValue>)
Nix attribute set with interned keys.
Closure(VMClosure)
A closure: compiled function body + captured upvalues.
Builtin(VMBuiltin)
A built-in function (native Rust implementation).
Thunk(VMThunk)
A lazy thunk: deferred computation, evaluated on first force.
HigherOrderBuiltin(HigherOrderBuiltin)
A higher-order builtin: partially applied operation that needs VM access to call closures. The VM intercepts calls to these and executes them with full execution context.
Implementations§
Source§impl VMValue
impl VMValue
Sourcepub fn is_truthy(&self) -> Result<bool, VMError>
pub fn is_truthy(&self) -> Result<bool, VMError>
Check if this value is truthy (for conditionals).
Sourcepub fn attrs_to_strings(
&self,
interner: &Interner,
) -> Option<BTreeMap<String, VMValue>>
pub fn attrs_to_strings( &self, interner: &Interner, ) -> Option<BTreeMap<String, VMValue>>
Convert a Symbol-keyed attrset to a String-keyed BTreeMap
using the provided interner. Returns None if not an Attrs.
Sourcepub fn to_string_keyed(&self, interner: &Interner) -> StringKeyedValue
pub fn to_string_keyed(&self, interner: &Interner) -> StringKeyedValue
Convert this entire value tree to use string keys (for external API).
Recursively resolves all Symbol keys in nested attrsets and lists.
Sourcepub fn display_with(&self, interner: &Interner, f: &mut Formatter<'_>) -> Result
pub fn display_with(&self, interner: &Interner, f: &mut Formatter<'_>) -> Result
Format this value for display using the interner for key resolution.
Sourcepub fn debug_with(&self, interner: &Interner, f: &mut Formatter<'_>) -> Result
pub fn debug_with(&self, interner: &Interner, f: &mut Formatter<'_>) -> Result
Debug this value using the interner for key resolution.
Trait Implementations§
impl Eq for VMValue
Auto Trait Implementations§
impl !RefUnwindSafe for VMValue
impl !Send for VMValue
impl !Sync for VMValue
impl !UnwindSafe for VMValue
impl Freeze for VMValue
impl Unpin for VMValue
impl UnsafeUnpin for VMValue
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.