Bytecode disassembler

koskari.dis

Disassembler for Koskari code objects. Similar to Python’s dis module: unpacks constant pool, vars (local_syms), closure refs (closure_syms from namespace_spec), and prints indexed opcodes with human-readable arguments (e.g. constant pool index as repr of value, jump targets as instruction indices). Also accepts BoundMethod (unwraps __func__ for bytecode, prints __self__ in a leading section).

koskari.dis.dis(x, file=None)

Print a disassembly of a Koskari Code or Function object.

For Function: prints a leading section with function instance details (name, formals, closures), then the disassembly of its code.

For BoundMethod: prints a bound-method section (__self__), then the same function-instance section and code disassembly as for __func__.

For Code: output includes constant pool (with NamespaceSpec entries expanded to show their locals and closures), vars (local_syms from namespace_spec), closure refs (closure_syms from namespace_spec), and indexed instructions with decoded arguments. FAST_* instructions show whether the slot is a local or closure. PUSH_NS and PUSH_COLLECT instructions are annotated with the namespace ID (ns#K) and name of the NamespaceSpec they push.

Parameters:
  • x – Code, Expression (unwraps to Code), Function, or BoundMethod

  • file – file-like object to print to (default: stdout)