leo_interpreter::core_functions

Trait CoreFunctionHelper

Source
pub trait CoreFunctionHelper {
    // Required method
    fn pop_value_impl(&mut self) -> Option<Value>;

    // Provided methods
    fn pop_value(&mut self) -> Result<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> { ... }
}
Expand description

A context in which we can evaluate core functions.

This is intended to be implemented by Cursor, which will be used during execution of the interpreter, and by Vec<Value>, which will be used during compile time evaluation for constant folding.

The default implementations for rng, set_block_height, and mapping lookup do nothing, as those features will not be available during compile time evaluation.

Required Methods§

Provided Methods§

Source

fn pop_value(&mut self) -> Result<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>

Implementations on Foreign Types§

Source§

impl CoreFunctionHelper for Vec<Value>

Implementors§