Struct cairo_vm::vm::vm_core::VirtualMachine
source · pub struct VirtualMachine { /* private fields */ }Implementations§
source§impl VirtualMachine
impl VirtualMachine
pub fn new(trace_enabled: bool) -> VirtualMachine
pub fn step_hint(
&mut self,
hint_executor: &mut dyn HintProcessor,
exec_scopes: &mut ExecutionScopes,
hint_data_dictionary: &HashMap<usize, Vec<Box<dyn Any>>>,
constants: &HashMap<String, Felt>
) -> Result<(), VirtualMachineError>
pub fn step_instruction(&mut self) -> Result<(), VirtualMachineError>
pub fn step(
&mut self,
hint_executor: &mut dyn HintProcessor,
exec_scopes: &mut ExecutionScopes,
hint_data_dictionary: &HashMap<usize, Vec<Box<dyn Any>>>,
constants: &HashMap<String, Felt>
) -> Result<(), VirtualMachineError>
sourcepub fn compute_operands(
&self,
instruction: &Instruction
) -> Result<(Operands, OperandsAddresses, DeducedOperands), VirtualMachineError>
pub fn compute_operands(
&self,
instruction: &Instruction
) -> Result<(Operands, OperandsAddresses, DeducedOperands), VirtualMachineError>
Compute operands and result, trying to deduce them if normal memory access returns a None value.
sourcepub fn verify_auto_deductions(&mut self) -> Result<(), VirtualMachineError>
pub fn verify_auto_deductions(&mut self) -> Result<(), VirtualMachineError>
Makes sure that all assigned memory cells are consistent with their auto deduction rules.
pub fn end_run(
&mut self,
exec_scopes: &ExecutionScopes
) -> Result<(), VirtualMachineError>
pub fn mark_address_range_as_accessed(
&mut self,
base: Relocatable,
len: usize
) -> Result<(), VirtualMachineError>
sourcepub fn add_memory_segment(&mut self) -> Relocatable
pub fn add_memory_segment(&mut self) -> Relocatable
Adds a new segment and to the VirtualMachine.memory returns its starting location as a RelocatableValue.
pub fn get_ap(&self) -> Relocatable
pub fn get_fp(&self) -> Relocatable
pub fn get_pc(&self) -> &Relocatable
sourcepub fn get_integer(
&self,
key: &Relocatable
) -> Result<Cow<'_, Felt>, VirtualMachineError>
pub fn get_integer(
&self,
key: &Relocatable
) -> Result<Cow<'_, Felt>, VirtualMachineError>
Gets the integer value corresponding to the Relocatable address
sourcepub fn get_relocatable(
&self,
key: &Relocatable
) -> Result<Relocatable, VirtualMachineError>
pub fn get_relocatable(
&self,
key: &Relocatable
) -> Result<Relocatable, VirtualMachineError>
Gets the relocatable value corresponding to the Relocatable address
sourcepub fn get_maybe<'a, 'b: 'a, K: 'a>(
&'b self,
key: &'a K
) -> Result<Option<MaybeRelocatable>, MemoryError>where
Relocatable: TryFrom<&'a K>,
pub fn get_maybe<'a, 'b: 'a, K: 'a>(
&'b self,
key: &'a K
) -> Result<Option<MaybeRelocatable>, MemoryError>where
Relocatable: TryFrom<&'a K>,
Gets a MaybeRelocatable value from memory indicated by a generic address
sourcepub fn get_builtin_runners(&self) -> &Vec<(String, BuiltinRunner)> ⓘ
pub fn get_builtin_runners(&self) -> &Vec<(String, BuiltinRunner)> ⓘ
Returns a reference to the vector with all builtins present in the virtual machine
pub fn get_builtin_runners_as_mut(
&mut self
) -> &mut Vec<(String, BuiltinRunner)> ⓘ
sourcepub fn insert_value<T: Into<MaybeRelocatable>>(
&mut self,
key: &Relocatable,
val: T
) -> Result<(), VirtualMachineError>
pub fn insert_value<T: Into<MaybeRelocatable>>(
&mut self,
key: &Relocatable,
val: T
) -> Result<(), VirtualMachineError>
Inserts a value into a memory address given by a Relocatable value
sourcepub fn load_data(
&mut self,
ptr: &MaybeRelocatable,
data: &Vec<MaybeRelocatable>
) -> Result<MaybeRelocatable, MemoryError>
pub fn load_data(
&mut self,
ptr: &MaybeRelocatable,
data: &Vec<MaybeRelocatable>
) -> Result<MaybeRelocatable, MemoryError>
Writes data into the memory at address ptr and returns the first address after the data.
sourcepub fn write_arg(
&mut self,
ptr: &Relocatable,
arg: &dyn Any
) -> Result<MaybeRelocatable, MemoryError>
pub fn write_arg(
&mut self,
ptr: &Relocatable,
arg: &dyn Any
) -> Result<MaybeRelocatable, MemoryError>
Writes args into the memory at address ptr and returns the first address after the data. Perfroms modulo on each element
sourcepub fn get_return_values(
&self,
n_ret: usize
) -> Result<Vec<MaybeRelocatable>, MemoryError>
pub fn get_return_values(
&self,
n_ret: usize
) -> Result<Vec<MaybeRelocatable>, MemoryError>
Gets n_ret return values from memory
sourcepub fn get_range(
&self,
addr: &MaybeRelocatable,
size: usize
) -> Result<Vec<Option<Cow<'_, MaybeRelocatable>>>, MemoryError>
pub fn get_range(
&self,
addr: &MaybeRelocatable,
size: usize
) -> Result<Vec<Option<Cow<'_, MaybeRelocatable>>>, MemoryError>
Gets n elements from memory starting from addr (n being size)
sourcepub fn get_continuous_range(
&self,
addr: &MaybeRelocatable,
size: usize
) -> Result<Vec<MaybeRelocatable>, MemoryError>
pub fn get_continuous_range(
&self,
addr: &MaybeRelocatable,
size: usize
) -> Result<Vec<MaybeRelocatable>, MemoryError>
Gets n elements from memory starting from addr (n being size)
sourcepub fn get_integer_range(
&self,
addr: &Relocatable,
size: usize
) -> Result<Vec<Cow<'_, Felt>>, VirtualMachineError>
pub fn get_integer_range(
&self,
addr: &Relocatable,
size: usize
) -> Result<Vec<Cow<'_, Felt>>, VirtualMachineError>
Gets n integer values from memory starting from addr (n being size),
pub fn get_range_check_builtin(
&self
) -> Result<&RangeCheckBuiltinRunner, VirtualMachineError>
pub fn get_signature_builtin(
&mut self
) -> Result<&mut SignatureBuiltinRunner, VirtualMachineError>
pub fn disable_trace(&mut self)
pub fn get_segment_used_size(&self, index: usize) -> Option<usize>
pub fn add_temporary_segment(&mut self) -> Relocatable
sourcepub fn add_relocation_rule(
&mut self,
src_ptr: Relocatable,
dst_ptr: Relocatable
) -> Result<(), MemoryError>
pub fn add_relocation_rule(
&mut self,
src_ptr: Relocatable,
dst_ptr: Relocatable
) -> Result<(), MemoryError>
Add a new relocation rule.
Will return an error if any of the following conditions are not met:
- Source address’s segment must be negative (temporary).
- Source address’s offset must be zero.
- There shouldn’t already be relocation at the source segment.
pub fn gen_arg(
&mut self,
arg: &dyn Any
) -> Result<MaybeRelocatable, VirtualMachineError>
sourcepub fn compute_effective_sizes(&mut self) -> &Vec<usize> ⓘ
pub fn compute_effective_sizes(&mut self) -> &Vec<usize> ⓘ
Proxy to MemorySegmentManager::compute_effective_sizes() to make it accessible from outside cairo-rs.