pub struct SymbolTable { /* private fields */ }
Expand description
A symbol table section in a KerbalObject file.
This section stores a list of all symbols that this object file stores and references.
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn new(section_index: SectionIdx) -> Self
pub fn new(section_index: SectionIdx) -> Self
Creates a new symbol table section with the provided section index
Sourcepub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
pub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
Creates a new symbol table section with the provided section index, with internal data structures pre-allocated for the provided amount of symbols
Sourcepub fn get(&self, index: SymbolIdx) -> Option<&KOSymbol>
pub fn get(&self, index: SymbolIdx) -> Option<&KOSymbol>
Gets the symbol at the provided index into this symbol table, or None if it doesn’t exist.
Sourcepub fn find_by_name(&self, name_idx: StringIdx) -> Option<&KOSymbol>
pub fn find_by_name(&self, name_idx: StringIdx) -> Option<&KOSymbol>
Returns the KOSymbol by the provided name index (from the .symstrtab), or None if it doesn’t exist
Sourcepub fn position_by_name(&self, name_idx: StringIdx) -> Option<SymbolIdx>
pub fn position_by_name(&self, name_idx: StringIdx) -> Option<SymbolIdx>
Returns the position/index in this symbol table of the symbol of the provided name index (from the .symstrtab), or None if it doesn’t exist
Sourcepub fn find(&self, symbol: &KOSymbol) -> Option<SymbolIdx>
pub fn find(&self, symbol: &KOSymbol) -> Option<SymbolIdx>
Returns the position/index in this symbol table of the provided symbol, or None if it doesn’t exist
Sourcepub fn add(&mut self, symbol: KOSymbol) -> SymbolIdx
pub fn add(&mut self, symbol: KOSymbol) -> SymbolIdx
Adds a new symbol to this symbol table, returning the index of the symbol into this section. Doesn’t do anything like checking if a symbol with that name already exists in the table
Sourcepub fn add_checked(&mut self, symbol: KOSymbol) -> SymbolIdx
pub fn add_checked(&mut self, symbol: KOSymbol) -> SymbolIdx
Adds a new symbol to this symbol table, returning the index of the symbol into this section. Checks if a symbol with the same name is already in the table, and in that case just returns the index of that symbol
Sourcepub fn symbols(&self) -> Iter<'_, KOSymbol>
pub fn symbols(&self) -> Iter<'_, KOSymbol>
Returns an iterator over all symbols in this symbol table
Sourcepub fn section_index(&self) -> SectionIdx
pub fn section_index(&self) -> SectionIdx
The index of this section’s section header
Sourcepub fn parse(
source: &mut BufferIterator<'_>,
size: u32,
section_index: SectionIdx,
) -> Result<Self, SymbolTableParseError>
pub fn parse( source: &mut BufferIterator<'_>, size: u32, section_index: SectionIdx, ) -> Result<Self, SymbolTableParseError>
Parses a symbol table from the provided byte buffer
Sourcepub fn write(&self, buf: &mut impl WritableBuffer)
pub fn write(&self, buf: &mut impl WritableBuffer)
Converts this symbol table to its binary representation and appends it to the provided buffer