gbf_core/decompiler/handlers/
general.rs1#![deny(missing_docs)]
2
3use std::backtrace::Backtrace;
4
5use crate::{
6 decompiler::{
7 ProcessedInstruction, ProcessedInstructionBuilder,
8 function_decompiler::FunctionDecompilerError,
9 function_decompiler_context::FunctionDecompilerContext,
10 },
11 instruction::Instruction,
12 opcode::Opcode,
13};
14
15use super::OpcodeHandler;
16
17pub struct GeneralHandler;
19
20impl OpcodeHandler for GeneralHandler {
21 fn handle_instruction(
22 &self,
23 context: &mut FunctionDecompilerContext,
24 instruction: &Instruction,
25 ) -> Result<ProcessedInstruction, FunctionDecompilerError> {
26 match instruction.opcode {
27 Opcode::Pop => {
28 context.pop_one_node()?;
30 }
31 _ => {
32 return Err(FunctionDecompilerError::UnimplementedOpcode {
33 opcode: instruction.opcode,
34 context: context.get_error_context(),
35 backtrace: Backtrace::capture(),
36 });
37 }
38 }
39
40 Ok(ProcessedInstructionBuilder::new().build())
41 }
42}