Neo N3 NEF decompiler: parse, disassemble, lift bytecode to high-level pseudocode and C# skeletons, with a CLI, JSON reports, and optional WebAssembly bindings.
usestd::collections::BTreeSet;usesuper::super::basic_block::BlockId;usesuper::Cfg;implCfg{/// Determine which basic blocks are reachable from the entry block.
////// This is the foundation for dead-code detection: blocks that are not
/// reachable via CFG edges are considered unreachable/dead.
#[must_use]pubfnreachable_blocks(&self)->BTreeSet<BlockId>{letmut visited =BTreeSet::new();if!self.blocks.contains_key(&self.entry){return visited;}letmut stack =vec![self.entry];whileletSome(id)= stack.pop(){if!visited.insert(id){continue;}for&succ inself.successors(id){ifself.blocks.contains_key(&succ){
stack.push(succ);}}}
visited
}/// Determine which basic blocks are unreachable (dead code).
#[must_use]pubfnunreachable_blocks(&self)->BTreeSet<BlockId>{let reachable =self.reachable_blocks();self.blocks
.keys().copied().filter(|id|!reachable.contains(id)).collect()}/// Check whether a block is reachable from the entry block.
////// **Note:** This recomputes the full reachable set on every call (O(V+E)).
/// When checking multiple blocks, call [`reachable_blocks`](Self::reachable_blocks)
/// once and query the returned set instead.
#[must_use]pubfnis_reachable(&self, id: BlockId)->bool{self.reachable_blocks().contains(&id)}}