pub struct SymGen(/* private fields */);
Expand description

A programmatic representation of the resymgen YAML format.

At its core, a SymGen is just a mapping between block names and Blocks, along with convenient methods for manipulating the data within those Blocks.

Implementations§

source§

impl SymGen

source

pub fn merge_symgen(&mut self, other: &Self) -> Result<(), MergeError>

Merges other into self.

source

pub fn merge_symbols<I>(&mut self, other: I) -> Result<Vec<Symbol>, MergeError>
where I: Iterator<Item = AddSymbol>,

Merges other into self.

Returns a Vec<Symbol> containing symbols that were not successfully merged if no fatal error was encountered, or a MergeError if a fatal error was encountered.

source§

impl SymGen

source

pub fn init(&mut self)

Initializes all the block names and Blocks within the SymGen.

source

pub fn read_no_init<R: Read>(rdr: R) -> Result<SymGen>

Reads an uninitialized SymGen from rdr.

source

pub fn read<R: Read>(rdr: R) -> Result<SymGen>

Reads a SymGen from rdr. The returned SymGen will be initialized.

source

pub fn read_sorted<R: Read>(rdr: R) -> Result<SymGen>

Reads a SymGen from rdr. The returned SymGen will be initialized and sorted.

Blocks and their contained Symbols are sorted by address. For version-dependent addresses, comparison is lexicographic in Version order.

source

pub fn write<W: Write>(&self, writer: W, int_format: IntFormat) -> Result<()>

Writes the SymGen data to writer in resymgen YAML format.

Integers will be written with the given int_format.

source

pub fn write_to_str(&self, int_format: IntFormat) -> Result<String>

Writes the SymGen data to a String in resymgen YAML format.

Integers will be written with the given int_format.

source

pub fn resolve_subregions<P, R, F>( &mut self, dir_path: P, file_opener: F ) -> Result<()>
where P: AsRef<Path>, R: Read, F: Fn(&Path) -> Result<R> + Copy,

Recursively resolves the contents of all Subregions in all Blocks within the SymGen.

Subregions are read from files using file_opener, with file paths based on the root directory specified by dir_path.

source

pub fn collapse_subregions(&mut self)

Moves all symbols within Subregions into their parent Blocks’ main symbol lists, destroying the Subregions in the process.

source

pub fn expand_versions(&mut self)

Expands the versions of all the addresses and lengths contained within the SymGen (in all the contained Blocks).

See Block::expand_versions().

source

pub fn block_key(&self, block_name: &str) -> Option<&OrdString>

Gets a reference to the OrdString key in the SymGen corresponding to block_name, if present.

source

pub fn get(&self, key: &OrdString) -> Option<&Block>

Gets a reference to the Block associated with key, if present.

source

pub fn get_mut(&mut self, key: &OrdString) -> Option<&mut Block>

Gets a mutable reference to the Block associated with key, if present.

source

pub fn insert(&mut self, key: OrdString, value: Block) -> Option<Block>

Inserts the Block contained by value into the SymGen, keyed by key.

If the SymGen already had a Block keyed by key, the old Block is returned.

source

pub fn iter(&self) -> impl Iterator<Item = (&OrdString, &Block)>

Returns an Iterator over references to (block name, Block) pairs in the SymGen.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&OrdString, &mut Block)>

Returns an Iterator over mutable references to (block name, Block) pairs in the SymGen.

source

pub fn blocks(&self) -> impl Iterator<Item = &Block>

Returns an Iterator over references to Blocks in the SymGen.

source

pub fn blocks_mut(&mut self) -> impl Iterator<Item = &mut Block>

Returns an Iterator over mutable references to Blocks in the SymGen.

source

pub fn symbols(&self) -> impl Iterator<Item = &Symbol>

Returns a flat Iterator over references to the Symbols contained within every Block in the SymGen.

source

pub fn symbols_realized( &self, version_name: &str ) -> impl Iterator<Item = RealizedSymbol<'_>> + '_

Returns a flat Iterator over all symbols contained within every Block in the SymGen, realized for the Version corresponding to version_name.

source

pub fn functions_realized( &self, version_name: &str ) -> impl Iterator<Item = RealizedSymbol<'_>> + '_

Returns a flat Iterator over all function symbols contained within every Block in the SymGen, realized for the Version corresponding to version_name.

source

pub fn data_realized( &self, version_name: &str ) -> impl Iterator<Item = RealizedSymbol<'_>> + '_

Returns a flat Iterator over all data symbols contained within every Block in the SymGen, realized for the Version corresponding to version_name.

source

pub fn cursor<'s, 'p>(&'s self, path: &'p Path) -> SymGenCursor<'s, 'p>

Returns a SymGenCursor for this SymGen with the given file path.

Trait Implementations§

source§

impl Clone for SymGen

source§

fn clone(&self) -> SymGen

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for SymGen

source§

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

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

impl<'de> Deserialize<'de> for SymGen

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for SymGen

source§

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

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

impl<const N: usize> From<[(OrdString, Block); N]> for SymGen

source§

fn from(arr: [(OrdString, Block); N]) -> Self

Converts to this type from the input type.
source§

impl PartialEq for SymGen

source§

fn eq(&self, other: &SymGen) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for SymGen

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sort for SymGen

source§

fn sort(&mut self)

source§

impl Eq for SymGen

source§

impl StructuralEq for SymGen

source§

impl StructuralPartialEq for SymGen

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,