pub struct SymbolTable { /* private fields */ }Expand description
Symbol table with scope management
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn enter_scope(&mut self)
pub fn enter_scope(&mut self)
Enter a new scope
Sourcepub fn exit_scope(&mut self) -> Result<()>
pub fn exit_scope(&mut self) -> Result<()>
Exit current scope
Sourcepub fn add_symbol(
&mut self,
name: String,
typ: Type,
is_parameter: bool,
is_exported: bool,
) -> Result<i32>
pub fn add_symbol( &mut self, name: String, typ: Type, is_parameter: bool, is_exported: bool, ) -> Result<i32>
Add a symbol to the current scope
Sourcepub fn add_function(
&mut self,
name: String,
parameters: Vec<(String, Type)>,
return_type: Type,
is_external: bool,
external_name: Option<String>,
is_exported: bool,
) -> Result<()>
pub fn add_function( &mut self, name: String, parameters: Vec<(String, Type)>, return_type: Type, is_external: bool, external_name: Option<String>, is_exported: bool, ) -> Result<()>
Add a function symbol with signature
Sourcepub fn lookup_function(&self, name: &str) -> Option<&FunctionSignature>
pub fn lookup_function(&self, name: &str) -> Option<&FunctionSignature>
Look up a function signature
Sourcepub fn add_const(
&mut self,
name: String,
typ: Type,
value: ConstValue,
) -> Result<()>
pub fn add_const( &mut self, name: String, typ: Type, value: ConstValue, ) -> Result<()>
Add a constant symbol
Sourcepub fn lookup(&self, name: &str) -> Option<&Symbol>
pub fn lookup(&self, name: &str) -> Option<&Symbol>
Look up a symbol in current and parent scopes
Sourcepub fn current_offset(&self) -> i32
pub fn current_offset(&self) -> i32
Get current stack offset
Sourcepub fn reset_offset(&mut self)
pub fn reset_offset(&mut self)
Reset offset for new function
Trait Implementations§
Source§impl Debug for SymbolTable
impl Debug for SymbolTable
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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