#![cfg_attr(coverage_nightly, coverage(off))]
use crate::services::deep_wasm::{DeepWasmError, DeepWasmResult};
use serde::{Deserialize, Serialize};
use wasmparser::{FunctionBody, Operator};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DisassembledInstruction {
pub offset: u32,
pub mnemonic: String,
pub operands: Vec<String>,
pub stack_effect: StackEffect,
pub category: String,
pub cost_estimate: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StackEffect {
pub pops: u32,
pub pushes: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DisassembledFunction {
pub function_index: u32,
pub name: Option<String>,
pub instructions: Vec<DisassembledInstruction>,
pub basic_blocks: Vec<BasicBlock>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BasicBlock {
pub id: u32,
pub start_offset: u32,
pub end_offset: u32,
pub block_type: String,
pub successors: Vec<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InstructionPattern {
pub name: String,
pub description: String,
pub start_offset: u32,
pub end_offset: u32,
pub instruction_count: u32,
pub suspicious: bool,
pub suspicion_reason: Option<String>,
}
pub struct Disassembler {
detect_patterns: bool,
}
include!("disassembler_core.rs");
include!("disassembler_formatting.rs");
include!("disassembler_tests.rs");