[−][src]Struct ketos::scope::GlobalScope
Represents the global namespace of an execution context.
Methods
impl GlobalScope
[src]
pub fn new(
name: Name,
names: Rc<RefCell<NameStore>>,
codemap: Rc<RefCell<CodeMap>>,
registry: Rc<ModuleRegistry>,
io: Rc<GlobalIo>,
struct_defs: Rc<RefCell<StructDefMap>>
) -> GlobalScope
[src]
name: Name,
names: Rc<RefCell<NameStore>>,
codemap: Rc<RefCell<CodeMap>>,
registry: Rc<ModuleRegistry>,
io: Rc<GlobalIo>,
struct_defs: Rc<RefCell<StructDefMap>>
) -> GlobalScope
Creates a new global scope.
pub fn default(name: &str) -> GlobalScope
[src]
Creates a new global scope with the given name and default environment.
pub fn new_using(name: Name, scope: &Scope) -> Scope
[src]
Creates a new global scope using the shared data from the given scope.
pub fn clone_scope(&self) -> Scope
[src]
Creates a semi-"deep" clone of the GlobalScope
object.
All constants, macros, and values will be cloned into the new scope.
Other data will be shared between this scope and the new scope.
pub fn add_constant(&self, name: Name, value: Value)
[src]
Adds a named constant value to the scope.
pub fn add_doc_string(&self, name: Name, doc: String)
[src]
Adds a docstring for the named constant or value.
pub fn add_macro(&self, name: Name, lambda: Lambda)
[src]
Adds a macro function to the global scope.
pub fn add_name(&self, name: &str) -> Name
[src]
Adds a string representation to the contained NameStore
.
pub fn add_imports(&self, imports: ImportSet)
[src]
Adds a set of imports to the given scope.
pub fn add_value(&self, name: Name, value: Value)
[src]
Adds a value to the global scope.
pub fn add_named_value(&self, name: &str, value: Value)
[src]
Adds a value with the given name to the global scope.
pub fn add_value_with_name<F>(&self, name: &str, f: F) where
F: FnOnce(Name) -> Value,
[src]
F: FnOnce(Name) -> Value,
Adds a value to the global scope. The Name
value for the given
string representation is passed to the given closure to create the value.
pub fn borrow_codemap(&self) -> Ref<CodeMap>
[src]
Borrows a reference to the contained CodeMap
.
pub fn borrow_codemap_mut(&self) -> RefMut<CodeMap>
[src]
Borrows a mutable reference to the contained CodeMap
.
pub fn borrow_names(&self) -> Ref<NameStore>
[src]
Borrows a reference to the contained NameStore
.
pub fn borrow_names_mut(&self) -> RefMut<NameStore>
[src]
Borrows a mutable reference to the contained NameStore
.
pub fn num_constants(&self) -> usize
[src]
Returns the number of contained constants.
pub fn num_macros(&self) -> usize
[src]
Returns the number of contained macros.
pub fn num_values(&self) -> usize
[src]
Returns the number of contained values.
pub fn codemap(&self) -> &Rc<RefCell<CodeMap>>
[src]
Returns a borrowed reference to the contained CodeMap
.
pub fn get_constant(&self, name: Name) -> Option<Value>
[src]
Returns a named constant value, if present.
pub fn get_named_constant(&self, name: &str) -> Option<Value>
[src]
Returns a named constant value, if present.
pub fn get_struct_def(&self, id: TypeId) -> Option<Rc<StructDef>>
[src]
Returns a StructDef
for a given type.
pub fn register_struct_value<T: StructValue>(&self)
[src]
Creates a StructDef
for the given type, inserting the definition
into the global namespace.
pub fn io(&self) -> &Rc<GlobalIo>
[src]
Returns a borrowed reference to the contained GlobalIo
.
pub fn modules(&self) -> &Rc<ModuleRegistry>
[src]
Returns a borrowed reference to the contained ModuleRegistry
.
pub fn name(&self) -> Name
[src]
Returns the scope's name.
pub fn names(&self) -> &Rc<RefCell<NameStore>>
[src]
Returns a borrowed reference to the contained NameStore
.
pub fn contains_name(&self, name: Name) -> bool
[src]
Returns whether the scope contains a given exportable name.
pub fn contains_constant(&self, name: Name) -> bool
[src]
Returns whether the scope contains a constant for the given name.
pub fn contains_macro(&self, name: Name) -> bool
[src]
Returns whether the scope contains a macro for the given name.
pub fn contains_value(&self, name: Name) -> bool
[src]
Returns whether the scope contains a value for the given name.
pub fn get_macro(&self, name: Name) -> Option<Lambda>
[src]
Returns a macro function for the given name, if present.
pub fn get_named_macro(&self, name: &str) -> Option<Lambda>
[src]
Returns a macro function for the given name, if present.
pub fn get_named_value(&self, name: &str) -> Option<Value>
[src]
Returns a Value
for the given name, if present.
pub fn get_value(&self, name: Name) -> Option<Value>
[src]
Returns a Value
for the given name, if present.
pub fn import_all(&self, other: &GlobalScope) -> Vec<Name>
[src]
Clones all exported values from a scope into this scope.
pub fn import_qualified(&self, other: &GlobalScope) -> Vec<(Name, Name)>
[src]
Imports all exported values from a scope into this scope, prefixing the name of the scope to the name of each imported value.
pub fn is_exported(&self, name: Name) -> bool
[src]
Returns whether the given name has been exported in this scope.
pub fn is_imported(&self, name: Name) -> bool
[src]
Returns whether the given name is imported from another module.
pub fn set_exports(&self, names: NameSetSlice)
[src]
Assigns a set of exported names for this scope.
pub fn with_doc<F, R>(&self, name: Name, f: F) -> Option<R> where
F: FnOnce(&str) -> R,
[src]
F: FnOnce(&str) -> R,
Calls a closure with a borrowed reference to the named documentation, if present.
Note
When a function is declared with a docstring, that docstring is stored
in the compiled Code
object rather than the GlobalScope
.
pub fn with_docs<F, R>(&self, f: F) -> R where
F: FnOnce(&NameMap<String>) -> R,
[src]
F: FnOnce(&NameMap<String>) -> R,
Calls a closure with a borrowed reference to the contained docstrings.
pub fn with_docs_mut<F, R>(&self, f: F) -> R where
F: FnOnce(&mut NameMap<String>) -> R,
[src]
F: FnOnce(&mut NameMap<String>) -> R,
Calls a closure with a mutable reference to the contained docstrings.
pub fn with_module_doc<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&str) -> R,
[src]
F: FnOnce(&str) -> R,
Calls a closure with an optional reference to the module docstring.
pub fn with_module_doc_mut<F, R>(&self, f: F) -> R where
F: FnOnce(&mut Option<String>) -> R,
[src]
F: FnOnce(&mut Option<String>) -> R,
Calls a closure with a mutable reference to the module docstring.
pub fn with_name<F, R>(&self, name: Name, f: F) -> R where
F: FnOnce(&str) -> R,
[src]
F: FnOnce(&str) -> R,
Calls a closure with the borrowed string representation of a name.
pub fn with_exports<F, R>(&self, f: F) -> Option<R> where
F: FnOnce(&NameSetSlice) -> R,
[src]
F: FnOnce(&NameSetSlice) -> R,
Calls a closure with the set of exported names.
pub fn with_imports<F, R>(&self, f: F) -> R where
F: FnOnce(&[ImportSet]) -> R,
[src]
F: FnOnce(&[ImportSet]) -> R,
Calls a closure with the set of imported values.
pub fn with_constants<F, R>(&self, f: F) -> R where
F: FnOnce(&NameMap<Value>) -> R,
[src]
F: FnOnce(&NameMap<Value>) -> R,
Calls a closure with the set of defined constants.
pub fn with_macros<F, R>(&self, f: F) -> R where
F: FnOnce(&NameMap<Lambda>) -> R,
[src]
F: FnOnce(&NameMap<Lambda>) -> R,
Calls a closure with the set of defined macros.
pub fn with_values<F, R>(&self, f: F) -> R where
F: FnOnce(&NameMap<Value>) -> R,
[src]
F: FnOnce(&NameMap<Value>) -> R,
Calls a closure with the set of defined values.
Auto Trait Implementations
impl !RefUnwindSafe for GlobalScope
impl !Send for GlobalScope
impl !Sync for GlobalScope
impl Unpin for GlobalScope
impl !UnwindSafe for GlobalScope
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,