Struct polkavm_common::program::ProgramBlob
source · pub struct ProgramBlob<'a> { /* private fields */ }Expand description
A partially deserialized PolkaVM program.
Implementations§
source§impl<'a> ProgramBlob<'a>
impl<'a> ProgramBlob<'a>
sourcepub fn parse(bytes: impl Into<CowBytes<'a>>) -> Result<Self, ProgramParseError>
pub fn parse(bytes: impl Into<CowBytes<'a>>) -> Result<Self, ProgramParseError>
Parses the given bytes into a program blob.
sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Returns the original bytes from which this program blob was created from.
sourcepub fn stack_size(&self) -> u32
pub fn stack_size(&self) -> u32
Returns the initial size of the stack.
sourcepub fn instruction_count(&self) -> u32
pub fn instruction_count(&self) -> u32
Returns the number of instructions the code section should contain.
NOTE: It is safe to preallocate memory based on this value as we make sure that it is no larger than the the physical size of the code section, however we do not verify that it is actually true, so it should not be blindly trusted!
sourcepub fn basic_block_count(&self) -> u32
pub fn basic_block_count(&self) -> u32
Returns the number of basic blocks the code section should contain.
NOTE: It is safe to preallocate memory based on this value as we make sure that it is no larger than the the physical size of the code section, however we do not verify that it is actually true, so it should not be blindly trusted!
sourcepub fn imports(
&self
) -> impl Iterator<Item = Result<ProgramImport<'_>, ProgramParseError>> + Clone + '_
pub fn imports( &self ) -> impl Iterator<Item = Result<ProgramImport<'_>, ProgramParseError>> + Clone + '_
Returns an iterator over program imports.
sourcepub fn exports(
&self
) -> impl Iterator<Item = Result<ProgramExport<'_>, ProgramParseError>> + Clone + '_
pub fn exports( &self ) -> impl Iterator<Item = Result<ProgramExport<'_>, ProgramParseError>> + Clone + '_
Returns an iterator over program exports.
sourcepub fn instructions(
&self
) -> impl Iterator<Item = Result<Instruction, ProgramParseError>> + Clone + '_
pub fn instructions( &self ) -> impl Iterator<Item = Result<Instruction, ProgramParseError>> + Clone + '_
Returns an iterator over program instructions.
sourcepub fn jump_table_upper_bound(&self) -> usize
pub fn jump_table_upper_bound(&self) -> usize
The upper bound of how many entries there might be in this program’s jump table, excluding the very first implicit entry.
sourcepub fn jump_table(
&self
) -> impl Iterator<Item = Result<u32, ProgramParseError>> + Clone + '_
pub fn jump_table( &self ) -> impl Iterator<Item = Result<u32, ProgramParseError>> + Clone + '_
Returns an iterator over the jump table entries, excluding the very first implicit entry.
sourcepub fn get_debug_string(&self, offset: u32) -> Result<&str, ProgramParseError>
pub fn get_debug_string(&self, offset: u32) -> Result<&str, ProgramParseError>
Returns the debug string for the given relative offset.
sourcepub fn get_debug_line_program_at(
&self,
nth_instruction: u32
) -> Result<Option<LineProgram<'_>>, ProgramParseError>
pub fn get_debug_line_program_at( &self, nth_instruction: u32 ) -> Result<Option<LineProgram<'_>>, ProgramParseError>
Returns the line program for the given instruction.
Trait Implementations§
source§impl<'a> Clone for ProgramBlob<'a>
impl<'a> Clone for ProgramBlob<'a>
source§fn clone(&self) -> ProgramBlob<'a>
fn clone(&self) -> ProgramBlob<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more