Skip to content

vihaco_bytecode (crate)

vihaco_bytecode

vihaco_bytecode

classBytecodeFilesource

vihaco_bytecode::BytecodeFile

Bases: Debug, Clone

Rust struct. A parsed bytecode file.

pub struct BytecodeFile<C>
source

methodcontextsource

vihaco_bytecode::BytecodeFile::context

pub fn context(&self) -> &C

Returns

&C

source

methodcontext_handlesource

vihaco_bytecode::BytecodeFile::context_handle

pub fn context_handle(&self) -> ContextHandle<C>

Returns

ContextHandle<C>

source

methodfrom_bytessource

vihaco_bytecode::BytecodeFile::from_bytes

pub fn from_bytes(bytes: Vec<u8>) -> Result<Self>

Parameters

NameTypeDescription
bytesVec&lt;u8&gt;

Returns

Result<Self>

Parse a bytecode file from bytes.

source

methodrootsource

vihaco_bytecode::BytecodeFile::root

pub fn root(&self) -> BytecodeSectionView<'_, C>

Returns

BytecodeSectionView<'_, C>

The view of the root of the bytecode section tree.

source

classBytecodeSectionViewsource

vihaco_bytecode::BytecodeSectionView

Bases: Clone, Debug

Rust struct. A lightweight view into a parsed bytecode section.

pub struct BytecodeSectionView<'bc, C>
source

methodbytecodesource

vihaco_bytecode::BytecodeSectionView::bytecode

pub fn bytecode(&self) -> &'bc [u8]

Returns

&'bc [u8]

source

methodchildsource

vihaco_bytecode::BytecodeSectionView::child

Signature
pub fn child(&self, local_name: &str) -> Option<BytecodeSectionView<'bc, C>>

Parameters

NameTypeDescription
local_name&amp;str

Returns

Option<BytecodeSectionView<'bc, C>>

source

methodchildrensource

vihaco_bytecode::BytecodeSectionView::children

pub fn children(&self) -> impl Iterator + '_

Returns

impl Iterator + '_

source

methodcontext_handlesource

vihaco_bytecode::BytecodeSectionView::context_handle

pub fn context_handle(&self) -> ContextHandle<C>

Returns

ContextHandle<C>

source

methoddecode_headersource

vihaco_bytecode::BytecodeSectionView::decode_header

pub fn decode_header<H: BytecodeHeader>(&self) -> Result<H>

Returns

Result<H>

Decode the specified composite header from raw header bytes.

source

methoddecode_instructionssource

vihaco_bytecode::BytecodeSectionView::decode_instructions

pub fn decode_instructions<I: Instruction>(&self) -> Result<Vec<I>>

Returns

Result<Vec<I>>

Decode this section’s bytecode body as an instruction stream.

source

methoddisplay_pathsource

vihaco_bytecode::BytecodeSectionView::display_path

pub fn display_path(&self) -> &'bc SectionPath

Returns

&'bc SectionPath

source

methodheader_bytessource

vihaco_bytecode::BytecodeSectionView::header_bytes

pub fn header_bytes(&self) -> &'bc [u8]

Returns

&'bc [u8]

source

methodlocal_namesource

vihaco_bytecode::BytecodeSectionView::local_name

pub fn local_name(&self) -> Option<&str>

Returns

Option<&str>

source

methodpathsource

vihaco_bytecode::BytecodeSectionView::path

pub fn path(&self) -> &'bc SectionPath

Returns

&'bc SectionPath

source

classConstantIdsource

vihaco_bytecode::ConstantId

Bases: Debug, Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, From&lt;u32&gt;, From&lt;ConstantId&gt;, FromBytes, WriteBytes, OpCode, Display

Rust struct.

pub struct ConstantId

Fields

NameTypeDescription
0u32
source

classContextHandlesource

vihaco_bytecode::ContextHandle

Bases: Debug, Clone, Deref

Rust struct. The public handle for a global context.

pub struct ContextHandle<C>

To avoid needing explicit lifetimes permeating throughout machine definitions, we wrap the context in an Arc to drop it automatically.

source

methodgetsource

vihaco_bytecode::ContextHandle::get

pub fn get(&self) -> &C

Returns

&C

source

methodnewsource

vihaco_bytecode::ContextHandle::new

pub fn new(context: C) -> Self

Parameters

NameTypeDescription
contextC

Returns

Self

source

methodptr_eqsource

vihaco_bytecode::ContextHandle::ptr_eq

pub fn ptr_eq(&self, other: &Self) -> bool

Parameters

NameTypeDescription
other&amp;Self

Returns

bool

source

classNoContextsource

vihaco_bytecode::NoContext

Bases: Debug, Clone, Copy, Default, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, SstGlobalContext

Rust struct. Marker context for SST files that do not carry global metadata.

pub struct NoContext

`NoContext` accepts an omitted or empty global section.

source

classSectionPathsource

vihaco_bytecode::SectionPath

Bases: Clone, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Display, Debug

Rust struct. The fully resolved path for a parsed section.

pub struct SectionPath

The root section has no components.

source

methodcomponentssource

vihaco_bytecode::SectionPath::components

pub fn components(&self) -> &[String]

Returns

&[String]

source

methodis_rootsource

vihaco_bytecode::SectionPath::is_root

pub fn is_root(&self) -> bool

Returns

bool

source

methodlocal_namesource

vihaco_bytecode::SectionPath::local_name

pub fn local_name(&self) -> Option<&str>

Returns

Option<&str>

source

methodrootsource

vihaco_bytecode::SectionPath::root

pub fn root() -> Self

Returns

Self

source

classSstFilesource

vihaco_bytecode::SstFile

Bases: Debug, Clone

Rust struct. A parsed SST file.

pub struct SstFile<C>
source

methodcontextsource

vihaco_bytecode::SstFile::context

pub fn context(&self) -> &C

Returns

&C

source

methodcontext_handlesource

vihaco_bytecode::SstFile::context_handle

pub fn context_handle(&self) -> ContextHandle<C>

Returns

ContextHandle<C>

source

methodfrom_textsource

vihaco_bytecode::SstFile::from_text

pub fn from_text(text: &str) -> Result<Self>

Parameters

NameTypeDescription
text&amp;str

Returns

Result<Self>

Parse an SST file from text.

source

methodrootsource

vihaco_bytecode::SstFile::root

pub fn root(&self) -> SstSectionView<'_, C>

Returns

SstSectionView<'_, C>

The view of the root of the SST section tree.

source

classSstSectionViewsource

vihaco_bytecode::SstSectionView

Bases: Clone, Debug

Rust struct. A lightweight view into a parsed SST section.

pub struct SstSectionView<'bc, C>
source

methodchildsource

vihaco_bytecode::SstSectionView::child

pub fn child(&self, local_name: &str) -> Option<SstSectionView<'bc, C>>

Parameters

NameTypeDescription
local_name&amp;str

Returns

Option<SstSectionView<'bc, C>>

source

methodchildrensource

vihaco_bytecode::SstSectionView::children

pub fn children(&self) -> impl Iterator + '_

Returns

impl Iterator + '_

source

methodcontext_handlesource

vihaco_bytecode::SstSectionView::context_handle

pub fn context_handle(&self) -> ContextHandle<C>

Returns

ContextHandle<C>

source

methoddisplay_pathsource

vihaco_bytecode::SstSectionView::display_path

pub fn display_path(&self) -> &'bc SectionPath

Returns

&'bc SectionPath

source

methodheader_textsource

vihaco_bytecode::SstSectionView::header_text

pub fn header_text(&self) -> &'bc str

Returns

&'bc str

source

methodlocal_namesource

vihaco_bytecode::SstSectionView::local_name

pub fn local_name(&self) -> Option<&str>

Returns

Option<&str>

source

methodparse_headersource

vihaco_bytecode::SstSectionView::parse_header

pub fn parse_header<H: SstHeader>(&self) -> Result<H>

Returns

Result<H>

Parse the specified composite header from SST header text.

source

methodpathsource

vihaco_bytecode::SstSectionView::path

pub fn path(&self) -> &'bc SectionPath

Returns

&'bc SectionPath

source

methodsstsource

vihaco_bytecode::SstSectionView::sst

pub fn sst(&self) -> &'bc str

Returns

&'bc str

source

classBytecodeGlobalContextsource

vihaco_bytecode::BytecodeGlobalContext

Rust trait. A global context that can be decoded from bytecode.

pub trait BytecodeGlobalContext: Sized + SectionNameResolver
source

methodfrom_bytessource

vihaco_bytecode::BytecodeGlobalContext::from_bytes

fn from_bytes(bytes: &[u8]) -> Result<Self>

Parameters

NameTypeDescription
bytes&amp;[u8]

Returns

Result<Self>

source

classBytecodeHeadersource

vihaco_bytecode::BytecodeHeader

Rust trait.

pub trait BytecodeHeader: Sized + FromBytes
source

classGlobalContextsource

vihaco_bytecode::GlobalContext

Rust trait. A global context that supports both bytecode and SST representations.

pub trait GlobalContext: BytecodeGlobalContext + SstGlobalContext
source

classSectionNameResolversource

vihaco_bytecode::SectionNameResolver

Rust trait. Resolve section-name indexes stored in bytecode files.

pub trait SectionNameResolver

Bytecode child section entries store section names indirectly, so parsing a bytecode file needs a context object that can resolve those indexes.

source

methodsection_namesource

vihaco_bytecode::SectionNameResolver::section_name

fn section_name(&self, index: u32) -> Option<&str>

Parameters

NameTypeDescription
indexu32

Returns

Option<&str>

source

classSstGlobalContextsource

vihaco_bytecode::SstGlobalContext

Rust trait. A global context that can be parsed from SST text.

pub trait SstGlobalContext: Sized
source

methodfrom_textsource

vihaco_bytecode::SstGlobalContext::from_text

fn from_text(text: &str) -> Result<Self>

Parameters

NameTypeDescription
text&amp;str

Returns

Result<Self>

source

classSstHeadersource

vihaco_bytecode::SstHeader

Rust trait.

pub trait SstHeader: Sized + FromText
source

classWriteBytecodeHeadersource

vihaco_bytecode::WriteBytecodeHeader

Rust trait.

pub trait WriteBytecodeHeader: WriteBytes
source

propertyFLAGS

vihaco_bytecode::FLAGS

pub const FLAGS: u16

propertyMAGIC

vihaco_bytecode::MAGIC

pub const MAGIC: &[u8; 4]

propertyVERSION

vihaco_bytecode::VERSION

pub const VERSION: u16

functiondecode_instruction_streamsource

vihaco_bytecode::decode_instruction_stream

Signature
pub fn decode_instruction_stream<I: Instruction>(bytes: &[u8]) -> Result<Vec<I>>

Parameters

NameTypeDescription
bytes&amp;[u8]

Returns

Result<Vec<I>>

source