asm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Provides support for dealing with EVM assembly instructions (e.g., disassembling them).

Index

Constants

View Source
const (
	Numbers            = "1234567890"                                           // characters representing any decimal number
	HexadecimalNumbers = Numbers + "aAbBcCdDeEfF"                               // characters representing any hexadecimal
	Alpha              = "abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ" // characters representing alphanumeric
)

Variables

This section is empty.

Functions

func Disassemble

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

Return 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. 输入源码,返回一个管道接收token

func NewInstructionIterator

func NewInstructionIterator(code []byte) *instructionIterator

Create a new instruction iterator. 输入字节码(code),创建instructionIterator对象

func PrintDisassembled

func PrintDisassembled(code string) error

Pretty-print all disassembled EVM instructions to stdout. 直接打印到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. 创建新的编译对象,输入代表是否开启Debug

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 in to 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. 从输入管道中读取词法分析器解析的token

Jump to

Keyboard shortcuts

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