Environment

Struct Environment 

Source
pub struct Environment {
    pub builtin_dtables: BuiltinDispatchTables,
    /* private fields */
}
Expand description

An environment containing information about declared globals, functions, vtables.

Fields§

§builtin_dtables: BuiltinDispatchTables

Dispatch tables for builtin types.

Implementations§

Source§

impl Environment

Source

pub fn new(builtin_dtables: BuiltinDispatchTables) -> Self

Creates a new, empty environment.

Source

pub fn create_global(&mut self, name: &str) -> Result<Opr24, ErrorKind>

Tries to create a global. Returns the global slot number, or an error if there are too many globals.

Source

pub fn get_global(&self, name: &str) -> Option<Opr24>

Tries to look up a global. Returns None if the global doesn’t exist.

Source

pub fn create_function( &mut self, function: Function, ) -> Result<Opr24, ErrorKind>

Creates a function and returns its ID.

Source

pub fn get_method_index( &mut self, signature: &FunctionSignature, ) -> Result<u16, ErrorKind>

Tries to look up the index of a method, based on a function signature. Returns None if there are too many function signatures in this environment.

Source

pub fn get_method_signature( &self, method_index: u16, ) -> Option<&FunctionSignature>

Returns the signature for the method with the given ID, or None if the method index is invalid.

Source

pub fn create_trait(&mut self, name: Rc<str>) -> Result<Opr24, ErrorKind>

Creates a trait and returns its ID. Use get_trait_mut afterwards to modify the trait.

Source

pub fn get_trait(&self, id: Opr24) -> Option<&TraitPrototype>

Returns a reference to the trait with the given ID.

Source

pub fn get_trait_mut(&mut self, id: Opr24) -> Option<&mut TraitPrototype>

Returns a mutable reference to the trait with the given ID.

Trait Implementations§

Source§

impl Debug for Environment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.