[][src]Struct runestick::unit::Unit

pub struct Unit { /* fields omitted */ }

Instructions from a single source file.

Implementations

impl Unit[src]

pub fn new() -> Self[src]

Construct a new unit.

pub fn with_default_prelude() -> Self[src]

Construct a new unit with the default prelude.

pub fn contains_name(&self, item: &Item) -> bool[src]

Check if unit contains the given name.

pub fn contains_prefix(&self, item: &Item) -> bool[src]

Check if unit contains the given name by prefix.

pub fn iter_components<I>(&self, iter: I) -> impl Iterator<Item = &Component> where
    I: IntoIterator,
    I::Item: Into<Component>, 
[src]

Iterate over known child components of the given name.

pub fn lookup_meta(&self, name: &Item) -> Option<Meta>[src]

Access the meta for the given language item.

pub fn lookup_type(&self, hash: Hash) -> Option<&UnitTypeInfo>[src]

Access the type for the given language item.

pub fn function_at(&self, n: usize) -> Option<(Hash, &UnitFnInfo)>[src]

Access the function at the given instruction location.

pub fn debug_info(&self) -> Option<&DebugInfo>[src]

Access debug information for the given location if it is available.

pub fn debug_info_mut(&mut self) -> &mut DebugInfo[src]

Insert and access a builder for debug information.

pub fn instruction_at(&self, ip: usize) -> Option<&Inst>[src]

Get the instruction at the given instruction pointer.

pub fn iter_static_strings(
    &self
) -> impl Iterator<Item = &Arc<StaticString>> + '_
[src]

Iterate over all static strings in the unit.

pub fn iter_static_object_keys(
    &self
) -> impl Iterator<Item = (Hash, &[String])> + '_
[src]

Iterate over all static object keys in the unit.

pub fn iter_instructions(&self) -> impl Iterator<Item = Inst> + '_[src]

Iterate over all instructions in order.

pub fn iter_functions(
    &self
) -> impl Iterator<Item = (Hash, &Arc<UnitFnInfo>)> + '_
[src]

Iterate over known functions.

pub fn iter_imports<'a>(
    &'a self
) -> impl Iterator<Item = (&'a ImportKey, &'a ImportEntry)> + '_
[src]

Iterate over known imports.

pub fn lookup_string(&self, slot: usize) -> Result<&Arc<StaticString>, VmError>[src]

Lookup the static string by slot, if it exists.

pub fn lookup_bytes(&self, slot: usize) -> Result<&[u8], VmError>[src]

Lookup the static byte string by slot, if it exists.

pub fn lookup_object_keys(&self, slot: usize) -> Option<&[String]>[src]

Lookup the static object keys by slot, if it exists.

pub fn new_static_string(&mut self, current: &str) -> Result<usize, UnitError>[src]

Insert a static string and return its associated slot that can later be looked up through lookup_string.

Only uses up space if the static string is unique.

pub fn new_static_bytes(&mut self, current: &[u8]) -> Result<usize, UnitError>[src]

Insert a static byte string and return its associated slot that can later be looked up through lookup_bytes.

Only uses up space if the static byte string is unique.

pub fn new_static_object_keys(
    &mut self,
    current: &[String]
) -> Result<usize, UnitError>
[src]

Insert a new collection of static object keys, or return one already existing.

pub fn lookup(&self, hash: Hash) -> Option<&Arc<UnitFnInfo>>[src]

Lookup information of a function.

pub fn lookup_import(&self, key: &ImportKey) -> Option<&ImportEntry>[src]

Look up an use by name.

pub fn new_import<I>(
    &mut self,
    item: Item,
    path: I,
    span: Span
) -> Result<(), UnitError> where
    I: Copy + IntoIterator,
    I::Item: Into<Component>, 
[src]

Declare a new import.

pub fn insert_meta(&mut self, meta: Meta) -> Result<(), UnitError>[src]

Declare a new struct.

pub fn new_assembly(&self) -> Assembly[src]

Construct a new empty assembly associated with the current unit.

pub fn new_function(
    &mut self,
    source_id: usize,
    path: Item,
    args: usize,
    assembly: Assembly,
    call: Call
) -> Result<(), UnitError>
[src]

Declare a new function at the current instruction pointer.

pub fn new_instance_function(
    &mut self,
    source_id: usize,
    path: Item,
    value_type: ValueType,
    name: &str,
    args: usize,
    assembly: Assembly,
    call: Call
) -> Result<(), UnitError>
[src]

Declare a new instance function at the current instruction pointer.

Try to link the unit with the context, checking that all necessary functions are provided.

This can prevent a number of runtime errors, like missing functions.

Trait Implementations

impl Debug for Unit[src]

impl Default for Unit[src]

Auto Trait Implementations

impl RefUnwindSafe for Unit

impl Send for Unit

impl Sync for Unit

impl Unpin for Unit

impl UnwindSafe for Unit

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,