Expand description
Arch-codec trait + open registry.
The univdreams decompile/compile pipeline is arch-agnostic at
its boundaries — the lower path takes a parsed .ud source and
emits bytes; the decompile path takes a binary and emits .ud
source. Between those boundaries, every instruction-shaped
decision belongs to a specific architecture.
This crate defines the shared shape: ArchCodec is the trait
every arch backend implements; registry is the open registry
consumers (CLI, wasm) populate at process start. The lower path
resolves a codec from the parsed @module block, then asks it to
encode each statement that carries semantic fields the codec can
re-emit (jumps, calls, moves, returns). Anything the codec
doesn’t model returns ArchError::Unsupported and the pinned
bytes field on the statement is the fallback.
§Layering
This crate intentionally has no dependency on ud-ast — it
takes raw (arch, e_machine) pairs at the registry boundary
and leaves the marshaling from a parsed ud_ast::Module to the
caller (ud-translate). That break is what keeps the dependency
graph acyclic: ud-ast depends on ud-arch-x86 for emitter
helpers, and the arch crates depend on ud-arch-codec, so
ud-arch-codec cannot also depend on ud-ast.
Prologue/epilogue parameters (which today live in ud-ast)
flow through the lower path as arch-specific types, not through
the trait. A follow-up commit will introduce a shared
representation here once we settle on a cross-arch shape.
Re-exports§
pub use registry::for_arch;pub use registry::register;pub use registry::CodecFactory;
Modules§
Structs§
- Encode
Hints - Per-call encoding hints that arches interpret in their own
convention. Today the only hint is
wide(x86’s short-vs-rel32 toggle); fixed-width arches (BPF, AArch64) ignore it. - Switch
Spec - Structured switch-dispatch spec, passed to
ArchCodec::encode_switch_dispatch. Holds everything the x86 MSVC encoder needs; arches that don’t model jump-table dispatch returnUnsupported.
Enums§
Traits§
- Arch
Codec - The shared interface every arch backend implements.