pub struct SymbolTable { /* private fields */ }Expand description
Symbol table for managing scopes and symbols
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn set_source(&mut self, source: String)
pub fn set_source(&mut self, source: String)
Set the source code for error location reporting
Sourcepub fn set_allow_redefinition(&mut self, allow: bool)
pub fn set_allow_redefinition(&mut self, allow: bool)
Allow variable redefinition in current scope (for REPL mode)
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Push a new scope
Sourcepub fn define_variable(
&mut self,
name: &str,
ty: Type,
kind: VarKind,
is_initialized: bool,
) -> Result<()>
pub fn define_variable( &mut self, name: &str, ty: Type, kind: VarKind, is_initialized: bool, ) -> Result<()>
Define a variable in the current scope
Sourcepub fn define_variable_at(
&mut self,
name: &str,
ty: Type,
kind: VarKind,
is_initialized: bool,
span: Span,
) -> Result<()>
pub fn define_variable_at( &mut self, name: &str, ty: Type, kind: VarKind, is_initialized: bool, span: Span, ) -> Result<()>
Define a variable in the current scope with span for error reporting
Sourcepub fn define_function(
&mut self,
name: &str,
params: Vec<Type>,
returns: Type,
) -> Result<()>
pub fn define_function( &mut self, name: &str, params: Vec<Type>, returns: Type, ) -> Result<()>
Define a function in the current scope
Sourcepub fn define_function_with_defaults(
&mut self,
name: &str,
params: Vec<Type>,
returns: Type,
defaults: Vec<bool>,
) -> Result<()>
pub fn define_function_with_defaults( &mut self, name: &str, params: Vec<Type>, returns: Type, defaults: Vec<bool>, ) -> Result<()>
Define a function in the current scope with default-parameter metadata.
Sourcepub fn define_function_at(
&mut self,
name: &str,
params: Vec<Type>,
returns: Type,
span: Span,
) -> Result<()>
pub fn define_function_at( &mut self, name: &str, params: Vec<Type>, returns: Type, span: Span, ) -> Result<()>
Define a function in the current scope with span for error reporting
Sourcepub fn define_enum(&mut self, enum_def: EnumDef) -> Result<()>
pub fn define_enum(&mut self, enum_def: EnumDef) -> Result<()>
Define an enum (always root-scoped)
Sourcepub fn lookup_enum(&self, name: &str) -> Option<&EnumDef>
pub fn lookup_enum(&self, name: &str) -> Option<&EnumDef>
Look up an enum by name
Sourcepub fn define_type_alias(
&mut self,
name: &str,
type_annotation: TypeAnnotation,
) -> Result<()>
pub fn define_type_alias( &mut self, name: &str, type_annotation: TypeAnnotation, ) -> Result<()>
Define a type alias (e.g., type Candle = { ... })
Sourcepub fn define_type_alias_at(
&mut self,
name: &str,
type_annotation: TypeAnnotation,
meta_param_overrides: Option<HashMap<String, Expr>>,
span: Span,
) -> Result<()>
pub fn define_type_alias_at( &mut self, name: &str, type_annotation: TypeAnnotation, meta_param_overrides: Option<HashMap<String, Expr>>, span: Span, ) -> Result<()>
Define a type alias with span for error reporting
Sourcepub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
pub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
Look up a type alias by name
Sourcepub fn lookup(&self, name: &str) -> Option<&Symbol>
pub fn lookup(&self, name: &str) -> Option<&Symbol>
Look up a symbol in all scopes (innermost first)
Sourcepub fn update_variable(&mut self, name: &str, new_ty: Type) -> Result<()>
pub fn update_variable(&mut self, name: &str, new_ty: Type) -> Result<()>
Update an existing variable (for assignments)
Sourcepub fn update_variable_at(
&mut self,
name: &str,
new_ty: Type,
span: Span,
) -> Result<()>
pub fn update_variable_at( &mut self, name: &str, new_ty: Type, span: Span, ) -> Result<()>
Update an existing variable (for assignments) with span for error reporting
Sourcepub fn lookup_variable(&self, name: &str) -> Option<(&Type, &VarKind, bool)>
pub fn lookup_variable(&self, name: &str) -> Option<(&Type, &VarKind, bool)>
Look up a variable specifically
Sourcepub fn lookup_function(
&self,
name: &str,
) -> Option<(&Vec<Type>, &Type, &Vec<bool>)>
pub fn lookup_function( &self, name: &str, ) -> Option<(&Vec<Type>, &Type, &Vec<bool>)>
Look up a function specifically
Sourcepub fn define_module(
&mut self,
name: &str,
exports: Vec<String>,
type_annotation: TypeAnnotation,
) -> Result<()>
pub fn define_module( &mut self, name: &str, exports: Vec<String>, type_annotation: TypeAnnotation, ) -> Result<()>
Define a module in the root (first) scope. Idempotent — returns Ok if already defined.
Sourcepub fn lookup_module(
&self,
name: &str,
) -> Option<(&Vec<String>, &TypeAnnotation)>
pub fn lookup_module( &self, name: &str, ) -> Option<(&Vec<String>, &TypeAnnotation)>
Look up a module specifically
Sourcepub fn is_defined_in_current_scope(&self, name: &str) -> bool
pub fn is_defined_in_current_scope(&self, name: &str) -> bool
Check if a name is defined in the current scope only
Sourcepub fn iter_all_symbols(&self) -> impl Iterator<Item = (&str, &Symbol)>
pub fn iter_all_symbols(&self) -> impl Iterator<Item = (&str, &Symbol)>
Iterate over all symbols in all scopes
Returns an iterator of (name, symbol) pairs from all scopes, with inner scopes appearing after outer scopes.
Sourcepub fn iter_type_aliases(&self) -> impl Iterator<Item = (&str, &TypeAliasEntry)>
pub fn iter_type_aliases(&self) -> impl Iterator<Item = (&str, &TypeAliasEntry)>
Iterate over all type aliases
Sourcepub fn iter_enums(&self) -> impl Iterator<Item = (&str, &EnumDef)>
pub fn iter_enums(&self) -> impl Iterator<Item = (&str, &EnumDef)>
Iterate over all enums
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 moreSource§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§impl<'de> Deserialize<'de> for SymbolTable
impl<'de> Deserialize<'de> for SymbolTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnsafeUnpin 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§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more