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>
impl<'lt> Resolver<'lt>
pub fn new(ast: &'lt Ast) -> Self
pub fn enter_function(&mut self, function_symbol_table: &'lt SymbolTable)
pub fn exit_function(&mut self) -> Option<&'lt SymbolTable>
Sourcepub fn resolve(&self, ident: &Ident) -> Result<SymbolDeclaration>
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
Sourcepub fn resolve_hierarchical(
&self,
hierarchical_ident: &HierarchicalId,
) -> Result<SymbolDeclaration>
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
Sourcepub fn enter_scope(&mut self, scope_symbol_table: &'lt SymbolTable)
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
Sourcepub fn exit_scope(&mut self) -> Option<&'lt SymbolTable>
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