pub struct Environment {
pub builtin_dtables: BuiltinDispatchTables,
/* private fields */
}Expand description
An environment containing information about declared globals, functions, vtables.
Fields§
§builtin_dtables: BuiltinDispatchTablesDispatch tables for builtin types.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn new(builtin_dtables: BuiltinDispatchTables) -> Self
pub fn new(builtin_dtables: BuiltinDispatchTables) -> Self
Creates a new, empty environment.
Sourcepub fn create_global(&mut self, name: &str) -> Result<Opr24, ErrorKind>
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.
Sourcepub fn get_global(&self, name: &str) -> Option<Opr24>
pub fn get_global(&self, name: &str) -> Option<Opr24>
Tries to look up a global. Returns None if the global doesn’t exist.
Sourcepub fn create_function(
&mut self,
function: Function,
) -> Result<Opr24, ErrorKind>
pub fn create_function( &mut self, function: Function, ) -> Result<Opr24, ErrorKind>
Creates a function and returns its ID.
Sourcepub fn get_method_index(
&mut self,
signature: &FunctionSignature,
) -> Result<u16, ErrorKind>
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.
Sourcepub fn get_method_signature(
&self,
method_index: u16,
) -> Option<&FunctionSignature>
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.
Sourcepub fn create_trait(&mut self, name: Rc<str>) -> Result<Opr24, ErrorKind>
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.
Sourcepub fn get_trait(&self, id: Opr24) -> Option<&TraitPrototype>
pub fn get_trait(&self, id: Opr24) -> Option<&TraitPrototype>
Returns a reference to the trait with the given ID.
Sourcepub fn get_trait_mut(&mut self, id: Opr24) -> Option<&mut TraitPrototype>
pub fn get_trait_mut(&mut self, id: Opr24) -> Option<&mut TraitPrototype>
Returns a mutable reference to the trait with the given ID.