neo-decompiler 0.11.0

Neo N3 NEF decompiler: parse, disassemble, lift bytecode to high-level pseudocode and C# skeletons, with a CLI, JSON reports, and optional WebAssembly bindings.
Documentation
mod checksum;
mod method_tokens;
mod parse;

use std::fmt;

use super::NefFile;

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct NefParseOutput {
    pub(crate) nef: NefFile,
    pub(crate) warnings: Vec<NefParseWarning>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum NefParseWarning {
    InvalidMethodTokenCallFlags {
        index: usize,
        flags: u8,
        allowed: u8,
    },
}

impl fmt::Display for NefParseWarning {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            NefParseWarning::InvalidMethodTokenCallFlags {
                index,
                flags,
                allowed,
            } => write!(
                f,
                "method token #{index} call flags 0x{flags:02X} contain unsupported bits (allowed mask 0x{allowed:02X}); preserving raw flags for decompilation"
            ),
        }
    }
}

/// Parser for Neo N3 NEF containers.
///
/// This type is stateless and can be reused across many parse calls.
#[derive(Debug, Default, Clone, Copy)]
pub struct NefParser;

impl NefParser {
    /// Create a new NEF parser.
    #[must_use]
    pub fn new() -> Self {
        Self
    }
}