Documentation
¶
Overview ¶
Package disasm – disasm.go
Provides Disassemble(), which walks a decoded *ast.Program and produces a colourised, instruction-level listing of a .101 bytecode file – similar to the output of Python's `dis` module. The output never shows English source code; it shows raw opcodes and their operands so that compiled programs can be inspected without running or re-transpiling them.
The package is split into four files:
disasm.go – public API, disassembler struct, core helpers, run() statements.go – stmt() handler (all statement AST node types) expressions.go – expr() handler (all expression AST node types) styles.go – lipgloss renderer and colour-style variables
Package disasm – expressions.go ¶
expr() renders any AST expression node as a compact, operator-notation string suitable for appearing as an operand on a single disassembly line. argList() formats a function-call argument list. symOp() maps English-prose operator names to conventional symbols.
Package disasm – statements.go ¶
stmt() dispatches over every AST statement node type and emits the corresponding opcode line(s). Nested bodies (function bodies, loop bodies, if branches, try/catch blocks, struct fields) are indented by incrementing d.depth around the recursive calls.
Package disasm – styles.go ¶
Dracula-inspired lipgloss colour palette shared across all disassembler files. A single renderer is created once at package init time so that TrueColor is always requested regardless of the caller's environment. Individual helpers then use d.s() to conditionally apply styles at run-time based on whether the caller enabled colour output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Disassemble ¶
func Disassemble(program *ast.Program, filename string, useColor, friendlyOps bool, importDepth, unrollDepth int) string
Disassemble produces a colorised, instruction-level listing of a decoded .101 bytecode program. filename is used only for the header line. When useColor is false the output contains no ANSI escape codes. When friendlyOps is true, comparison/logical operators are shown as English prose (e.g. "is less than or equal to") instead of their symbolic equivalents (e.g. "<="). friendlyOps has no effect on arithmetic operators (+, -, *, /, %) which are always shown symbolically.
importDepth controls how many levels of imported files are also disassembled and appended to the output. Pass 0 (the default) to show only the top-level file. Pass -1 for unlimited depth.
unrollDepth controls how many levels of nested function-call arguments are extracted into temporary declarations to improve readability. Pass 0 (the default) for no unrolling. Pass -1 for fully recursive unrolling.
Types ¶
This section is empty.