Struct ketos::scope::GlobalScope
[−]
[src]
pub struct GlobalScope {
// some fields omitted
}Represents the global namespace of an execution context.
Methods
impl GlobalScope[src]
fn new(name: Name, names: Rc<RefCell<NameStore>>, codemap: Rc<RefCell<CodeMap>>, registry: Rc<ModuleRegistry>, io: Rc<GlobalIo>) -> GlobalScope
Creates a new global scope.
fn default(name: &str) -> GlobalScope
Creates a new global scope with the given name and default environment.
fn new_using(name: Name, scope: &Scope) -> Scope
Creates a new global scope using the shared data from the given scope.
fn add_constant(&self, name: Name, value: Value)
Adds a named constant value to the scope.
fn add_doc_string(&self, name: Name, doc: String)
Adds a docstring for the named constant or value.
fn add_macro(&self, name: Name, lambda: Lambda)
Adds a macro function to the global scope.
fn add_name(&self, name: &str) -> Name
Adds a string representation to the contained NameStore.
fn add_imports(&self, imports: ImportSet)
Adds a set of imports to the given scope.
fn add_value(&self, name: Name, value: Value)
Adds a value to the global scope.
fn add_named_value(&self, name: &str, value: Value)
Adds a value with the given name to the global scope.
fn add_value_with_name<F>(&self, name: &str, f: F) where 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.
fn borrow_codemap(&self) -> Ref<CodeMap>
Borrows a reference to the contained CodeMap.
fn borrow_codemap_mut(&self) -> RefMut<CodeMap>
Borrows a mutable reference to the contained CodeMap.
fn borrow_names(&self) -> Ref<NameStore>
Borrows a reference to the contained NameStore.
fn borrow_names_mut(&self) -> RefMut<NameStore>
Borrows a mutable reference to the contained NameStore.
fn num_constants(&self) -> usize
Returns the number of contained constants.
fn num_macros(&self) -> usize
Returns the number of contained macros.
fn num_values(&self) -> usize
Returns the number of contained values.
fn get_codemap(&self) -> &Rc<RefCell<CodeMap>>
Returns a borrowed reference to the contained CodeMap.
fn get_constant(&self, name: Name) -> Option<Value>
Returns a named constant value, if present.
fn get_named_constant(&self, name: &str) -> Option<Value>
Returns a named constant value, if present.
fn get_io(&self) -> &Rc<GlobalIo>
Returns a borrowed reference to the contained GlobalIo.
fn get_modules(&self) -> &Rc<ModuleRegistry>
Returns a borrowed reference to the contained ModuleRegistry.
fn get_name(&self) -> Name
Returns the scope's name.
fn get_names(&self) -> &Rc<RefCell<NameStore>>
Returns a borrowed reference to the contained NameStore.
fn contains_name(&self, name: Name) -> bool
Returns whether the scope contains a given exportable name.
fn contains_constant(&self, name: Name) -> bool
Returns whether the scope contains a constant for the given name.
fn contains_macro(&self, name: Name) -> bool
Returns whether the scope contains a macro for the given name.
fn contains_value(&self, name: Name) -> bool
Returns whether the scope contains a value for the given name.
fn get_macro(&self, name: Name) -> Option<Lambda>
Returns a macro function for the given name, if present.
fn get_named_macro(&self, name: &str) -> Option<Lambda>
Returns a macro function for the given name, if present.
fn get_named_value(&self, name: &str) -> Option<Value>
Returns a Value for the given name, if present.
fn get_value(&self, name: Name) -> Option<Value>
Returns a Value for the given name, if present.
fn import_all(&self, other: &GlobalScope) -> Vec<Name>
Clones all exported values from a scope into this scope.
fn is_exported(&self, name: Name) -> bool
Returns whether the given name has been exported in this scope.
fn is_imported(&self, name: Name) -> bool
Returns whether the given name is imported from another module.
fn set_exports(&self, names: NameSetSlice)
Assigns a set of exported names for this scope.
fn with_doc<F, R>(&self, name: Name, f: F) -> Option<R> where 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.
fn with_docs<F, R>(&self, f: F) -> R where F: FnOnce(&NameMap<String>) -> R
Calls a closure with a borrowed reference to the contained docstrings.
fn with_docs_mut<F, R>(&self, f: F) -> R where F: FnOnce(&mut NameMap<String>) -> R
Calls a closure with a mutable reference to the contained docstrings.
fn with_module_doc<F, R>(&self, f: F) -> Option<R> where F: FnOnce(&str) -> R
Calls a closure with an optional reference to the module docstring.
fn with_module_doc_mut<F, R>(&self, f: F) -> R where F: FnOnce(&mut Option<String>) -> R
Calls a closure with a mutable reference to the module docstring.
fn with_name<F, R>(&self, name: Name, f: F) -> R where F: FnOnce(&str) -> R
Calls a closure with the borrowed string representation of a name.
fn with_exports<F, R>(&self, f: F) -> Option<R> where F: FnOnce(&NameSetSlice) -> R
Calls a closure with the set of exported names.
fn with_imports<F, R>(&self, f: F) -> R where F: FnOnce(&[ImportSet]) -> R
Calls a closure with the set of imported values.
fn with_constants<F, R>(&self, f: F) -> R where F: FnOnce(&NameMap<Value>) -> R
Calls a closure with the set of defined constants.
fn with_macros<F, R>(&self, f: F) -> R where F: FnOnce(&NameMap<Lambda>) -> R
Calls a closure with the set of defined macros.
fn with_values<F, R>(&self, f: F) -> R where F: FnOnce(&NameMap<Value>) -> R
Calls a closure with the set of defined values.