pub struct Program {
pub instructions: Vec<AnInstruction<BFieldElement>>,
/* private fields */
}
Expand description
A program for Triton VM. Triton VM can run and profile such programs, and trace its execution in order to generate a proof of correct execution. See there for details.
A program may contain debug information, such as label names and breakpoints.
Access this information through methods label_for_address()
and
is_breakpoint()
. Some operations, most notably
BField-encoding, discard this debug information.
Fields§
§instructions: Vec<AnInstruction<BFieldElement>>
Implementations§
Source§impl Program
impl Program
pub fn new(labelled_instructions: &[LabelledInstruction]) -> Program
Sourcepub fn from_code(code: &str) -> Result<Program, ParseError<'_>>
pub fn from_code(code: &str) -> Result<Program, ParseError<'_>>
Create a Program
by parsing source code.
pub fn labelled_instructions(&self) -> Vec<LabelledInstruction>
pub fn is_breakpoint(&self, address: u64) -> bool
pub fn type_hints_at(&self, address: u64) -> Vec<TypeHint>
pub fn assertion_context_at(&self, address: u64) -> Option<AssertionContext>
Sourcepub fn to_bwords(&self) -> Vec<BFieldElement>
pub fn to_bwords(&self) -> Vec<BFieldElement>
Sourcepub fn len_bwords(&self) -> usize
pub fn len_bwords(&self) -> usize
The total length of the program as BFieldElement
s. Double-word instructions contribute
two BFieldElement
s.
pub fn is_empty(&self) -> bool
Sourcepub fn hash(&self) -> Digest
pub fn hash(&self) -> Digest
Produces the program’s canonical hash digest. Uses Tip5
, the
canonical hash function for Triton VM.
Sourcepub fn label_for_address(&self, address: u64) -> String
pub fn label_for_address(&self, address: u64) -> String
The label for the given address, or a deterministic, unique substitute if no label is found.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Program
impl<'a> Arbitrary<'a> for Program
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Program, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Program, Error>
Generate an arbitrary value of
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moreSource§impl BFieldCodec for Program
impl BFieldCodec for Program
type Error = ProgramDecodingError
fn decode( sequence: &[BFieldElement], ) -> Result<Box<Program>, <Program as BFieldCodec>::Error>
fn encode(&self) -> Vec<BFieldElement>
Source§fn static_length() -> Option<usize>
fn static_length() -> Option<usize>
Returns the length in number of BFieldElements if it is known at compile-time.
Otherwise, None.
Source§impl<'de> Deserialize<'de> for Program
impl<'de> Deserialize<'de> for Program
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Program, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Program, <__D as Deserializer<'de>>::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?
Source§impl Serialize for Program
impl Serialize for Program
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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