Struct Resolver

Source
pub struct Resolver<'lt> {
    pub scope_stack: Vec<&'lt SymbolTable>,
    /* private fields */
}
Expand description

Allows name resolution with the resolve/resolve_hierarchical methods

Fields§

§scope_stack: Vec<&'lt SymbolTable>

Implementations§

Source§

impl<'lt> Resolver<'lt>

Source

pub fn new(ast: &'lt Ast) -> Self

Source

pub fn enter_function(&mut self, function_symbol_table: &'lt SymbolTable)

Source

pub fn exit_function(&mut self) -> Option<&'lt SymbolTable>

Source

pub fn resolve(&self, ident: &Ident) -> Result<SymbolDeclaration>

Tries to resolve the Identifier ident

This functions first tries to find `ident in the current scope, then in the previous scope and so on If it can’t find ident in the global (first) Scope it returns an NotFound Error

Source

pub fn resolve_hierarchical( &self, hierarchical_ident: &HierarchicalId, ) -> Result<SymbolDeclaration>

Tries to resolve the Hierarchical Identifer hierarchical_ident

This functions tires to resolve the first identifier using the resolve function Afterwards it tries to resolve all following identifier inside the scope of the previously resolved Identifier

Source

pub fn enter_scope(&mut self, scope_symbol_table: &'lt SymbolTable)

Enter a new Scope

This scope will be the first to be searched for identifiers until it is overshadowed by another enter_scope call or it is removed using exit_scope

§Arguments
  • scope_symbol_table - Symbol table in which the resolver will look for definitions in this scope
Source

pub fn exit_scope(&mut self) -> Option<&'lt SymbolTable>

Leave the current Scope

Items defined in the current scope will not be resolved anymore by this resolver after this method has been called

§Returns
  • None if the Resolver doesn’t hold any Scopes
  • The Symbol_Table of the removed Scope

Auto Trait Implementations§

§

impl<'lt> Freeze for Resolver<'lt>

§

impl<'lt> RefUnwindSafe for Resolver<'lt>

§

impl<'lt> Send for Resolver<'lt>

§

impl<'lt> Sync for Resolver<'lt>

§

impl<'lt> Unpin for Resolver<'lt>

§

impl<'lt> UnwindSafe for Resolver<'lt>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.