pub struct EvalContext<'a> { /* private fields */ }
Expand description
Evaluation context for the AVM
Implementations§
Source§impl<'a> EvalContext<'a>
impl<'a> EvalContext<'a>
Sourcepub fn new(
program: &'a [u8],
run_mode: RunMode,
cost_budget: u64,
version: TealVersion,
group_index: usize,
group_size: usize,
ledger: &'a mut dyn LedgerAccess,
) -> Self
pub fn new( program: &'a [u8], run_mode: RunMode, cost_budget: u64, version: TealVersion, group_index: usize, group_size: usize, ledger: &'a mut dyn LedgerAccess, ) -> Self
Create a new evaluation context
Sourcepub fn set_trace_enabled(&mut self, enabled: bool)
pub fn set_trace_enabled(&mut self, enabled: bool)
Enable or disable execution tracing
Sourcepub fn stack(&self) -> &[StackValue]
pub fn stack(&self) -> &[StackValue]
Get a read-only reference to the stack
Sourcepub fn push(&mut self, value: StackValue) -> AvmResult<()>
pub fn push(&mut self, value: StackValue) -> AvmResult<()>
Push a value onto the stack
Sourcepub fn pop(&mut self) -> AvmResult<StackValue>
pub fn pop(&mut self) -> AvmResult<StackValue>
Pop a value from the stack
Sourcepub fn peek(&self) -> AvmResult<&StackValue>
pub fn peek(&self) -> AvmResult<&StackValue>
Peek at the top value on the stack without removing it
Sourcepub fn stack_size(&self) -> usize
pub fn stack_size(&self) -> usize
Get the current stack size
Sourcepub fn stack_is_empty(&self) -> bool
pub fn stack_is_empty(&self) -> bool
Check if the stack is empty
Sourcepub fn peek_at_depth(&self, depth: usize) -> AvmResult<&StackValue>
pub fn peek_at_depth(&self, depth: usize) -> AvmResult<&StackValue>
Get value at stack depth N (0 = top, 1 = one below top, etc.)
Sourcepub fn remove_at_depth(&mut self, depth: usize) -> AvmResult<StackValue>
pub fn remove_at_depth(&mut self, depth: usize) -> AvmResult<StackValue>
Remove value at stack depth N and return it
Sourcepub fn insert_at_depth(
&mut self,
depth: usize,
value: StackValue,
) -> AvmResult<()>
pub fn insert_at_depth( &mut self, depth: usize, value: StackValue, ) -> AvmResult<()>
Insert value at stack depth N (0 = top)
Sourcepub fn program_len(&self) -> usize
pub fn program_len(&self) -> usize
Get the program length
Sourcepub fn advance_pc(&mut self, offset: usize) -> AvmResult<()>
pub fn advance_pc(&mut self, offset: usize) -> AvmResult<()>
Advance the program counter
Sourcepub fn current_byte(&self) -> AvmResult<u8>
pub fn current_byte(&self) -> AvmResult<u8>
Get the current program byte at PC
Sourcepub fn read_bytes(&self, count: usize) -> AvmResult<&[u8]>
pub fn read_bytes(&self, count: usize) -> AvmResult<&[u8]>
Read bytes from program starting at PC
Sourcepub fn cost_budget(&self) -> u64
pub fn cost_budget(&self) -> u64
Get the cost budget
Sourcepub fn version(&self) -> TealVersion
pub fn version(&self) -> TealVersion
Get the TEAL version
Sourcepub fn group_index(&self) -> usize
pub fn group_index(&self) -> usize
Get the group index
Sourcepub fn group_size(&self) -> usize
pub fn group_size(&self) -> usize
Get the group size
Sourcepub fn get_scratch(&self, index: u8) -> AvmResult<&StackValue>
pub fn get_scratch(&self, index: u8) -> AvmResult<&StackValue>
Get a value from scratch space
Sourcepub fn set_scratch(&mut self, index: u8, value: StackValue) -> AvmResult<()>
pub fn set_scratch(&mut self, index: u8, value: StackValue) -> AvmResult<()>
Set a value in scratch space
Sourcepub fn call_subroutine(&mut self, target: usize) -> AvmResult<()>
pub fn call_subroutine(&mut self, target: usize) -> AvmResult<()>
Call a subroutine
Sourcepub fn return_from_subroutine(&mut self) -> AvmResult<()>
pub fn return_from_subroutine(&mut self) -> AvmResult<()>
Return from a subroutine
Sourcepub fn ledger(&self) -> &dyn LedgerAccess
pub fn ledger(&self) -> &dyn LedgerAccess
Get the ledger access interface
Sourcepub fn ledger_mut(&mut self) -> &mut dyn LedgerAccess
pub fn ledger_mut(&mut self) -> &mut dyn LedgerAccess
Get mutable access to the ledger
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if execution is finished
Sourcepub fn set_function_prototype(
&mut self,
args: usize,
returns: usize,
) -> AvmResult<()>
pub fn set_function_prototype( &mut self, args: usize, returns: usize, ) -> AvmResult<()>
Set function prototype
Sourcepub fn frame_dig(&self, depth: i8) -> AvmResult<StackValue>
pub fn frame_dig(&self, depth: i8) -> AvmResult<StackValue>
Dig value from function frame
Sourcepub fn frame_bury(&mut self, depth: i8, value: StackValue) -> AvmResult<()>
pub fn frame_bury(&mut self, depth: i8, value: StackValue) -> AvmResult<()>
Bury value in function frame
Sourcepub fn set_int_constants(&mut self, constants: Vec<u64>)
pub fn set_int_constants(&mut self, constants: Vec<u64>)
Store integer constants from intcblock
Sourcepub fn set_byte_constants(&mut self, constants: Vec<Vec<u8>>)
pub fn set_byte_constants(&mut self, constants: Vec<Vec<u8>>)
Store byte constants from bytecblock
Sourcepub fn get_int_constant(&self, index: usize) -> AvmResult<u64>
pub fn get_int_constant(&self, index: usize) -> AvmResult<u64>
Get integer constant by index
Sourcepub fn get_byte_constant(&self, index: usize) -> AvmResult<&[u8]>
pub fn get_byte_constant(&self, index: usize) -> AvmResult<&[u8]>
Get byte constant by index
Sourcepub fn get_program(&self) -> &[u8] ⓘ
pub fn get_program(&self) -> &[u8] ⓘ
Get program reference for reading bytes
Sourcepub fn current_opcode_spec<'b>(
&self,
vm: &'b VirtualMachine,
) -> AvmResult<&'b OpSpec>
pub fn current_opcode_spec<'b>( &self, vm: &'b VirtualMachine, ) -> AvmResult<&'b OpSpec>
Get current opcode specification (for debugging)
Sourcepub fn step(
&mut self,
vm: &VirtualMachine,
config: &ExecutionConfig,
) -> AvmResult<()>
pub fn step( &mut self, vm: &VirtualMachine, config: &ExecutionConfig, ) -> AvmResult<()>
Execute a single step with the given VM and config