Documentation
¶
Overview ¶
Package asm provides support for dealing with EVM assembly instructions (e.g., disassembling them).
Index ¶
- Constants
- func DisablePC(fn func()) func()
- func Disassemble(code []byte) ([]string, error)
- func HasValidJumpdest(code []byte) bool
- func IsProgramCounterWithinJumpDest(code []byte, pc int) error
- func Lex(source []byte, debug bool) <-chan token
- func LexProgram(source string) ([]token, error)
- func PrintDisassembled(code []byte) error
- type Compiler
- type InstructionIterator
Constants ¶
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 ¶
Disassemble returns the disassembled EVM instructions.
func HasValidJumpdest ¶
HasValidJumpdest returns true if the destination is a valid jump destination.
func IsProgramCounterWithinJumpDest ¶
IsProgramCounterWithinJumpDest returns true if the program counter is within a valid jump destination.
func LexProgram ¶
LexProgram lexes the given source and returns tokens.
func PrintDisassembled ¶
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 ¶
NewCompiler returns a new Compiler ready for use.
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.