pub struct FunctionDecompilerContext {
pub block_ast_node_stack: HashMap<BasicBlockId, Vec<ExecutionFrame>>,
pub block_ast_phi_count: HashMap<BasicBlockId, usize>,
pub current_block_id: BasicBlockId,
pub opcode_handlers: HashMap<Opcode, Box<dyn OpcodeHandler>>,
pub ssa_context: SsaContext,
pub current_instruction: Instruction,
pub register_mapping: HashMap<usize, ExprKind>,
}
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.
block_ast_phi_count: HashMap<BasicBlockId, usize>
The number of phi nodes in each basic block.
current_block_id: BasicBlockId
The current basic block being processed.
opcode_handlers: HashMap<Opcode, Box<dyn OpcodeHandler>>
The handlers for each opcode.
ssa_context: SsaContext
The SSA Context
current_instruction: Instruction
The current instruction being processed.
register_mapping: HashMap<usize, ExprKind>
Register mapping for the current function
Implementations§
Source§impl FunctionDecompilerContext
impl FunctionDecompilerContext
Sourcepub fn new(start_block_id: BasicBlockId) -> Self
pub fn new(start_block_id: BasicBlockId) -> Self
Creates a new, empty context. We initialize with the starting block ID and region ID.
Sourcepub fn start_block_processing(
&mut self,
block_id: BasicBlockId,
) -> Result<(), FunctionDecompilerError>
pub fn start_block_processing( &mut self, block_id: BasicBlockId, ) -> Result<(), FunctionDecompilerError>
Sourcepub fn process_instruction(
&mut self,
instr: &Instruction,
) -> Result<ProcessedInstruction, FunctionDecompilerError>
pub fn process_instruction( &mut self, instr: &Instruction, ) -> Result<ProcessedInstruction, FunctionDecompilerError>
Sourcepub fn get_error_context(&self) -> Box<FunctionDecompilerErrorContext>
pub fn get_error_context(&self) -> Box<FunctionDecompilerErrorContext>
If an error happens, this helper function will return the context of the error.
Sourcepub fn get_stack(&self, block_id: &BasicBlockId) -> Option<&Vec<ExecutionFrame>>
pub fn get_stack(&self, block_id: &BasicBlockId) -> Option<&Vec<ExecutionFrame>>
Retrieves the AST stack for a basic block.
Sourcepub fn new_phi(&mut self) -> PhiNode
pub fn new_phi(&mut self) -> PhiNode
Create a new phi node, increment the phi count for the current block, and return the new phi node.
Sourcepub fn pop_building_array(
&mut self,
) -> Result<ArrayKind, FunctionDecompilerError>
pub fn pop_building_array( &mut self, ) -> Result<ArrayKind, FunctionDecompilerError>
Pops an array from the current basic block’s stack and returns it as an ArrayKind.
- If no frame is available, returns a PhiArray with empty elements.
- If the last frame is a BuildingArray, returns it as a MergedArray.
- If the last frame is a StandaloneNode, pops additional nodes from the stack (both StandaloneNode and BuildingArray frames) and merges them into a PhiArray with a newly created phi node.
Sourcepub fn pop_one_node(&mut self) -> Result<AstKind, FunctionDecompilerError>
pub fn pop_one_node(&mut self) -> Result<AstKind, FunctionDecompilerError>
Pops an AST node from the current basic block’s stack.
Sourcepub fn pop_expression(&mut self) -> Result<ExprKind, FunctionDecompilerError>
pub fn pop_expression(&mut self) -> Result<ExprKind, FunctionDecompilerError>
Pops an expression from the current basic block’s stack.
Sourcepub fn pop_identifier(
&mut self,
) -> Result<P<IdentifierNode>, FunctionDecompilerError>
pub fn pop_identifier( &mut self, ) -> Result<P<IdentifierNode>, FunctionDecompilerError>
Pops an identifier from the current basic block’s stack.
Sourcepub fn push_one_node(
&mut self,
node: AstKind,
) -> Result<(), FunctionDecompilerError>
pub fn push_one_node( &mut self, node: AstKind, ) -> Result<(), FunctionDecompilerError>
Pushes an AST node to the current basic block’s stack.