asm

package
v1.14.9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: GPL-3.0 Imports: 11 Imported by: 252

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disassemble

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

Disassemble returns all disassembled EVM instructions in human-readable format.

func Lex

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

Lex lexes the program by name with the given source. It returns a channel on which the tokens are delivered.

func NewInstructionIterator

func NewInstructionIterator(code []byte) *instructionIterator

NewInstructionIterator creates a new instruction iterator.

func PrintDisassembled

func PrintDisassembled(code string) error

PrintDisassembled pretty-print all disassembled EVM instructions to stdout.

Types

type Compiler

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

Compiler contains information about the parsed source and holds the tokens for the program.

func NewCompiler

func NewCompiler(debug bool) *Compiler

NewCompiler returns a new allocated compiler.

func (*Compiler) Compile

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

Compile compiles the current tokens and returns a binary string that can be interpreted by the EVM and an error if it failed.

compile is the second stage in the compile phase which compiles the tokens to EVM instructions.

func (*Compiler) Feed

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

Feed feeds tokens into ch and are interpreted by the compiler.

feed is the first pass in the compile stage as it collects the used labels in the program and keeps a program counter which is used to determine the locations of the jump dests. The labels can than be used in the second stage to push labels and determine the right position.

Jump to

Keyboard shortcuts

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