Skip to main content

LabelTable

Struct LabelTable 

Source
pub struct LabelTable {
    pub local_strings: HashMap<String, String>,
    pub referenced_extern: Vec<String>,
    pub declared_externs: HashMap<String, Reach>,
    /* private fields */
}
Expand description

Interns labels and tracks their flags.

Fields§

§local_strings: HashMap<String, String>

Maps each local label to its emitted symbol text.

§referenced_extern: Vec<String>

Lists the extern labels recorded as referenced, in first-use order.

§declared_externs: HashMap<String, Reach>

Maps each label declared with extern to how code reaches it.

Implementations§

Source§

impl LabelTable

Source

pub fn new() -> Self

Creates an empty table.

Source

pub fn label_for_name( &mut self, name: &str, defined_in_file: bool, ) -> Result<(), String>

Interns name, marking it defined when defined_in_file holds.

§Errors

Returns an error if name collides with a local label.

Source

pub fn local_label_for_name( &mut self, origin: &CodeOrigin, name: &str, ) -> Result<(), String>

Interns the local label name with its emitted symbol text.

§Errors

Returns an error if name collides with a global label.

Source

pub fn apply_substituted_label_flags(&mut self, old: &str, new: &str)

Carries the flags recorded for old over to new.

Source

pub fn unique_local_label( &mut self, origin: &CodeOrigin, comment: &str, ) -> String

Creates a fresh local label derived from comment.

Source

pub fn set_as_global(&mut self, name: &str) -> Result<(), String>

Marks name as global.

§Errors

Returns an error if name is already global or collides with a local label.

Source

pub fn set_as_global_export(&mut self, name: &str) -> Result<(), String>

Marks name as a global export.

§Errors

Returns an error if name is already global or collides with a local label.

Source

pub fn set_as_unaligned_global(&mut self, name: &str) -> Result<(), String>

Marks name as an unaligned global.

§Errors

Returns an error if name is already global or collides with a local label.

Source

pub fn set_as_unaligned_global_export( &mut self, name: &str, ) -> Result<(), String>

Marks name as an unaligned global export.

§Errors

Returns an error if name is already global or collides with a local label.

Source

pub fn set_as_extern(&mut self, name: &str, reach: Reach) -> Result<(), String>

Declares name an external symbol reached as reach.

§Errors

Returns an error if name is already declared extern, is defined or declared global in this file, or collides with a local label.

Source

pub fn set_as_aligned( &mut self, name: &str, align_to: Option<Node>, ) -> Result<(), String>

Marks name aligned, optionally to align_to.

§Errors

Returns an error if name is already aligned or collides with a local label.

Source

pub fn label_flags(&self, name: &str) -> Option<&LabelFlags>

Returns the flags recorded for name, when interned.

Source

pub fn is_extern_label(&self, name: &str) -> bool

Reports whether name is an extern label.

Source

pub fn is_global_label(&self, name: &str) -> bool

Reports whether name is a global label.

Source

pub fn reset_referenced(&mut self)

Clears the referenced-extern list.

Source

pub fn mark_used(&mut self, name: &str)

Records name as referenced when it is extern.

Trait Implementations§

Source§

impl Clone for LabelTable

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LabelTable

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LabelTable

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.