mm

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PoolOfIntPools = &IntPoolPool{
	pools: make([]*IntPool, 0, poolDefaultCap),
}

PoolOfIntPools 内存缓冲池

Functions

func MemoryCall

func MemoryCall(stack *Stack) *big.Int

MemoryCall call所需内存大小

func MemoryCallDataCopy

func MemoryCallDataCopy(stack *Stack) *big.Int

MemoryCallDataCopy callDataCopy所需内存大小

func MemoryCodeCopy

func MemoryCodeCopy(stack *Stack) *big.Int

MemoryCodeCopy codeCopy所需内存大小

func MemoryCreate

func MemoryCreate(stack *Stack) *big.Int

MemoryCreate create所需内存大小

func MemoryDelegateCall

func MemoryDelegateCall(stack *Stack) *big.Int

MemoryDelegateCall delegateCall所需内存大小

func MemoryExtCodeCopy

func MemoryExtCodeCopy(stack *Stack) *big.Int

MemoryExtCodeCopy extCodeCopy所需内存大小

func MemoryLog

func MemoryLog(stack *Stack) *big.Int

MemoryLog log所需内存大小

func MemoryMLoad

func MemoryMLoad(stack *Stack) *big.Int

MemoryMLoad mload所需内存大小

func MemoryMStore

func MemoryMStore(stack *Stack) *big.Int

MemoryMStore mstore所需内存大小

func MemoryMStore8

func MemoryMStore8(stack *Stack) *big.Int

MemoryMStore8 mstore8所需内存大小

func MemoryReturn

func MemoryReturn(stack *Stack) *big.Int

MemoryReturn return所需内存大小

func MemoryReturnDataCopy

func MemoryReturnDataCopy(stack *Stack) *big.Int

MemoryReturnDataCopy returnDataCopy所需内存大小

func MemoryRevert

func MemoryRevert(stack *Stack) *big.Int

MemoryRevert revert所需内存大小

func MemorySha3

func MemorySha3(stack *Stack) *big.Int

MemorySha3 sha3计算所需内存大小

func MemoryStaticCall

func MemoryStaticCall(stack *Stack) *big.Int

MemoryStaticCall staticCall所需内存大小

Types

type IntPool

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

IntPool big.Int组成的内存池

func NewIntPool

func NewIntPool() *IntPool

NewIntPool 创建新的内存池

func (*IntPool) Get

func (p *IntPool) Get() *big.Int

Get 取数据

func (*IntPool) GetZero

func (p *IntPool) GetZero() *big.Int

GetZero 返回一个零值的big.Int

func (*IntPool) Put

func (p *IntPool) Put(is ...*big.Int)

Put 存数据

type IntPoolPool

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

IntPoolPool 用于管理IntPool的Pool

func (*IntPoolPool) Get

func (ipp *IntPoolPool) Get() *IntPool

Get 返回一个可用的内存池

func (*IntPoolPool) Put

func (ipp *IntPoolPool) Put(ip *IntPool)

Put 放入一个初始化过的内存池

type Memory

type Memory struct {
	// Store 内存中存储的数据
	Store []byte
	// LastGasCost 上次开辟内存消耗的Gas
	LastGasCost uint64
}

Memory 内存操作封装,在EVM中使用此对象模拟物理内存

func NewMemory

func NewMemory() *Memory

NewMemory 创建内存对象结构

func (*Memory) Data

func (m *Memory) Data() []byte

Data 返回内存中的原始数据引用

func (*Memory) Get

func (m *Memory) Get(offset, size int64) (cpy []byte)

Get 获取内存中制定偏移量开始的指定长度的数据,返回数据的拷贝而非引用

func (*Memory) GetPtr

func (m *Memory) GetPtr(offset, size int64) []byte

GetPtr 同Get操作,不过这里返回的是数据引用

func (*Memory) Len

func (m *Memory) Len() int

Len 返回内存中已开辟空间的大小(以字节计算)

func (*Memory) Print

func (m *Memory) Print()

Print 打印内存中的数据(调试用)

func (*Memory) Resize

func (m *Memory) Resize(size uint64)

Resize 扩充内存到指定大小

func (*Memory) Set

func (m *Memory) Set(offset, size uint64, value []byte) (err error)

Set 设置内存中的值, value => offset:offset + size

func (*Memory) Set32

func (m *Memory) Set32(offset uint64, val *big.Int) (err error)

Set32 从offset开始设置32个字节的内存值,如果值长度不足32个字节,左零值填充

type MemorySizeFunc

type MemorySizeFunc func(*Stack) *big.Int

MemorySizeFunc 计算所需内存大小

type Stack

type Stack struct {
	Items []*big.Int
}

Stack 栈对象封装,提供常用的栈操作

func NewStack

func NewStack() *Stack

NewStack 新创建栈对象

func (*Stack) Back

func (st *Stack) Back(n int) *big.Int

Back 返回第n个取值

func (*Stack) Data

func (st *Stack) Data() []*big.Int

Data 返回栈中的所有底层数据

func (*Stack) Dup

func (st *Stack) Dup(pool *IntPool, n int)

Dup 复制栈中指定位置的数据的栈顶

func (*Stack) Len

func (st *Stack) Len() int

Len 栈长度

func (*Stack) Peek

func (st *Stack) Peek() *big.Int

Peek 返回顶端数据

func (*Stack) Pop

func (st *Stack) Pop() (ret *big.Int)

Pop 弹出栈顶数据

func (*Stack) Print

func (st *Stack) Print()

Print 印栈对象(调试用)

func (*Stack) Push

func (st *Stack) Push(d *big.Int)

Push 数据入栈

func (*Stack) PushN

func (st *Stack) PushN(ds ...*big.Int)

PushN 同时压栈多个数据

func (*Stack) Require

func (st *Stack) Require(n int) error

Require 检查栈是否满足长度要求

func (*Stack) Swap

func (st *Stack) Swap(n int)

Swap 将栈顶数据和栈中指定位置的数据互换位置

type StackValidationFunc

type StackValidationFunc func(*Stack) error

StackValidationFunc 校验栈中数据是否满足计算要求

func MakeDupStackFunc

func MakeDupStackFunc(n int) StackValidationFunc

MakeDupStackFunc 创建栈大小计算方法对象

func MakeStackFunc

func MakeStackFunc(pop, push int) StackValidationFunc

MakeStackFunc 栈校验的通用逻辑封装(主要就是检查栈的深度和空间是否够用)

func MakeSwapStackFunc

func MakeSwapStackFunc(n int) StackValidationFunc

MakeSwapStackFunc 创建栈大小计算方法对象

Jump to

Keyboard shortcuts

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