pub struct Cursor<'a> {Show 14 fields
pub frames: Vec<Frame<'a>>,
pub values: Vec<Value>,
pub functions: HashMap<GlobalId, FunctionVariant<'a>>,
pub globals: HashMap<GlobalId, Value>,
pub user_values: HashMap<Symbol, Value>,
pub mappings: HashMap<GlobalId, HashMap<Value, Value>>,
pub structs: HashMap<GlobalId, IndexSet<Symbol>>,
pub futures: Vec<Future>,
pub contexts: ContextStack,
pub signer: Address<TestnetV0>,
pub rng: ChaCha20Rng,
pub block_height: u32,
pub really_async: bool,
pub program: Option<Symbol>,
}
Expand description
Tracks the current execution state - a cursor into the running program.
Fields§
§frames: Vec<Frame<'a>>
Stack of execution frames, with the one currently to be executed on top.
values: Vec<Value>
Stack of values from evaluated expressions.
Each time an expression completes evaluation, a value is pushed here.
functions: HashMap<GlobalId, FunctionVariant<'a>>
All functions (or transitions or inlines) in any program being interpreted.
globals: HashMap<GlobalId, Value>
Consts are stored here.
user_values: HashMap<Symbol, Value>
§mappings: HashMap<GlobalId, HashMap<Value, Value>>
§structs: HashMap<GlobalId, IndexSet<Symbol>>
For each struct type, we only need to remember the names of its members, in order.
futures: Vec<Future>
§contexts: ContextStack
§signer: Address<TestnetV0>
§rng: ChaCha20Rng
§block_height: u32
§really_async: bool
§program: Option<Symbol>
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
Sourcepub fn new(
really_async: bool,
signer: Address<TestnetV0>,
block_height: u32,
) -> Self
pub fn new( really_async: bool, signer: Address<TestnetV0>, block_height: u32, ) -> Self
really_async
indicates we should really delay execution of async function calls until the user runs them.
pub fn set_program(&mut self, program: &str)
pub fn current_program(&self) -> Option<Symbol>
pub fn increment_step(&mut self)
fn new_caller(&self) -> Address<TestnetV0>
fn pop_value(&mut self) -> Result<Value>
fn lookup(&self, name: Symbol) -> Option<Value>
pub fn lookup_mapping( &self, program: Option<Symbol>, name: Symbol, ) -> Option<&HashMap<Value, Value>>
pub fn lookup_mapping_mut( &mut self, program: Option<Symbol>, name: Symbol, ) -> Option<&mut HashMap<Value, Value>>
fn lookup_function( &self, program: Symbol, name: Symbol, ) -> Option<FunctionVariant<'a>>
fn set_variable(&mut self, symbol: Symbol, value: Value)
Sourcepub fn whole_step(&mut self) -> Result<StepResult>
pub fn whole_step(&mut self) -> Result<StepResult>
Execute the whole step of the current Element.
That is, perform a step, and then finish all statements and expressions that have been pushed, until we’re ready for the next step of the current Element (if there is one).
Sourcepub fn over(&mut self) -> Result<StepResult>
pub fn over(&mut self) -> Result<StepResult>
Step over
the current Element.
That is, continue executing until the current Element is finished.
pub fn step_block( &mut self, block: &'a Block, function_body: bool, step: usize, ) -> bool
fn step_statement( &mut self, statement: &'a Statement, step: usize, ) -> Result<bool>
fn step_expression( &mut self, expression: &'a Expression, step: usize, ) -> Result<bool>
Sourcepub fn step(&mut self) -> Result<StepResult>
pub fn step(&mut self) -> Result<StepResult>
Execute one step of the current element.
Many Leo constructs require multiple steps. For instance, when executing a conditional,
the first step will push the condition expression to the stack. Once that has executed
and we’ve returned to the conditional, we push the then
or otherwise
block to the
stack. Once that has executed and we’ve returned to the conditional, the final step
does nothing.
pub fn do_call( &mut self, function_program: Symbol, function_name: Symbol, arguments: impl Iterator<Item = Value>, finalize: bool, span: Span, ) -> Result<()>
Source§impl Cursor<'_>
impl Cursor<'_>
fn mapping_by_call_operator( &self, operator: &CallOperator<TestnetV0>, ) -> Option<&HashMap<Value, Value>>
fn get_register(&self, reg: &Register<TestnetV0>) -> &Value
fn set_register(&mut self, reg: Register<TestnetV0>, value: Value)
fn instructions_len(&self) -> usize
fn increment_instruction_index(&mut self)
fn execution_complete(&self) -> bool
fn next_instruction(&self) -> Option<&Instruction<TestnetV0>>
fn next_command(&self) -> Option<&Command<TestnetV0>>
fn operand_value(&self, operand: &Operand<TestnetV0>) -> Value
fn step_aleo_instruction( &mut self, instruction: Instruction<TestnetV0>, ) -> Result<()>
fn outputs(&self) -> Vec<Value>
fn step_aleo_command(&mut self, command: Command<TestnetV0>) -> Result<()>
fn branch(&mut self, label: &Identifier<TestnetV0>)
pub fn step_aleo(&mut self) -> Result<()>
Trait Implementations§
Source§impl CoreFunctionHelper for Cursor<'_>
impl CoreFunctionHelper for Cursor<'_>
fn pop_value_impl(&mut self) -> Option<Value>
fn set_block_height(&mut self, height: u32)
fn lookup_mapping( &self, program: Option<Symbol>, name: Symbol, ) -> Option<&HashMap<Value, Value>>
fn lookup_mapping_mut( &mut self, program: Option<Symbol>, name: Symbol, ) -> Option<&mut HashMap<Value, Value>>
fn rng(&mut self) -> Option<&mut ChaCha20Rng>
fn pop_value(&mut self) -> Result<Value>
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> !RefUnwindSafe for Cursor<'a>
impl<'a> !Send for Cursor<'a>
impl<'a> !Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> !UnwindSafe for Cursor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more