pub struct SymbolTable { /* private fields */ }Expand description
Stores and manages symbols defined in the assembly source.
Typically used in a two-pass assembly process:
- Pass 1: Populate the table with label definitions and their addresses.
- Pass 2: Use the table to resolve symbol references in instruction operands.
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn define(
&mut self,
name: String,
address: u32,
line_number: Option<usize>,
) -> Result<(), AssemblerError>
pub fn define( &mut self, name: String, address: u32, line_number: Option<usize>, ) -> Result<(), AssemblerError>
Defines a new symbol or updates an existing one.
§Arguments
name- The name of the symbol (label).address- The address associated with the symbol.line_number- The line number where the symbol is defined (optional).
§Returns
Ok(())- If the symbol was successfully defined.Err(SymbolError::Redefinition)- If a symbol with the same name already exists.
Sourcepub fn is_defined(&self, name: &str) -> bool
pub fn is_defined(&self, name: &str) -> bool
Checks if a symbol with the given name is defined.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &Symbol)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &Symbol)>
Returns an iterator over the symbols in the table.
Sourcepub fn add_unresolved_reference(&mut self, name: &str, line_number: usize)
pub fn add_unresolved_reference(&mut self, name: &str, line_number: usize)
Records that an unresolved symbol was encountered at a specific location. Call this during Pass 1 when an operand uses a symbol not yet defined.
Trait Implementations§
Source§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§fn default() -> SymbolTable
fn default() -> SymbolTable
Returns the “default value” for a type. Read more
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