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 containing default values.
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)
Add a named constant value to the scope.
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 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_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_value(&self, name: Name) -> Option<Value>
Returns a Value
for the given name, if present.
fn import_all_constants(&self, other: &GlobalScope) -> Vec<Name>
Clones all constant values from a scope into this one.
fn import_all_macros(&self, other: &GlobalScope) -> Vec<Name>
Clones all exported values from a scope into this scope.
fn import_all_values(&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 set_exports(&self, names: NameSetSlice)
Assigns a set of exported names for this scope.
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) -> R where F: FnOnce(Option<&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.