pub struct Decompiler { /* private fields */ }Expand description
Main entry point used by the CLI and tests.
Implementations§
Source§impl Decompiler
impl Decompiler
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new decompiler that permits unknown opcodes during disassembly.
This is equivalent to Decompiler::with_unknown_handling(UnknownHandling::Permit).
Sourcepub fn with_unknown_handling(handling: UnknownHandling) -> Self
pub fn with_unknown_handling(handling: UnknownHandling) -> Self
Create a new decompiler configured with the desired unknown-opcode policy.
Unknown opcodes can appear when disassembling corrupted inputs or when
targeting a newer VM revision. Use crate::UnknownHandling::Error to
fail fast, or crate::UnknownHandling::Permit to emit Unknown
instructions and continue.
§Examples
use neo_decompiler::{Decompiler, UnknownHandling};
let decompiler = Decompiler::with_unknown_handling(UnknownHandling::Error);
let _ = decompiler;Sourcepub fn with_inline_single_use_temps(self, enabled: bool) -> Self
pub fn with_inline_single_use_temps(self, enabled: bool) -> Self
Enable experimental inlining of single-use temporary variables in the high-level view.
This can reduce noise in lifted code by replacing temps like t0 with their RHS
at the first use site, but it may reduce readability for larger expressions.
Sourcepub fn decompile_bytes(&self, bytes: &[u8]) -> Result<Decompilation>
pub fn decompile_bytes(&self, bytes: &[u8]) -> Result<Decompilation>
Decompile a NEF blob already loaded in memory.
§Errors
Returns an error if the NEF container is malformed or disassembly fails.
Sourcepub fn disassemble_bytes(&self, bytes: &[u8]) -> Result<DisassemblyOutput>
pub fn disassemble_bytes(&self, bytes: &[u8]) -> Result<DisassemblyOutput>
Disassemble a NEF blob already loaded in memory.
This fast path parses the NEF container and decodes instructions only; it skips CFG construction, analysis passes, and renderers.
§Errors
Returns an error if the NEF container is malformed or disassembly fails.
Sourcepub fn decompile_bytes_with_manifest(
&self,
bytes: &[u8],
manifest: Option<ContractManifest>,
output_format: OutputFormat,
) -> Result<Decompilation>
pub fn decompile_bytes_with_manifest( &self, bytes: &[u8], manifest: Option<ContractManifest>, output_format: OutputFormat, ) -> Result<Decompilation>
Decompile a NEF blob using an optional manifest.
§Errors
Returns an error if the NEF container is malformed or disassembly fails.
Sourcepub fn decompile_file<P: AsRef<Path>>(&self, path: P) -> Result<Decompilation>
pub fn decompile_file<P: AsRef<Path>>(&self, path: P) -> Result<Decompilation>
Decompile a NEF file from disk.
§Errors
Returns an error if the file cannot be read, the NEF container is malformed, or disassembly fails.
Sourcepub fn disassemble_file<P: AsRef<Path>>(
&self,
path: P,
) -> Result<DisassemblyOutput>
pub fn disassemble_file<P: AsRef<Path>>( &self, path: P, ) -> Result<DisassemblyOutput>
Disassemble a NEF file from disk.
§Errors
Returns an error if the file cannot be read, the NEF container is malformed, or disassembly fails.
Sourcepub fn decompile_file_with_manifest<P, Q>(
&self,
nef_path: P,
manifest_path: Option<Q>,
output_format: OutputFormat,
) -> Result<Decompilation>
pub fn decompile_file_with_manifest<P, Q>( &self, nef_path: P, manifest_path: Option<Q>, output_format: OutputFormat, ) -> Result<Decompilation>
Decompile a NEF file alongside an optional manifest file.
§Errors
Returns an error if either file cannot be read, the NEF container is malformed, the manifest JSON is invalid, or disassembly fails.