pub struct Program {
pub instructions: Vec<Instruction>,
}Expand description
A Program is a Vec<Instruction> that contains duplicate elements for instructions with a
size of 2. This means that the index in the vector corresponds to the VM’s
instruction_pointer. These duplicate values should most often be skipped/ignored,
e.g. when pretty-printing.
Fields§
§instructions: Vec<Instruction>Implementations§
Source§impl Program
impl Program
Sourcepub fn new(input: &[LabelledInstruction]) -> Self
pub fn new(input: &[LabelledInstruction]) -> Self
Create a Program from a slice of Instruction.
Sourcepub fn to_bwords(&self) -> Vec<BFieldElement>
pub fn to_bwords(&self) -> Vec<BFieldElement>
Convert a Program to a Vec<BFieldElement>.
Every single-word instruction is converted to a single word.
Every double-word instruction is converted to two words.
Sourcepub fn len_bwords(&self) -> usize
pub fn len_bwords(&self) -> usize
The total length of the program as BFieldElements. Double-word instructions contribute
two BFieldElements.
pub fn is_empty(&self) -> bool
Sourcepub fn hash<H: AlgebraicHasher>(&self) -> Digest
pub fn hash<H: AlgebraicHasher>(&self) -> Digest
Hash the program using the given AlgebraicHasher.
Trait Implementations§
Source§impl BFieldCodec for Program
impl BFieldCodec for Program
Source§impl<'de> Deserialize<'de> for Program
impl<'de> Deserialize<'de> for Program
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl GetSize for Program
impl GetSize for Program
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Determines how many bytes this object occupies inside the heap. Read more
Source§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Determines how may bytes this object occupies inside the stack. Read more
Source§impl IntoIterator for Program
impl IntoIterator for Program
Source§type Item = AnInstruction<BFieldElement>
type Item = AnInstruction<BFieldElement>
The type of the elements being iterated over.
Source§type IntoIter = InstructionIter
type IntoIter = InstructionIter
Which kind of iterator are we turning this into?
impl Eq for Program
impl StructuralPartialEq for Program
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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 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>
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