neo-decompiler 0.8.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
import { formatOperand } from "./disassembler.js";
import { hex8, hex16 } from "./util.js";

export function renderPseudocode(instructions) {
  const lines = [];
  for (let i = 0; i < instructions.length; i++) {
    const instruction = instructions[i];
    let line = `${hex16(instruction.offset)}: ${renderMnemonic(instruction)}`;
    if (instruction.operand !== null) {
      line += ` ${formatOperand(instruction.operand)}`;
    }
    lines.push(line);
  }
  return lines.join("\n") + (instructions.length > 0 ? "\n" : "");
}

function renderMnemonic(instruction) {
  if (instruction.opcode.mnemonic === "UNKNOWN") {
    return `UNKNOWN_0x${hex8(instruction.opcode.byte)}`;
  }
  return instruction.opcode.mnemonic;
}