RunnableCode

Trait RunnableCode 

Source
pub trait RunnableCode {
    // Required methods
    fn num_params(&self) -> u32;
    fn num_registers(&self) -> u32;
    fn constants(&self) -> &[i64];
    fn type_idx(&self) -> TypeIndex;
    fn return_type(&self) -> BlockType;
    fn params(&self) -> &[ValueType];
    fn num_locals(&self) -> u32;
    fn locals(&self) -> LocalsIterator<'_> ;
    fn code(&self) -> &[u8] ;
}
Expand description

A trait encapsulating the properties that are needed to run a function. This trait exists because we have two different kinds of code we run. A fully deserialized code, i.e., where instructions are essentially Vec<InternalOpcode> or we execute directly from &[u8] if the origin of the code is a serialized structure, such as an Artifact retrieved from a database.

Required Methods§

Source

fn num_params(&self) -> u32

The number of parameters of the function.

Source

fn num_registers(&self) -> u32

The number of registers the function needs in the worst case. This includes locals and parameters.

Source

fn constants(&self) -> &[i64]

The number of distinct constants that appear in the function body.

Source

fn type_idx(&self) -> TypeIndex

The type of the function, as an index into the list of types of the module.

Source

fn return_type(&self) -> BlockType

The return type of the function.

Source

fn params(&self) -> &[ValueType]

The types of function parameters.

Source

fn num_locals(&self) -> u32

The number of locals declared by the function. This does not include the function parameters, only declared locals.

Source

fn locals(&self) -> LocalsIterator<'_>

An iterator over the locals (not including function parameters).

Source

fn code(&self) -> &[u8]

A reference to the instructions to execute.

Implementors§