Struct miden_core::code_blocks::Span
source · [−]pub struct Span { /* private fields */ }
Expand description
A code block used to describe a linear sequence of operations (i.e., no branching or loops).
When the VM executes a Span block, it breaks the sequence of operations into batches and groups according to the following rules:
- A group may contain up to 9 operations or a single immediate value.
- An operation carrying an immediate value cannot be in the 9th position in a group.
- A batch may contain up to 8 groups.
- There is no limit on the number of batches contained within a single span.
Thus, for example, executing 8 pushes in a row will result in two operation batches:
- The first batch will contain 8 groups, with the first group containing 7 push opcodes, and the remaining 7 groups containing immediate values for each of the push operations.
- The second batch will contain 2 groups, with the first group containing a single push opcode, and the second group containing the immediate value for the last push operation.
If a sequence of operations does not have any operations which carry immediate values, then up to 72 operations can fit into a single batch.
TODO: describe how Span hash is computed.
Implementations
sourceimpl Span
impl Span
sourcepub fn new(operations: Vec<Operation>) -> Self
pub fn new(operations: Vec<Operation>) -> Self
Returns a new Span block instantiated with the specified operations.
Errors (TODO)
Returns an error if:
operations
vector is empty.operations
vector contains any number of system operations.
sourcepub fn with_decorators(
operations: Vec<Operation>,
decorators: DecoratorList
) -> Self
pub fn with_decorators(
operations: Vec<Operation>,
decorators: DecoratorList
) -> Self
Returns a new Span block instantiated with the specified operations and decorators.
Errors (TODO)
Returns an error if:
operations
vector is empty.operations
vector contains any number of system operations.
sourcepub fn op_batches(&self) -> &[OpBatch]
pub fn op_batches(&self) -> &[OpBatch]
Returns list of operation batches contained in this span block.
sourcepub fn replicate(&self, num_copies: usize) -> Self
pub fn replicate(&self, num_copies: usize) -> Self
Returns a new Span block instantiated with operations from this block repeated the specified number of times.
sourcepub fn decorators(&self) -> &DecoratorList
pub fn decorators(&self) -> &DecoratorList
Returns a list of decorators in this span block
sourcepub fn decorator_iter(&self) -> DecoratorIterator<'_>
pub fn decorator_iter(&self) -> DecoratorIterator<'_>
Returns a DecoratorIterator which allows us to iterate through the decorator list of this span block while executing operation batches of this span block
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more