Struct brane_dsl::symbol_table::SymbolTable
source · pub struct SymbolTable {
pub parent: Option<Rc<RefCell<SymbolTable>>>,
/* private fields */
}
Expand description
Defines a SymbolTable that contains all definitions of a single scope.
Fields§
§parent: Option<Rc<RefCell<SymbolTable>>>
Contains the parent symbol table, if any.
Implementations§
source§impl SymbolTable
impl SymbolTable
sourcepub fn new() -> Rc<RefCell<Self>>
pub fn new() -> Rc<RefCell<Self>>
Constructor for the SymbolTable.
§Returns
A new SymbolTable that does not have any definitions within it yet. It is already wrapped in an Rc and RefCell for convenience.
sourcepub fn add_func(
&mut self,
entry: FunctionEntry,
) -> Result<Rc<RefCell<FunctionEntry>>, Error>
pub fn add_func( &mut self, entry: FunctionEntry, ) -> Result<Rc<RefCell<FunctionEntry>>, Error>
sourcepub fn add_class(
&mut self,
entry: ClassEntry,
) -> Result<Rc<RefCell<ClassEntry>>, Error>
pub fn add_class( &mut self, entry: ClassEntry, ) -> Result<Rc<RefCell<ClassEntry>>, Error>
sourcepub fn get<S: AsRef<str>>(&self, name: S) -> Option<SymbolTableEntry>
pub fn get<S: AsRef<str>>(&self, name: S) -> Option<SymbolTableEntry>
Returns the entry in all namespaces with the given name if it exists.
This implies that the name is unique across namespaces, so it relies on an external source to make that happen.
If that somehow fails, returns the first occurrence in the order of functions -> classes -> variables.
§Generic arguments
S
: The &str-like type of the targetname
.
§Arguments
name
: The name of the entry to retrieve.
§Returns
A reference-counter pointer to the entry if it exists, or else None.
sourcepub fn has_functions(&self) -> bool
pub fn has_functions(&self) -> bool
Returns whether this SymbolTable has any functions defined at all.
sourcepub fn n_functions(&self) -> usize
pub fn n_functions(&self) -> usize
Returns the number of functions defined in the SymbolTable.
sourcepub fn functions(&self) -> Iter<'_, String, Rc<RefCell<FunctionEntry>>>
pub fn functions(&self) -> Iter<'_, String, Rc<RefCell<FunctionEntry>>>
Returns an iterator over the defined functions (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn functions_mut(
&mut self,
) -> IterMut<'_, String, Rc<RefCell<FunctionEntry>>>
pub fn functions_mut( &mut self, ) -> IterMut<'_, String, Rc<RefCell<FunctionEntry>>>
Returns a muteable iterator over the defined functions (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn into_functions(&mut self) -> IntoIter<String, Rc<RefCell<FunctionEntry>>>
pub fn into_functions(&mut self) -> IntoIter<String, Rc<RefCell<FunctionEntry>>>
Returns a consuming iterator over the defined functions (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn has_classes(&self) -> bool
pub fn has_classes(&self) -> bool
Returns whether this SymbolTable has any classes defined at all.
sourcepub fn classes(&self) -> Iter<'_, String, Rc<RefCell<ClassEntry>>>
pub fn classes(&self) -> Iter<'_, String, Rc<RefCell<ClassEntry>>>
Returns an iterator over the defined classes (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn classes_mut(&mut self) -> IterMut<'_, String, Rc<RefCell<ClassEntry>>>
pub fn classes_mut(&mut self) -> IterMut<'_, String, Rc<RefCell<ClassEntry>>>
Returns a muteable iterator over the defined classes (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn into_classes(&mut self) -> IntoIter<String, Rc<RefCell<ClassEntry>>>
pub fn into_classes(&mut self) -> IntoIter<String, Rc<RefCell<ClassEntry>>>
Returns a consuming iterator over the defined classes (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
sourcepub fn has_variables(&self) -> bool
pub fn has_variables(&self) -> bool
Returns whether this SymbolTable has any variables defined at all.
sourcepub fn n_variables(&self) -> usize
pub fn n_variables(&self) -> usize
Returns the number of variables defined in the SymbolTable.
sourcepub fn variables(&self) -> Iter<'_, String, Rc<RefCell<VarEntry>>>
pub fn variables(&self) -> Iter<'_, String, Rc<RefCell<VarEntry>>>
Returns an iterator over the defined variables (as (name, entry)
pairs).
§Returns
The iterator returned by the internal HashMap.
Trait Implementations§
source§impl Clone for SymbolTable
impl Clone for SymbolTable
source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for SymbolTable
impl !RefUnwindSafe for SymbolTable
impl !Send for SymbolTable
impl !Sync for SymbolTable
impl Unpin for SymbolTable
impl !UnwindSafe for SymbolTable
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request