Struct netsblox_vm::runtime::SymbolTable
source · pub struct SymbolTable<'gc, C: CustomTypes<S>, S: System<C>>(/* private fields */);Expand description
Holds a collection of variables in an execution context.
SymbolTable has utilities to extract variables from an abstract syntax tree, or to explicitly define variables.
Simple methods are provided to perform value lookups in the table.
Implementations§
source§impl<'gc, C: CustomTypes<S>, S: System<C>> SymbolTable<'gc, C, S>
impl<'gc, C: CustomTypes<S>, S: System<C>> SymbolTable<'gc, C, S>
sourcepub fn define_or_redefine(
&mut self,
var: &str,
value: Shared<'gc, Value<'gc, C, S>>
)
pub fn define_or_redefine( &mut self, var: &str, value: Shared<'gc, Value<'gc, C, S>> )
Defines or redefines a value in the symbol table to a new instance of Shared<Value>.
If a variable named var already existed and was Shared::Aliased, its value is not modified.
sourcepub fn lookup(&self, var: &str) -> Option<&Shared<'gc, Value<'gc, C, S>>>
pub fn lookup(&self, var: &str) -> Option<&Shared<'gc, Value<'gc, C, S>>>
Looks up the given variable in the symbol table.
If a variable with the given name does not exist, returns None.
sourcepub fn lookup_mut(
&mut self,
var: &str
) -> Option<&mut Shared<'gc, Value<'gc, C, S>>>
pub fn lookup_mut( &mut self, var: &str ) -> Option<&mut Shared<'gc, Value<'gc, C, S>>>
Equivalent to SymbolTable::lookup except that it returns a mutable reference.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the symbol table is currently empty (no defined symbols).
Trait Implementations§
source§impl<'gc, C: CustomTypes<S>, S: System<C>> Clone for SymbolTable<'gc, C, S>
impl<'gc, C: CustomTypes<S>, S: System<C>> Clone for SymbolTable<'gc, C, S>
source§impl<'gc, C: CustomTypes<S>, S: System<C>> Collect for SymbolTable<'gc, C, S>
impl<'gc, C: CustomTypes<S>, S: System<C>> Collect for SymbolTable<'gc, C, S>
source§fn needs_trace() -> bool
fn needs_trace() -> bool
As an optimization, if this type can never hold a
Gc pointer and trace is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace must be called.source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Must call
Collect::trace on all held Gc pointers. If this type holds inner types that
implement Collect, a valid implementation would simply call Collect::trace on all the
held values to ensure this.source§impl<'gc, C: CustomTypes<S>, S: System<C>> Debug for SymbolTable<'gc, C, S>
impl<'gc, C: CustomTypes<S>, S: System<C>> Debug for SymbolTable<'gc, C, S>
source§impl<'gc, C: CustomTypes<S>, S: System<C>> Default for SymbolTable<'gc, C, S>
impl<'gc, C: CustomTypes<S>, S: System<C>> Default for SymbolTable<'gc, C, S>
Auto Trait Implementations§
impl<'gc, C, S> !RefUnwindSafe for SymbolTable<'gc, C, S>
impl<'gc, C, S> !Send for SymbolTable<'gc, C, S>
impl<'gc, C, S> !Sync for SymbolTable<'gc, C, S>
impl<'gc, C, S> Unpin for SymbolTable<'gc, C, S>
impl<'gc, C, S> !UnwindSafe for SymbolTable<'gc, C, S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more