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 compute_segments_effective_sizes(&mut self)
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, Felt252> ) -> 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, Felt252> ) -> 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(&self) -> Result<(), VirtualMachineError>
pub fn verify_auto_deductions(&self) -> Result<(), VirtualMachineError>
Makes sure that all assigned memory cells are consistent with their auto deduction rules.
pub fn verify_auto_deductions_for_addr( &self, addr: Relocatable, builtin: &BuiltinRunner ) -> Result<(), VirtualMachineError>
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 memory and returns its starting location as a Relocatable value.
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<'_, Felt252>, MemoryError>
pub fn get_integer( &self, key: Relocatable ) -> Result<Cow<'_, Felt252>, MemoryError>
Gets the integer value corresponding to the Relocatable address
sourcepub fn get_relocatable(
&self,
key: Relocatable
) -> Result<Relocatable, MemoryError>
pub fn get_relocatable( &self, key: Relocatable ) -> Result<Relocatable, MemoryError>
Gets the relocatable value corresponding to the Relocatable address
sourcepub fn get_maybe<'a, 'b: 'a, K: 'a>(
&'b self,
key: &'a K
) -> Option<MaybeRelocatable>where
Relocatable: TryFrom<&'a K>,
pub fn get_maybe<'a, 'b: 'a, K: 'a>( &'b self, key: &'a K ) -> Option<MaybeRelocatable>where Relocatable: TryFrom<&'a K>,
Gets a MaybeRelocatable value from memory indicated by a generic address
sourcepub fn get_builtin_runners(&self) -> &Vec<BuiltinRunner>
pub fn get_builtin_runners(&self) -> &Vec<BuiltinRunner>
Returns a reference to the vector with all builtins present in the virtual machine
sourcepub fn get_builtin_runners_as_mut(&mut self) -> &mut Vec<BuiltinRunner>
pub fn get_builtin_runners_as_mut(&mut self) -> &mut Vec<BuiltinRunner>
Returns a mutable reference to the vector with all builtins present in the virtual machine
sourcepub fn insert_value<T: Into<MaybeRelocatable>>(
&mut self,
key: Relocatable,
val: T
) -> Result<(), MemoryError>
pub fn insert_value<T: Into<MaybeRelocatable>>( &mut self, key: Relocatable, val: T ) -> Result<(), MemoryError>
Inserts a value into a memory address given by a Relocatable value
sourcepub fn load_data(
&mut self,
ptr: Relocatable,
data: &Vec<MaybeRelocatable>
) -> Result<Relocatable, MemoryError>
pub fn load_data( &mut self, ptr: Relocatable, data: &Vec<MaybeRelocatable> ) -> Result<Relocatable, MemoryError>
Writes data into the memory from 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 from address ptr and returns the first address after the data.
pub fn memcmp( &self, lhs: Relocatable, rhs: Relocatable, len: usize ) -> (Ordering, usize)
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: Relocatable,
size: usize
) -> Vec<Option<Cow<'_, MaybeRelocatable>>>
pub fn get_range( &self, addr: Relocatable, size: usize ) -> Vec<Option<Cow<'_, MaybeRelocatable>>>
Gets n elements from memory starting from addr (n being size)
sourcepub fn get_continuous_range(
&self,
addr: Relocatable,
size: usize
) -> Result<Vec<MaybeRelocatable>, MemoryError>
pub fn get_continuous_range( &self, addr: Relocatable, 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<'_, Felt252>>, MemoryError>
pub fn get_integer_range( &self, addr: Relocatable, size: usize ) -> Result<Vec<Cow<'_, Felt252>>, MemoryError>
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 get_segment_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, MemoryError>
sourcepub fn write_output(
&mut self,
writer: &mut impl Write
) -> Result<(), VirtualMachineError>
pub fn write_output( &mut self, writer: &mut impl Write ) -> Result<(), VirtualMachineError>
Write the values hosted in the output builtin’s segment. Does nothing if the output builtin is not present in the program.
sourcepub fn relocate_trace(
&mut self,
relocation_table: &[usize]
) -> Result<(), TraceError>
pub fn relocate_trace( &mut self, relocation_table: &[usize] ) -> Result<(), TraceError>
Relocates the VM’s trace, turning relocatable registers to numbered ones
pub fn get_relocated_trace(&self) -> Result<&Vec<TraceEntry>, TraceError>
Auto Trait Implementations§
impl !RefUnwindSafe for VirtualMachine
impl !Send for VirtualMachine
impl !Sync for VirtualMachine
impl Unpin for VirtualMachine
impl !UnwindSafe for VirtualMachine
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.