pub struct SymbolTable {
    pub functions: IndexMap<Symbol, FunctionSymbol, RandomState>,
    pub structs: IndexMap<Symbol, Struct, RandomState>,
    /* private fields */
}

Fields§

§functions: IndexMap<Symbol, FunctionSymbol, RandomState>

Functions represents the name of each function mapped to the AST’s function definition. This field is populated at a first pass.

§structs: IndexMap<Symbol, Struct, RandomState>

Maps struct names to struct definitions. This field is populated at a first pass.

Implementations§

source§

impl SymbolTable

source

pub fn check_shadowing( &self, symbol: Symbol, span: Span ) -> Result<(), LeoError>

Recursively checks if the symbol table contains an entry for the given symbol. Leo does not allow any variable shadowing or overlap between different symbols.

source

pub fn scope_index(&mut self) -> usize

Returns the current scope index. Increments the scope index.

source

pub fn insert_fn( &mut self, symbol: Symbol, insert: &Function ) -> Result<(), LeoError>

Inserts a function into the symbol table.

source

pub fn insert_struct( &mut self, symbol: Symbol, insert: &Struct ) -> Result<(), LeoError>

Inserts a struct into the symbol table.

source

pub fn insert_variable( &mut self, symbol: Symbol, insert: VariableSymbol ) -> Result<(), LeoError>

Inserts a variable into the symbol table.

source

pub fn insert_block(&mut self) -> usize

Creates a new scope for the block and stores it in the symbol table.

source

pub fn lookup_fn_symbol(&self, symbol: Symbol) -> Option<&FunctionSymbol>

Attempts to lookup a function in the symbol table.

source

pub fn lookup_struct(&self, symbol: Symbol) -> Option<&Struct>

Attempts to lookup a struct in the symbol table.

source

pub fn lookup_variable(&self, symbol: Symbol) -> Option<&VariableSymbol>

Attempts to lookup a variable in the symbol table.

source

pub fn variable_in_local_scope(&self, symbol: Symbol) -> bool

Returns true if the variable exists in the local scope

source

pub fn variable_in_parent_scope(&self, symbol: Symbol) -> bool

Returns true if the variable exists in any parent scope

source

pub fn lookup_variable_mut( &mut self, symbol: Symbol ) -> Option<&mut VariableSymbol>

Returns a mutable reference to the VariableSymbol if it exists in the symbol table.

source

pub fn lookup_fn_scope(&self, symbol: Symbol) -> Option<&RefCell<SymbolTable>>

Returns the scope associated with the function symbol, if it exists in the symbol table.

source

pub fn lookup_scope_by_index( &self, index: usize ) -> Option<&RefCell<SymbolTable>>

Returns the scope associated with index, if it exists in the symbol table.

Trait Implementations§

source§

impl Clone for SymbolTable

source§

fn clone(&self) -> SymbolTable

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SymbolTable

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for SymbolTable

source§

fn default() -> SymbolTable

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V