ppvm_vihaco::bytecode
bytecode¶
ppvm_vihaco::bytecode
Binary bytecode (`.ssb`) round-trip for PPVM modules.
Serializes a resolved [`Module`] to a little-endian container — header (magic + version + device info) → strings section → code section — and reads it back. The per-instruction codec is the existing `WriteBytes` / `FromBytes` generated for PPVMInstruction; this module only frames the container around it.
propertyPPVM_BYTECODE_VERSION¶
ppvm_vihaco::bytecode::PPVM_BYTECODE_VERSION
pub const PPVM_BYTECODE_VERSION: u16Current `.ssb` format version. The reader rejects any other version.
functioncompile_to_bytes¶source
ppvm_vihaco::bytecode::compile_to_bytes
pub fn compile_to_bytes(source: &str) -> Result<Vec<u8>>Parameters
| Name | Type | Description |
|---|---|---|
source | &str |
Returns
Result<Vec<u8>>
“Dump”: compile `.sst` source straight to the `.ssb` byte stream.
sourcefunctionis_bytecode¶source
ppvm_vihaco::bytecode::is_bytecode
pub fn is_bytecode(bytes: &[u8]) -> boolParameters
| Name | Type | Description |
|---|---|---|
bytes | &[u8] |
Returns
bool
Cheap sniff: does this byte stream begin with the PPVM `.ssb` magic?
Reads the leading four bytes the same way read_module does — as a little-endian `u32` — so a positive result here means read_module will accept the magic. A stream shorter than the magic is not bytecode.
sourcefunctionmodule_from_bytes¶source
ppvm_vihaco::bytecode::module_from_bytes
pub fn module_from_bytes(bytes: &[u8]) -> Result<PPVMModule>Parameters
| Name | Type | Description |
|---|---|---|
bytes | &[u8] |
Returns
Result<PPVMModule>
Reconstruct a module from a byte slice.
sourcefunctionmodule_to_bytes¶source
ppvm_vihaco::bytecode::module_to_bytes
pub fn module_to_bytes(module: &PPVMModule) -> Result<Vec<u8>>Parameters
| Name | Type | Description |
|---|---|---|
module | &PPVMModule |
Returns
Result<Vec<u8>>
Serialize a module to an owned byte vector.
sourcefunctionread_module¶source
ppvm_vihaco::bytecode::read_module
pub fn read_module<R: Read>(r: &mut R) -> Result<PPVMModule>Parameters
| Name | Type | Description |
|---|---|---|
r | &mut R |
Returns
Result<PPVMModule>
Reconstruct a module from a v2 `.ssb` byte stream.
sourcefunctionwrite_module¶source
ppvm_vihaco::bytecode::write_module
Signature
pub fn write_module<W: Write>(module: &PPVMModule, w: &mut W) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
module | &PPVMModule | |
w | &mut W |
Returns
Result<()>
Serialize a resolved module to the v2 `.ssb` byte stream.
source