Skip to main content

Decompiler

Struct Decompiler 

Source
pub struct Decompiler { /* private fields */ }
Expand description

Main entry point used by the CLI and tests.

Implementations§

Source§

impl Decompiler

Source

pub fn new() -> Self

Create a new decompiler that permits unknown opcodes during disassembly.

This is equivalent to Decompiler::with_unknown_handling(UnknownHandling::Permit).

Source

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;
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn decompile_file_with_manifest<P, Q>( &self, nef_path: P, manifest_path: Option<Q>, output_format: OutputFormat, ) -> Result<Decompilation>
where P: AsRef<Path>, Q: AsRef<Path>,

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.

Trait Implementations§

Source§

impl Debug for Decompiler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Decompiler

Source§

fn default() -> Decompiler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.