program

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunProgram

func RunProgram(testFn func() error) error

RunProgram parses flags (for profiling), and executes teh testFn

Types

type Program

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

func NewProgram

func NewProgram() *Program

func (*Program) AddAll

func (p *Program) AddAll(data []byte)

AddAll adds the data to the Program

func (*Program) Bytecode

func (p *Program) Bytecode() []byte

Bytecode returns the Program bytecode

func (*Program) Call

func (p *Program) Call(gas *big.Int, address, value, inOffset, inSize, outOffset, outSize interface{})

Call is a convenience function to make a call

func (*Program) CallCode

func (p *Program) CallCode(gas *big.Int, address, value, inOffset, inSize, outOffset, outSize interface{})

func (*Program) CreateAndCall

func (p *Program) CreateAndCall(code []byte, isCreate2 bool, callOp ops.OpCode)

CreateAndCall calls create/create2 with the given bytecode and then checks if the returnvalue is non-zero. If so, it calls into the newly created contract with all available gas

func (*Program) Hex

func (p *Program) Hex() string

Bytecode returns the Program bytecode

func (*Program) InputAddressToStack

func (p *Program) InputAddressToStack(inputOffset uint32)

InputToMemory stores the input (calldata) to memory

func (*Program) Jump

func (p *Program) Jump(loc interface{})

Jump pushes the destination and adds a JUMP

func (*Program) JumpIf

func (p *Program) JumpIf(loc interface{}, condition interface{})

Jump pushes the destination and adds a JUMP

func (*Program) JumpSub

func (p *Program) JumpSub(loc interface{})

func (*Program) Jumpdest

func (p *Program) Jumpdest() uint64

Jumpdest adds a JUMPDEST op, and returns the PC of that instruction

func (*Program) Label

func (p *Program) Label() uint64

Label returns the PC (of the next instruction)

func (*Program) MemToStorage

func (p *Program) MemToStorage(memStart, memSize, startSlot int)

MemToStorage copies the given memory area into SSTORE slots, It expects data to be aligned to 32 byte, and does not zero out remainders if some data is not I.e, if given a 1-byte area, it will still copy the full 32 bytes to storage

func (*Program) Mstore

func (p *Program) Mstore(data []byte, memStart uint32)

MStore stores the provided data (into the memory area starting at memStart)

func (*Program) Op

func (p *Program) Op(op ops.OpCode)

Op appends the given opcode

func (*Program) Push

func (p *Program) Push(val interface{}) *Program

Push creates a PUSHX instruction with the data provided

func (*Program) Return

func (p *Program) Return(offset, len uint32)

func (*Program) ReturnData

func (p *Program) ReturnData(data []byte)

ReturnData loads the given data into memory, and does a return with it

func (*Program) Size

func (p *Program) Size() int

func (*Program) Sstore

func (p *Program) Sstore(slot interface{}, value interface{})

Sstore stores the given byte array to the given slot. OBS! Does not verify that the value indeed fits into 32 bytes If it does not, it will panic later on via pushBig

func (*Program) StaticCall

func (p *Program) StaticCall(gas *big.Int, address, inOffset, inSize, outOffset, outSize interface{})

StaticCall is a convenience function to make a staticcall

Jump to

Keyboard shortcuts

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