Help us shape the future of Go! Take the 2026 Go Developer Survey

asm

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: GPL-3.0, LGPL-3.0, BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package asm provides support for dealing with EVM assembly instructions (e.g., disassembling them).

Index

Constants

View Source
const (
	Numbers            = "1234567890"
	HexadecimalNumbers = Numbers + "aAbBcCdDeEfF"
)

Variables

This section is empty.

Functions

func DisablePC

func DisablePC(fn func()) func()

DisablePC disables the PC (program counter) display in the output.

func Disassemble

func Disassemble(code []byte) ([]string, error)

Disassemble returns the disassembled EVM instructions.

func HasValidJumpdest

func HasValidJumpdest(code []byte) bool

HasValidJumpdest returns true if the destination is a valid jump destination.

func IsProgramCounterWithinJumpDest

func IsProgramCounterWithinJumpDest(code []byte, pc int) error

IsProgramCounterWithinJumpDest returns true if the program counter is within a valid jump destination.

func Lex

func Lex(source []byte, debug bool) <-chan token

lex lexes the program by name with the given source.

func LexProgram

func LexProgram(source string) ([]token, error)

LexProgram lexes the given source and returns tokens.

func PrintDisassembled

func PrintDisassembled(code []byte) error

PrintDisassembled pretty-prints the disassembled bytecode.

Types

type Compiler

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

Compiler is a basic assembly language compiler.

func NewCompiler

func NewCompiler(debug bool) *Compiler

NewCompiler returns a new Compiler ready for use.

func (*Compiler) Compile

func (c *Compiler) Compile() ([]byte, []error)

Compile compiles the current tokens and returns the bytecode.

func (*Compiler) Feed

func (c *Compiler) Feed(ch <-chan token)

Feed feeds tokens to the compiler.

type InstructionIterator

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

InstructionIterator iterates over EVM bytecode instructions.

func NewInstructionIterator

func NewInstructionIterator(code []byte) *InstructionIterator

NewInstructionIterator creates a new instruction iterator.

func (*InstructionIterator) Arg

func (it *InstructionIterator) Arg() []byte

Arg returns the argument of the current instruction.

func (*InstructionIterator) Error

func (it *InstructionIterator) Error() error

Error returns any error that occurred during iteration.

func (*InstructionIterator) Next

func (it *InstructionIterator) Next() bool

Next moves to the next instruction. Returns true if there is a next instruction.

func (*InstructionIterator) Op

func (it *InstructionIterator) Op() vm.OpCode

Op returns the opcode of the current instruction.

func (*InstructionIterator) PC

func (it *InstructionIterator) PC() int

PC returns the program counter of the current instruction.

Jump to

Keyboard shortcuts

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