assembly

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateWebDisassembly

func GenerateWebDisassembly(cob *scripting.COB) (string, error)

GenerateWebDisassembly creates structured disassembly data for web visualization. It accepts a *scripting.COB directly to avoid circular dependencies.

Types

type Assembler

type Assembler struct {
	// contains filtered or unexported fields
}

Assembler converts assembly listings back to COB bytecode.

func NewAssembler

func NewAssembler() *Assembler

NewAssembler creates a new assembler.

func (*Assembler) Assemble

func (a *Assembler) Assemble(text string) (*scripting.COB, error)

Assemble parses an assembly listing and produces a COB.

The listing uses structured directives for metadata:

.version 4
.statics 4
.piece base
.piece turret

.script Create
0000  PUSH_CONST           0
0004  RETURN

Comments (lines starting with ; or //) are ignored.

type Disassembler

type Disassembler struct {
	// contains filtered or unexported fields
}

Disassembler creates a bytecode view for a single script.

func NewDisassembler

func NewDisassembler(instructions []scripting.Instruction, name string, codeOffset uint32) *Disassembler

NewDisassembler creates a new disassembly view.

func (*Disassembler) Render

func (dv *Disassembler) Render(format Format) string

Render produces disassembly output using the given format.

type Format

type Format int

Format controls the output style of disassembly.

const (
	// Plain produces a clean, minimal listing — one instruction per line,
	// no box-drawing, no flow arrows, no hex opcodes.
	Plain Format = iota
	// Annotated produces the rich view with Unicode box-drawing,
	// flow-control arrows, jump target annotations, and hex opcodes.
	Annotated
)

type WebDisassemblyData

type WebDisassemblyData struct {
	Header  WebDisassemblyHeader   `json:"header"`
	Scripts []WebDisassemblyScript `json:"scripts"`
}

WebDisassemblyData represents the complete disassembly for web visualization

type WebDisassemblyHeader

type WebDisassemblyHeader struct {
	Version     uint32   `json:"version"`
	ScriptCount uint32   `json:"scriptCount"`
	PieceCount  uint32   `json:"pieceCount"`
	CodeLength  int      `json:"codeLength"`
	PieceNames  []string `json:"pieceNames"`
	StaticVars  []string `json:"staticVars"`
	StaticCount uint32   `json:"staticCount"`
}

WebDisassemblyHeader contains file-level metadata

type WebDisassemblyScript

type WebDisassemblyScript struct {
	Index        int              `json:"index"`
	Name         string           `json:"name"`
	Offset       uint32           `json:"offset"`
	Instructions []WebInstruction `json:"instructions"`
	Jumps        []WebJump        `json:"jumps"`
}

WebDisassemblyScript represents a single script for web visualization

type WebInstruction

type WebInstruction struct {
	Index       int    `json:"index"`
	Offset      uint32 `json:"offset"`
	Opcode      string `json:"opcode"`
	OpcodeHex   string `json:"opcodeHex"`
	Operand     int32  `json:"operand"`
	OperandHex  string `json:"operandHex"`
	Description string `json:"description"`
}

WebInstruction represents a single instruction for web display

type WebJump

type WebJump struct {
	FromIndex  int    `json:"fromIndex"`
	FromOffset uint32 `json:"fromOffset"`
	ToIndex    int    `json:"toIndex"`
	ToOffset   uint32 `json:"toOffset"`
	IsBackward bool   `json:"isBackward"`
	Type       string `json:"type"` // "JUMP" or "JUMP_IF_FALSE"
}

WebJump represents a jump instruction for visualization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL