mock

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package counter implements buffered position-based editing of byte slices.

Package mock provides lightweight contract call tracing and logging

Index

Constants

This section is empty.

Variables

View Source
var (
	GasImportPath      = "github.com/govm-net/vm/mock"
	GasPackageNickName = ""
	GasPackageName     = "mock"
	GasConsumeGasFunc  = "ConsumeGas"
)

Functions

func AddGasConsumption

func AddGasConsumption(packageName string, code []byte) ([]byte, error)

AddGasConsumption 添加gas消耗

func ConsumeGas

func ConsumeGas(amount int64)

ConsumeGas 消耗gas

func Enter

func Enter(contract core.Address, function string)

Enter records function entry by pushing the contract address onto the call stack

func Exit

func Exit(contract core.Address, function string)

Exit records function exit by popping the top contract address from the call stack

func GetCaller

func GetCaller() core.Address

GetCaller returns the address of the contract that called the current contract This correctly handles the case where a contract calls its own functions Returns an empty address if there's no caller (e.g., top-level call)

func GetCurrentContract

func GetCurrentContract() core.Address

GetCurrentContract returns the address of the currently executing contract Returns an empty address if the call stack is empty

func GetGas

func GetGas() int64

GetGas 获取剩余gas

func GetUsedGas

func GetUsedGas() int64

GetUsedGas 获取已使用的gas

func InitGas

func InitGas(initialGas int64)

InitGas 初始化gas

func RefundGas

func RefundGas(amount int64)

RefundGas 退还gas

func ResetGas

func ResetGas(initialGas int64)

ResetGas 重置gas

Types

type Block

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

Block represents the information about a basic block to be recorded in the analysis. Note: Our definition of basic block is based on control structures; we don't break apart && and ||. We could but it doesn't seem important enough to bother.

type Buffer

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

A Buffer is a queue of edits to apply to a given byte slice.

func NewBuffer

func NewBuffer(data []byte) *Buffer

NewBuffer returns a new buffer to accumulate changes to an initial data slice. The returned buffer maintains a reference to the data, so the caller must ensure the data is not modified until after the Buffer is done being used.

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

Bytes returns a new byte slice containing the original data with the queued edits applied.

func (*Buffer) Delete

func (b *Buffer) Delete(start, end int)

Delete delete

func (*Buffer) Insert

func (b *Buffer) Insert(pos int, new string)

Insert insert

func (*Buffer) Replace

func (b *Buffer) Replace(start, end int, new string)

Replace replace

func (*Buffer) String

func (b *Buffer) String() string

String returns a string containing the original data with the queued edits applied.

type File

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

File is a wrapper for the state of a file used in the parser. The basic parse tree walker is a method of this type.

func (*File) Visit

func (f *File) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

Jump to

Keyboard shortcuts

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