pub struct Env { /* private fields */ }
Expand description
The environment at some point in time during the declaration of OCaml bindings. It ensures that types cannot be declared twice, and that types that are renamed and/or relocated into module are referenced correctly.
Implementations§
source§impl Env
impl Env
sourcepub fn new_type(&mut self, ty: u128, name: &'static str)
pub fn new_type(&mut self, ty: u128, name: &'static str)
Declares a new type. If the type was already declared, this will panic.
Panics
The function will panic if the type was already declared.
sourcepub fn get_type(&self, ty: u128, name: &str) -> (String, bool)
pub fn get_type(&self, ty: u128, name: &str) -> (String, bool)
Retrieves a type that was declared previously. A boolean indicates if the type is being aliased.
Panics
The function will panic if the type was not declared previously.
sourcepub fn add_alias(&mut self, ty: u128, alias: &'static str)
pub fn add_alias(&mut self, ty: u128, alias: &'static str)
Adds a new alias for the current scope (module).
Panics
The function will panic if the alias was already declared.
sourcepub fn new_module(&mut self, mod_name: &'static str) -> String
pub fn new_module(&mut self, mod_name: &'static str) -> String
Create a module and enters it.
Panics
This function will panic if the module was already declared, or if the module name is not following the OCaml guidelines.