pub struct SymbolTable { /* private fields */ }
Expand description

The symbol table created in the first assembler pass that encodes source code mappings to memory addresses in the object file.

The symbol table consists of:

  • A mapping from source code labels to memory addresses.
  • A mapping from source code line numbers to memory addresses (if debug symbols are enabled, see SymbolTable::new).
  • The source text (if debug symbols are enabled, see SymbolTable::new).

Implementations§

source§

impl SymbolTable

source

pub fn new(stmts: &[Stmt], src: Option<&str>) -> Result<Self, AsmErr>

Creates a new symbol table.

This performs the first assembler pass, calculating the memory address of labels at each provided statement.

If a src argument is provided, this also computes debug symbols and includes them within this SymbolTable struct. These debug symbols include:

  • Mappings from source code line numbers to memory addresses
  • Source code text (and more detailed calculations with source code, see SourceInfo for more details)
source

pub fn get_label(&self, label: &str) -> Option<u16>

Gets the memory address of a given label (if it exists).

source

pub fn find_label_source(&self, label: &str) -> Option<Range<usize>>

Gets the source span of a given label (if it exists).

source

pub fn label_iter(&self) -> impl Iterator<Item = (&str, u16)> + '_

Gets an iterable of the mapping from labels to addresses.

source

pub fn get_line(&self, line: usize) -> Option<u16>

Gets the address of a given source line.

If debug symbols are not enabled, this unconditionally returns None.

source

pub fn find_line_source(&self, addr: u16) -> Option<usize>

Gets the source line of a given memory address (if it exists.)

The result can be converted into a source span (range of characters encompassed by the instruction) using SymbolTable::source_info and SourceInfo::line_span.

If debug symbols are not enabled, this unconditionally returns None.

source

pub fn source_info(&self) -> Option<&SourceInfo>

Reads the source info from this symbol table (if debug symbols are enabled).

Trait Implementations§

source§

impl Debug for SymbolTable

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V