Skip to main content

gcrecomp_core/recompiler/analysis/
mod.rs

1pub mod control_flow;
2pub mod data_flow;
3pub mod type_inference;
4pub mod inter_procedural;
5pub mod loop_analysis;
6
7/// Type information for decompiled/recompiled code
8#[derive(Debug, Clone, PartialEq)]
9pub enum TypeInfo {
10    /// Unknown type (not yet inferred)
11    Unknown,
12    /// Void type
13    Void,
14    /// Integer type with signedness and size
15    Integer { signed: bool, size: u8 },
16    /// Pointer to another type
17    Pointer { pointee: Box<TypeInfo> },
18    /// Floating point type
19    Float { size: u8 },
20    /// Array type
21    Array { element: Box<TypeInfo>, size: usize },
22    /// Structure type
23    Struct { name: String, fields: Vec<(String, TypeInfo)> },
24}
25
26/// Function metadata extracted from analysis
27#[derive(Debug, Clone)]
28pub struct FunctionMetadata {
29    /// Function start address
30    pub address: u32,
31    /// Function name
32    pub name: String,
33    /// Function size in bytes
34    pub size: u32,
35    /// Calling convention (e.g., "cdecl", "fastcall")
36    pub calling_convention: String,
37    /// Function parameters
38    pub parameters: Vec<ParameterInfo>,
39    /// Return type
40    pub return_type: Option<TypeInfo>,
41    /// Local variables
42    pub local_variables: Vec<VariableInfo>,
43    /// Basic block addresses
44    pub basic_blocks: Vec<u32>,
45}
46
47/// Parameter information
48#[derive(Debug, Clone)]
49pub struct ParameterInfo {
50    /// Parameter name
51    pub name: String,
52    /// Parameter type
53    pub type_info: TypeInfo,
54    /// Register used (if any)
55    pub register: Option<u8>,
56    /// Stack offset (if stack parameter)
57    pub stack_offset: i32,
58}
59
60/// Variable information
61#[derive(Debug, Clone)]
62pub struct VariableInfo {
63    /// Variable name
64    pub name: String,
65    /// Variable type
66    pub type_info: TypeInfo,
67    /// Stack offset
68    pub stack_offset: i32,
69    /// Scope start address
70    pub scope_start: u32,
71    /// Scope end address
72    pub scope_end: u32,
73}
74