gbf_core::decompiler::function_decompiler_context

Struct FunctionDecompilerContext

Source
pub struct FunctionDecompilerContext {
    pub block_ast_node_stack: HashMap<BasicBlockId, Vec<ExecutionFrame>>,
    pub current_block_id: Option<BasicBlockId>,
    pub current_region_id: Option<RegionId>,
    pub opcode_handlers: HashMap<Opcode, Box<dyn OpcodeHandler>>,
    pub ssa_context: SsaContext,
}
Expand description

Manages the state of the decompiler, including per-block AST stacks and current processing context.

Fields§

§block_ast_node_stack: HashMap<BasicBlockId, Vec<ExecutionFrame>>

AST node stacks for each basic block.

§current_block_id: Option<BasicBlockId>

The current basic block being processed.

§current_region_id: Option<RegionId>

The current region being processed.

§opcode_handlers: HashMap<Opcode, Box<dyn OpcodeHandler>>

The handlers for each opcode.

§ssa_context: SsaContext

The SSA Context

Implementations§

Source§

impl FunctionDecompilerContext

Source

pub fn new() -> Self

Creates a new, empty context.

Source

pub fn start_block_processing( &mut self, block_id: BasicBlockId, region_id: RegionId, ) -> Result<(), FunctionDecompilerError>

Starts processing a new basic block.

§Arguments
  • block_id: The ID of the basic block to start processing.
  • region_id: The ID of the region the basic block belongs to.
§Errors
  • Returns FunctionDecompilerError if there is an issue initializing the block stack.
Source

pub fn process_instruction( &mut self, instr: &Instruction, ) -> Result<ProcessedInstruction, FunctionDecompilerError>

Processes an instruction and updates the AST stack.

§Arguments
  • instr: The instruction to process.
§Errors
  • Returns FunctionDecompilerError for invalid or unexpected instructions.
Source

pub fn get_stack(&self, block_id: &BasicBlockId) -> Option<&Vec<ExecutionFrame>>

Retrieves the AST stack for a basic block.

Source

pub fn pop_one_node(&mut self) -> Result<AstKind, FunctionDecompilerError>

Pops an AST node from the current basic block’s stack.

Source

pub fn pop_expression(&mut self) -> Result<ExprKind, FunctionDecompilerError>

Pops an expression from the current basic block’s stack.

Source

pub fn pop_assignable( &mut self, ) -> Result<AssignableKind, FunctionDecompilerError>

Pops an assignable expression from the current basic block’s stack.

Source

pub fn pop_identifier( &mut self, ) -> Result<IdentifierNode, FunctionDecompilerError>

Pops an identifier from the current basic block’s stack.

Source

pub fn push_one_node( &mut self, node: AstKind, ) -> Result<(), FunctionDecompilerError>

Pushes an AST node to the current basic block’s stack.

Trait Implementations§

Source§

impl Default for FunctionDecompilerContext

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