binary

package
v0.0.0-...-46f5beb Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The binary package handles reading and writing of wasm binary files https://webassembly.github.io/spec/core/binary/index.html

Index

Constants

View Source
const ComponentVersion uint16 = 0x0d
View Source
const ModuleVersion uint16 = 0x01

Variables

View Source
var Magic = []byte{0x00, 0x61, 0x73, 0x6d}

Functions

func ReadByte

func ReadByte(reader io.Reader) (byte, error)

func ReadInstruction

func ReadInstruction(reader io.Reader) (instruction.Instruction, error)

func ReadLebU128

func ReadLebU128(reader io.Reader) (uint32, error)

func ReadOpCode

func ReadOpCode(reader io.Reader) (opcode.Opcode, error)

func ReadUInt16

func ReadUInt16(reader io.Reader) (uint16, error)

func ReadUInt32

func ReadUInt32(reader io.Reader) (uint32, error)

Types

type Code

type Code struct {
	Size       uint32
	Locals     []Local
	Expression []instruction.Instruction
}

func ReadCode

func ReadCode(reader io.Reader) (*Code, error)

type CodeSection

type CodeSection struct {
	ID    SectionID
	Size  uint32
	Codes []*Code
}

func ReadCodeSection

func ReadCodeSection(size uint32, reader io.Reader) (*CodeSection, error)

type Component

type Component struct{}

type Document

type Document struct {
	Preamble *Preamble
	Root     Root
}

func Read

func Read(reader io.Reader) (*Document, error)

type FunctionSection

type FunctionSection struct {
	ID    SectionID
	Size  uint32
	Types []uint32
}

func ReadFunctionSection

func ReadFunctionSection(size uint32, reader io.Reader) (*FunctionSection, error)

type FunctionType

type FunctionType struct {
	Parameters []ValueType
	Results    []ValueType
}

func ReadType

func ReadType(reader io.Reader) (*FunctionType, error)

type Local

type Local struct {
	ValueTypes []ValueType
}

func ReadLocal

func ReadLocal(reader io.Reader) (Local, error)

type Module

type Module struct {
	Sections []Section
}

func ReadModule

func ReadModule(reader io.Reader) (*Module, error)

type Preamble

type Preamble struct {
	Magic   [4]byte
	Version uint16
	Layer   uint16
}

func ReadPreamble

func ReadPreamble(reader io.Reader) (*Preamble, error)

type Root

type Root interface {
	// contains filtered or unexported methods
}

type Section

type Section interface {
	// contains filtered or unexported methods
}

func ReadSection

func ReadSection(reader io.Reader) (Section, error)

type SectionID

type SectionID uint8
const (
	CustomSectionID   SectionID = 0
	TypeSectionID     SectionID = 1
	FunctionSectionID SectionID = 3
	CodeSectionID     SectionID = 10
)

type TypeSection

type TypeSection struct {
	ID    SectionID
	Size  uint32
	Types []*FunctionType
}

func ReadTypeSection

func ReadTypeSection(size uint32, reader io.Reader) (*TypeSection, error)

type ValueType

type ValueType byte
const F32 ValueType = 0x7d
const F64 ValueType = 0x7c
const I32 ValueType = 0x7f
const I64 ValueType = 0x7e

func ReadValueType

func ReadValueType(reader io.Reader) (ValueType, error)

func ReadValueTypeVector

func ReadValueTypeVector(reader io.Reader) ([]ValueType, error)

Jump to

Keyboard shortcuts

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