leo_interpreter::cursor

Struct Cursor

Source
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>

Source

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.

Source

pub fn set_program(&mut self, program: &str)

Source

pub fn current_program(&self) -> Option<Symbol>

Source

pub fn increment_step(&mut self)

Source

fn new_caller(&self) -> Address<TestnetV0>

Source

fn pop_value(&mut self) -> Result<Value>

Source

fn lookup(&self, name: Symbol) -> Option<Value>

Source

pub fn lookup_mapping( &self, program: Option<Symbol>, name: Symbol, ) -> Option<&HashMap<Value, Value>>

Source

pub fn lookup_mapping_mut( &mut self, program: Option<Symbol>, name: Symbol, ) -> Option<&mut HashMap<Value, Value>>

Source

fn lookup_function( &self, program: Symbol, name: Symbol, ) -> Option<FunctionVariant<'a>>

Source

fn set_variable(&mut self, symbol: Symbol, value: Value)

Source

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).

Source

pub fn over(&mut self) -> Result<StepResult>

Step over the current Element.

That is, continue executing until the current Element is finished.

Source

pub fn step_block( &mut self, block: &'a Block, function_body: bool, step: usize, ) -> bool

Source

fn step_statement( &mut self, statement: &'a Statement, step: usize, ) -> Result<bool>

Source

fn step_expression( &mut self, expression: &'a Expression, step: usize, ) -> Result<bool>

Source

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.

Source

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<'_>

Source

fn mapping_by_call_operator( &self, operator: &CallOperator<TestnetV0>, ) -> Option<&HashMap<Value, Value>>

Source

fn get_register(&self, reg: &Register<TestnetV0>) -> &Value

Source

fn set_register(&mut self, reg: Register<TestnetV0>, value: Value)

Source

fn instructions_len(&self) -> usize

Source

fn increment_instruction_index(&mut self)

Source

fn execution_complete(&self) -> bool

Source

fn next_instruction(&self) -> Option<&Instruction<TestnetV0>>

Source

fn next_command(&self) -> Option<&Command<TestnetV0>>

Source

fn operand_value(&self, operand: &Operand<TestnetV0>) -> Value

Source

fn step_aleo_instruction( &mut self, instruction: Instruction<TestnetV0>, ) -> Result<()>

Source

fn outputs(&self) -> Vec<Value>

Source

fn step_aleo_command(&mut self, command: Command<TestnetV0>) -> Result<()>

Source

fn branch(&mut self, label: &Identifier<TestnetV0>)

Source

pub fn step_aleo(&mut self) -> Result<()>

Trait Implementations§

Source§

impl<'a> Clone for Cursor<'a>

Source§

fn clone(&self) -> Cursor<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CoreFunctionHelper for Cursor<'_>

Source§

fn pop_value_impl(&mut self) -> Option<Value>

Source§

fn set_block_height(&mut self, height: u32)

Source§

fn lookup_mapping( &self, program: Option<Symbol>, name: Symbol, ) -> Option<&HashMap<Value, Value>>

Source§

fn lookup_mapping_mut( &mut self, program: Option<Symbol>, name: Symbol, ) -> Option<&mut HashMap<Value, Value>>

Source§

fn rng(&mut self) -> Option<&mut ChaCha20Rng>

Source§

fn pop_value(&mut self) -> Result<Value>

Source§

impl<'a> Debug for Cursor<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more