gbf_core/decompiler/handlers/
special_one_operand.rs#![deny(missing_docs)]
use crate::{
decompiler::{
ast::create_return, function_decompiler::FunctionDecompilerError,
function_decompiler_context::FunctionDecompilerContext, ProcessedInstruction,
ProcessedInstructionBuilder,
},
instruction::Instruction,
opcode::Opcode,
};
use super::OpcodeHandler;
pub struct SpecialOneOperandHandler;
impl OpcodeHandler for SpecialOneOperandHandler {
fn handle_instruction(
&self,
context: &mut FunctionDecompilerContext,
instruction: &Instruction,
) -> Result<ProcessedInstruction, FunctionDecompilerError> {
match instruction.opcode {
Opcode::Ret => {
let ret_val = context.pop_expression()?;
let ret = create_return(ret_val);
Ok(ProcessedInstructionBuilder::new()
.push_to_region(ret.into())
.build())
}
_ => Err(FunctionDecompilerError::UnimplementedOpcode(
instruction.opcode,
context.current_block_id.unwrap(),
)),
}
}
}