gbf_core::bytecode_loader

Struct BytecodeLoader

Source
pub struct BytecodeLoader<R: Read> {
    pub function_map: HashMap<Option<String>, Gs2BytecodeAddress>,
    pub instructions: Vec<Instruction>,
    pub block_address_to_function: HashMap<Gs2BytecodeAddress, Option<String>>,
    /* private fields */
}
Expand description

A structure for loading bytecode from a reader.

Fields§

§function_map: HashMap<Option<String>, Gs2BytecodeAddress>

A map of function names to their addresses.

§instructions: Vec<Instruction>

The instructions in the module.

§block_address_to_function: HashMap<Gs2BytecodeAddress, Option<String>>

A map of block start addresses to their corresponding function name.

Implementations§

Source§

impl<R: Read> BytecodeLoader<R>

Source

pub fn get_function_name_for_address( &self, address: Gs2BytecodeAddress, ) -> Result<Option<String>, BytecodeLoaderError>

Get the function name for a given address.

§Arguments
  • address: The address to get the function name for.
§Returns
  • The function name, if it exists.
§Errors
  • BytecodeLoaderError::UnreachableBlock if the block is unreachable, and therefore, the function name cannot be determined.
Source

pub fn is_instruction_reachable(&self, address: Gs2BytecodeAddress) -> bool

Checks if an instruction is reachable.

§Arguments
  • address: The address to check.
§Returns
  • true if the instruction is reachable, false otherwise.
Source

pub fn find_block_start_address( &self, address: Gs2BytecodeAddress, ) -> Gs2BytecodeAddress

Helper function to figure out what block the address is in. This basically looks at the argument, and finds the closest block start address that is less than or equal

§Arguments
  • address: The address to find the block for.
§Returns
  • The block start address.

Auto Trait Implementations§

§

impl<R> Freeze for BytecodeLoader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for BytecodeLoader<R>
where R: RefUnwindSafe,

§

impl<R> Send for BytecodeLoader<R>
where R: Send,

§

impl<R> Sync for BytecodeLoader<R>
where R: Sync,

§

impl<R> Unpin for BytecodeLoader<R>
where R: Unpin,

§

impl<R> UnwindSafe for BytecodeLoader<R>
where R: UnwindSafe,

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

Source§

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

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.