memory

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Overview

modified from https://github.com/ontio/ontology-wasm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PointerType

type PointerType int
const (
	PInt8 PointerType = iota
	PInt16
	PInt32
	PInt64
	PFloat32
	PFloat64
	PString
	PStruct
	PUnknown
)

type TypeLength

type TypeLength struct {
	Type   PointerType
	Length int
}

type VMemory

type VMemory struct {
	Memory            []byte // linear memory
	AllocatedMemIndex int    // index of allocated memory
	PointedMemIndex   int    //for the pointed objects,string,array,structs
	ParamIndex        int
	MemPoints         map[uint64]*TypeLength
}

func NewVMemory

func NewVMemory(size uint64) VMemory

func (*VMemory) GetPointerMemSize

func (vm *VMemory) GetPointerMemSize(addr uint64) int

GetPointerMemSize return pointed memory size

func (*VMemory) GetPointerMemory

func (vm *VMemory) GetPointerMemory(addr uint64) ([]byte, error)

GetPointerMemory return pointed memory data of the address when wasm returns a pointer, call this function to get the pointed memory

func (*VMemory) Grow

func (vm *VMemory) Grow(size uint64)

Grow up memory size

func (*VMemory) Length

func (vm *VMemory) Length() int

func (*VMemory) Malloc

func (vm *VMemory) Malloc(size int) (int, error)

Malloc memory for base types by size, return the address in memory

func (*VMemory) MallocPointer

func (vm *VMemory) MallocPointer(size int, pType PointerType) (int, error)

MallocPointer malloc memory for pointer types, return the address in memory

func (*VMemory) MemSet

func (vm *VMemory) MemSet(dest int, ch int, count int) (int, error)

MemSet

func (*VMemory) SetMemory

func (vm *VMemory) SetMemory(val interface{}) (int, error)

SetMemory set base types into memory, return address of memory

func (*VMemory) SetPointerMemory

func (vm *VMemory) SetPointerMemory(val interface{}) (int, error)

SetPointerMemory set pointer types into memory, return address of memory

func (*VMemory) SetStructMemory

func (vm *VMemory) SetStructMemory(val interface{}) (int, error)

SetStructMemory set struct into memory , return address of memory

Jump to

Keyboard shortcuts

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