neo-decompiler 0.7.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
use super::super::super::HighLevelEmitter;

impl HighLevelEmitter {
    pub(in super::super) fn find_initializer_index(
        statements: &[String],
        start: usize,
    ) -> Option<usize> {
        let mut index = start;
        while index > 0 {
            index -= 1;
            let line = statements[index].trim();
            if line.is_empty() || line.starts_with("//") {
                continue;
            }
            if line == "}" || line.ends_with("{") {
                break;
            }
            if line.contains('=') && line.ends_with(';') {
                if let Some(assign) = Self::parse_assignment(line) {
                    if assign.lhs.starts_with("loc")
                        || assign.lhs.starts_with("arg")
                        || assign.lhs.starts_with("static")
                    {
                        return Some(index);
                    }
                }
            }
        }
        None
    }

    pub(in super::super) fn previous_code_line(
        statements: &[String],
        mut index: usize,
    ) -> Option<usize> {
        while index > 0 {
            index -= 1;
            let line = statements[index].trim();
            if line.is_empty() || line.starts_with("//") || line == "}" {
                continue;
            }
            return Some(index);
        }
        None
    }
}