pub struct MetadataLoweringContext { /* private fields */ }Expand description
Symbol lookups and string interning backed by program metadata and the section’s symbol table.
Every @name operand resolves through one section-wide symbol table:
label_address accepts any symbol, while
function_address additionally requires a
function declaration with that name. Function indices retain metadata table
order, independently of executable addresses.
string_index interns: a string already in the
table keeps its index, and a new one is appended. Lowering a code stream
in address order therefore appends its literals in address order, after
the strings the header derived. Take the completed table with
into_strings and store it in the metadata before
assembling the module. The context is independent of any instruction set;
dialect crates implement their lowering-capability traits for it.
Implementations§
Source§impl MetadataLoweringContext
impl MetadataLoweringContext
Sourcepub fn new<V, Ty, Info>(
metadata: &ProgramMetadata<V, Ty, Info>,
symbols: &[Symbol],
) -> Result<Self>
pub fn new<V, Ty, Info>( metadata: &ProgramMetadata<V, Ty, Info>, symbols: &[Symbol], ) -> Result<Self>
Prepare section-wide string, function, and symbol lookups.
§Errors
Rejects invalid function-name indices, duplicate function names,
duplicate symbols, and tables whose indices cannot be represented by
u32. Full program validation remains the responsibility of the
metadata loading driver.
Sourcepub fn function_address(&self, name: &str) -> Result<u32>
pub fn function_address(&self, name: &str) -> Result<u32>
Look up a function’s executable start address: its symbol’s address.
Sourcepub fn function_index(&self, name: &str) -> Result<u32>
pub fn function_index(&self, name: &str) -> Result<u32>
Look up a function’s index in the supplied metadata table.
Sourcepub fn label_address(&self, name: &str) -> Result<u32>
pub fn label_address(&self, name: &str) -> Result<u32>
Look up any symbol’s address in the section’s symbol table.
Sourcepub fn string_index(&mut self, text: &str) -> Result<u32>
pub fn string_index(&mut self, text: &str) -> Result<u32>
Intern decoded string contents: the index of the first equal entry, or of a new entry appended to the table.
§Errors
Fails only if the table cannot represent another u32 index.
Sourcepub fn strings(&self) -> &[String]
pub fn strings(&self) -> &[String]
The string table so far: the metadata’s strings, then every interned string.
Sourcepub fn into_strings(self) -> Vec<String>
pub fn into_strings(self) -> Vec<String>
The completed string table, for metadata.strings before
metadata.into_module(...).