vm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PTRSIZE is size of arguments pointer
	PTRSIZE = 8

	// SIZEPTRSIZE is size of arguments size pointer
	SIZEPTRSIZE = 8
)

Variables

View Source
var ErrInvalidData = errors.New("Invalid data")
View Source
var ErrInvalidMemory = errors.New("Invalid memory reference")
View Source
var ErrInvalidOpcode = errors.New("invalid opcode")

Functions

This section is empty.

Types

type CallFunc

type CallFunc struct {
	Func []byte
	Args []byte
}

type Data

type Data struct {
	Body []uint8
}

type Memory

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

func NewMemory

func NewMemory() *Memory

func (*Memory) Cost

func (m *Memory) Cost() uint64

func (*Memory) Data

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

func (*Memory) GetPtr

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

GetPtr returns the offset + size

func (*Memory) GetVal

func (m *Memory) GetVal(offset, size uint64) []byte

Get returns offset + size as a new slice

func (*Memory) Len

func (m *Memory) Len() int

func (*Memory) Print

func (m *Memory) Print()

Print dumps the content of the memory.

func (*Memory) Resize

func (m *Memory) Resize(size uint64)

Resize resizes the memory to size

func (*Memory) Set

func (m *Memory) Set(offset uint64, value byte)

Set sets offset to value

func (*Memory) Set8

func (m *Memory) Set8(offset uint64, value []byte)

Set8 sets the 8 bytes starting at offset to the value of val, left-padded with zeroes to 8 bytes.

func (*Memory) Sets

func (m *Memory) Sets(offset, size uint64, value []byte)

Sets sets offset + size to value

type Stack

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

Stack is an object for basic Stack operations. Items popped to the Stack are expected not to be changed and modified.

func Execute

func Execute(rawByteCode []byte, memory *Memory, callFunc *CallFunc) (*Stack, error)

The Execute function assemble the rawByteCode into an assembly code, which in turn executes the assembly logic.

func (*Stack) Dup

func (s *Stack) Dup()

func (*Stack) Len

func (s *Stack) Len() int

func (*Stack) Pop

func (s *Stack) Pop() item

func (*Stack) Print

func (s *Stack) Print()

Print dumps the content of the Stack

func (*Stack) Push

func (s *Stack) Push(d item)

func (*Stack) PushN

func (s *Stack) PushN(ds ...item)

Push n number of data([]data) to Stack

func (*Stack) Swap

func (s *Stack) Swap()

Jump to

Keyboard shortcuts

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