Trait budvm::Environment
source · pub trait Environment: 'static {
type String: DynamicValue + for<'a> From<&'a str> + From<String>;
type Intrinsic: Clone + PartialEq + Display + Debug + FromStr;
// Required methods
fn intrinsic(
&mut self,
intrinsic: &Self::Intrinsic,
args: PoppedValues<'_>
) -> Result<Value, FaultKind>;
fn step(&mut self) -> ExecutionBehavior;
// Provided methods
fn convert(&self, value: &Value, kind: &Symbol) -> Result<Value, FaultKind> { ... }
fn convert_string(&self, value: &Value) -> Result<Value, FaultKind> { ... }
}
Expand description
Customizes the behavior of a virtual machine instance.
Required Associated Types§
Required Methods§
sourcefn intrinsic(
&mut self,
intrinsic: &Self::Intrinsic,
args: PoppedValues<'_>
) -> Result<Value, FaultKind>
fn intrinsic( &mut self, intrinsic: &Self::Intrinsic, args: PoppedValues<'_> ) -> Result<Value, FaultKind>
Evalutes the intrinsic
operation with the provided arguments.
This is invoked when the virtual machine executes an
Instruction::CallIntrinsic
.
sourcefn step(&mut self) -> ExecutionBehavior
fn step(&mut self) -> ExecutionBehavior
Called once before each instruction is executed.
If ExecutionBehavior::Continue
is returned, the next instruction
will be exected.
If ExecutionBehavior::Pause
is returned, the virtual machine is
paused and a FaultOrPause::Pause
is raised. If the execution is
resumed, the first function call will be before executing the same
instruction as the one when ExecutionBehavior::Pause
was called.