The old src/ppc.rs that re-implemented PPC formatting collapses into a 30-line shim that delegates to xenia-cpu's single-source-of-truth disasm. A new disasm.rs wraps the shared iterator and feeds enriched items (analysis context: function membership, xrefs, mnemonics) into pluggable sinks. Sinks split: text.rs (objdump-like output), json.rs (JSONL stream matching the new xenia dis --json mode), duckdb.rs (the analysis DB ingest). db.rs is restructured into ingest_instructions + write_analysis_results so a run can stop after raw ingest, and a new target_hex column lands on the instructions table. sql_views.rs adds five additive views layered on top of the raw tables. Tests: assert-based JSON-fixture goldens (disasm_goldens) and a PRAGMA-table_info schema golden (db_schema_golden) covering all ingested tables and the SQL views. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
29 lines
959 B
Rust
29 lines
959 B
Rust
//! Back-compat shim. The full PPC disassembler now lives in
|
|
//! [`xenia_cpu::disasm`] (single source of truth, sitting on top of the
|
|
//! canonical decoder). This module preserves the legacy `Decoded { base, ext }`
|
|
//! surface so existing call sites keep compiling while the analysis crate
|
|
//! migrates to `DisasmText` directly.
|
|
|
|
use xenia_cpu::decoder::decode;
|
|
use xenia_cpu::disasm::format;
|
|
|
|
/// Decoded instruction carrying both base and (optional) extended mnemonic forms.
|
|
pub struct Decoded {
|
|
pub base: String,
|
|
pub ext: Option<String>,
|
|
}
|
|
|
|
impl Decoded {
|
|
/// Returns the preferred display form (extended if available, else base).
|
|
pub fn display(&self) -> &str {
|
|
self.ext.as_deref().unwrap_or(&self.base)
|
|
}
|
|
}
|
|
|
|
/// Disassemble one 32-bit big-endian PowerPC instruction.
|
|
pub fn disasm(instr: u32, addr: u32) -> Decoded {
|
|
let d = decode(instr, addr);
|
|
let t = format(&d);
|
|
Decoded { base: t.disasm, ext: t.ext_disasm }
|
|
}
|