pub struct Bytecode {
Show 15 fields pub version: u8, pub entrypoint: RefFun, pub ints: Vec<i32>, pub floats: Vec<f64>, pub strings: Vec<String>, pub bytes: Option<(Vec<u8>, Vec<usize>)>, pub debug_files: Option<Vec<String>>, pub types: Vec<Type>, pub globals: Vec<RefType>, pub natives: Vec<Native>, pub functions: Vec<Function>, pub constants: Option<Vec<ConstantDef>>, pub findexes: Vec<RefFunKnown>, pub fnames: HashMap<String, usize>, pub globals_initializers: HashMap<RefGlobal, usize>,
}
Expand description

Bytecode structure containing all the information. Every field is public for flexibility, but you aren’t encouraged to modify them.

We try to keep optimizations, and acceleration structures separated from the main data.

Fields

version: u8

Bytecode format version

entrypoint: RefFun

Program entrypoint

ints: Vec<i32>

i32 constant pool

floats: Vec<f64>

f64 constant pool

strings: Vec<String>

String constant pool

bytes: Option<(Vec<u8>, Vec<usize>)>

Bytes constant pool

Since bytecode v5

debug_files: Option<Vec<String>>

Debug file names constant pool

types: Vec<Type>

Types, contains every possible types expressed in the program

globals: Vec<RefType>

Globals, holding static variables and such

natives: Vec<Native>

Native functions references

functions: Vec<Function>

Code functions pool

constants: Option<Vec<ConstantDef>>

Constants, initializers for globals

Since bytecode v4

findexes: Vec<RefFunKnown>

Acceleration structure mapping function references (findex) to functions indexes in the native or function pool.

fnames: HashMap<String, usize>

Acceleration structure mapping function names to function indexes in the function pool

globals_initializers: HashMap<RefGlobal, usize>

Implementations

Iterate on every instruction of every function

Load the bytecode from any source. Must be a valid hashlink bytecode binary.

Serialize the bytecode to any sink. Bytecode is serialized to the same format.

Get the entrypoint function.

Get the main function. This will panic if there is no main function in the bytecode (there should always be one)

Get a function by its name.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.