types

package
v0.0.0-...-87e38ef Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTypeByte = errors.New("invalid byte")

ErrInvalidTypeByte means the type byte mismatches the one from wasm binary

Functions

func HasSameSignature

func HasSameSignature(a []ValueType, b []ValueType) bool

HasSameSignature will verify whether the two types.ValueType are same

func ReadNameValue

func ReadNameValue(r *bytes.Reader) (string, error)

ReadNameValue will read a name string from the io.Reader

Types

type FuncType

type FuncType struct {
	InputTypes  []ValueType
	ReturnTypes []ValueType
}

FuncType classify the signature of functions, mapping a vector of parameters to a vector of results, written as follows.

func ReadFuncType

func ReadFuncType(r *bytes.Reader) (*FuncType, error)

ReadFuncType will read a types.ReadFuncType from the io.Reader

type GlobalType

type GlobalType struct {
	ValType ValueType
	Mutable bool
}

GlobalType classify global variables, which hold a value and can either be mutable or immutable.

func ReadGlobalType

func ReadGlobalType(r io.Reader) (*GlobalType, error)

ReadGlobalType will read a types.GlobalType from the io.Reader

type Limits

type Limits struct {
	Min uint32
	Max *uint32 // can be nil
}

Limits classify the size range of resizeable storage associated with memory types and table types https://www.w3.org/TR/wasm-core-1/#limits%E2%91%A0

func ReadLimits

func ReadLimits(r *bytes.Reader) (*Limits, error)

ReadLimits will read a types.Limits from the io.Reader

type MemoryType

type MemoryType = Limits

MemoryType classify linear memories and their size range. https://www.w3.org/TR/wasm-core-1/#memory-types%E2%91%A0

func ReadMemoryType

func ReadMemoryType(r *bytes.Reader) (*MemoryType, error)

ReadMemoryType will read a types.MemoryType from the io.Reader

type TableType

type TableType struct {
	Elem   byte
	Limits *Limits
}

TableType classify tables over elements of element types within a size range. https://www.w3.org/TR/wasm-core-1/#table-types%E2%91%A0

func ReadTableType

func ReadTableType(r *bytes.Reader) (*TableType, error)

ReadTableType will read a types.TableType from the io.Reader

type ValueType

type ValueType byte

ValueType classifies the individual values that WebAssembly code can compute with and the values that a variable accepts https://www.w3.org/TR/wasm-core-1/#value-types%E2%91%A0

const (
	// ValueTypeI32 classify 32 bit integers
	ValueTypeI32 ValueType = 0x7f
	// ValueTypeI64 classify 64 bit integers
	// Integers are not inherently signed or unsigned, the interpretation is determined by individual operations
	ValueTypeI64 ValueType = 0x7e
	// ValueTypeF32 classify 32 bit floating-point data, known as single
	ValueTypeF32 ValueType = 0x7d
	// ValueTypeF64 classify 64 bit floating-point data, known as double
	ValueTypeF64 ValueType = 0x7c
)

func ReadValueTypes

func ReadValueTypes(r io.Reader, num uint32) ([]ValueType, error)

ReadValueTypes will read a types.ValueType from the io.Reader

func (ValueType) String

func (v ValueType) String() string

String will convert the types.ValueType into a string

Jump to

Keyboard shortcuts

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