Enum tvix_eval::generators::VMRequest
source · pub enum VMRequest {
Show 22 variants
ForceValue(Value),
DeepForceValue(Value),
WithValue(usize),
CapturedWithValue(usize),
NixEquality(Box<(Value, Value)>, PointerEquality),
StackPush(Value),
StackPop,
StringCoerce(Value, CoercionKind),
Call(Value),
EnterLambda {
lambda: Rc<Lambda>,
upvalues: Rc<Upvalues>,
span: Span,
},
EmitWarning(EvalWarning),
EmitWarningKind(WarningKind),
ImportCacheLookup(PathBuf),
ImportCachePut(PathBuf, Value),
PathImport(PathBuf),
OpenFile(PathBuf),
PathExists(PathBuf),
ReadDir(PathBuf),
Span,
TryForce(Value),
ToJson(Value),
ReadFileType(PathBuf),
}
Expand description
Messages that can be sent from generators to the VM. In most cases, the VM will suspend the generator when receiving a message and enter some other frame to process the request.
Responses are returned to generators via the [GeneratorResponse
] type.
Variants§
ForceValue(Value)
Request that the VM forces this value. This message is first sent to the VM with the unforced value, then returned to the generator with the forced result.
DeepForceValue(Value)
Request that the VM deep-forces the value.
WithValue(usize)
Request the value at the given index from the VM’s with-stack, in forced state.
The value is returned in the ForceValue
message.
CapturedWithValue(usize)
Request the value at the given index from the captured with-stack, in forced state.
NixEquality(Box<(Value, Value)>, PointerEquality)
Request that the two values be compared for Nix equality. The result is
returned in the ForceValue
message.
StackPush(Value)
Push the given value to the VM’s stack. This is used to prepare the stack for requesting a function call from the VM.
The VM does not respond to this request, so the next message received is
Empty
.
StackPop
Pop a value from the stack and return it to the generator.
StringCoerce(Value, CoercionKind)
Request that the VM coerces this value to a string.
Call(Value)
Request that the VM calls the given value, with arguments already prepared on the stack. Value must already be forced.
EnterLambda
Request a call frame entering the given lambda immediately. This can be used to force thunks.
EmitWarning(EvalWarning)
Emit a runtime warning (already containing a span) through the VM.
EmitWarningKind(WarningKind)
Emit a runtime warning through the VM. The span of the current generator is used for the final warning.
ImportCacheLookup(PathBuf)
Request a lookup in the VM’s import cache, which tracks the thunks yielded by previously imported files.
ImportCachePut(PathBuf, Value)
Provide the VM with an imported value for a given path, which it can populate its input cache with.
PathImport(PathBuf)
Request that the VM imports the given path through its I/O interface.
OpenFile(PathBuf)
Request that the VM opens the specified file and provides a reader.
PathExists(PathBuf)
Request that the VM checks whether the given path exists.
ReadDir(PathBuf)
Request that the VM reads the given path.
Span
Request a reasonable span from the VM.
TryForce(Value)
Request evaluation of builtins.tryEval
from the VM. See
[VM::catch_result
] for an explanation of how this works.
ToJson(Value)
Request serialisation of a value to JSON, according to the slightly odd Nix evaluation rules.
ReadFileType(PathBuf)
Request the VM for the file type of the given path.