Struct lovm2_core::code::CodeObject [−][src]
CodeObject
contains the bytecode as well as all the data used by it.
The entries
attribute is a vector of name-offset pairs where the first component is an
index into idents
. This information is essential for the run_bytecode function used by
CodeObjectFunction. It shouldn't be necessary to manually alter entries
. By default,
the subprogram named ENTRY_POINT will be at offset 0:
main:
...
ret
add:
...
ret
Values will be returned over the value stack. Every code object has
to return some value on termination. If no value is produced, Nil
is implicitly returned.
Fields
name: String
Name of the object. This is used as the modules name when imported.
loc: Option<String>
Location of objects origin.
uses: Vec<String>
Modules required for executing this object successfully.
entries: Vec<(usize, usize)>
Entry points for the bytecode in the form Vec<(index_into_idents, bytecode_offset)>. These are the functions of the module.
consts: Vec<Value>
Necessary constants.
idents: Vec<Variable>
Necessary identifiers.
code: Vec<Instruction>
Bytecode itself.
Implementations
impl CodeObject
[src]
pub fn new() -> Self
[src]
pub fn load_from_file<T>(path: T) -> Lovm2Result<Self> where
T: AsRef<Path>,
[src]
T: AsRef<Path>,
Tries to load the file as shared object first and falls back to regular deserialization if it failed
pub fn to_bytes(&self) -> Lovm2Result<Vec<u8>>
[src]
Return the objects representation as bytes
pub fn store_to_file<T>(&self, path: T) -> Lovm2Result<()> where
T: AsRef<Path>,
[src]
T: AsRef<Path>,
Write the object to a file at given path
Trait Implementations
impl CallProtocol for CodeObject
[src]
impl Clone for CodeObject
[src]
fn clone(&self) -> CodeObject
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CodeObject
[src]
impl Default for CodeObject
[src]
impl<'de> Deserialize<'de> for CodeObject
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<CodeObject> for Module
[src]
fn from(code_object: CodeObject) -> Self
[src]
impl Serialize for CodeObject
[src]
Auto Trait Implementations
impl !RefUnwindSafe for CodeObject
[src]
impl !Send for CodeObject
[src]
impl !Sync for CodeObject
[src]
impl Unpin for CodeObject
[src]
impl !UnwindSafe for CodeObject
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,