binary

package
v0.0.0-...-c25e94d Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package binary implements the WebAsembly binary encoding and decoding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBinary

func DecodeBinary(data io.Reader) error

DecodeBinary decodes module from binary encoding.

Types

type Decoder

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

Decoder implements primite functions for WASM binary format decoding.

func (*Decoder) Avail

func (d *Decoder) Avail() int64

Avail returns the number of bytes available in the current decoder input.

func (*Decoder) LEB128u32

func (d *Decoder) LEB128u32() (uint32, error)

LEB128u32 decodes a Little Endian Base 128 encoded uint32 number.

func (*Decoder) MSBu32

func (d *Decoder) MSBu32() (uint32, error)

MSBu32 decodes a most-significant bit (MSB) encoded uint32 number.

func (*Decoder) Name

func (d *Decoder) Name() (string, error)

Name decodes an UTF-8 name.

func (*Decoder) PopInput

func (d *Decoder) PopInput()

PopInput removes the topmost input from the decoder.

func (*Decoder) PushInput

func (d *Decoder) PushInput(in io.Reader, size int64)

PushInput pushes a new input to the decoder.

func (*Decoder) ReadByte

func (d *Decoder) ReadByte() (byte, error)

ReadByte reads one byte from the input.

type NameID

type NameID byte

NameID defines name section IDs.

const (
	ModuleName NameID = iota
	FunctionNames
	LocalNames
	LabelNames
	TypeNames
	TableNames
	MemoryNames
	GlobalNames
	ElemSegmentNames
	DataSegmentNames
)

Known name IDs.

func (NameID) String

func (id NameID) String() string

type Section

type Section struct {
	ID   SectionID
	Data []byte
}

Section implements a module section.

type SectionID

type SectionID byte

SectionID defines the ID of module sections.

const (
	SectionCustom SectionID = iota
	SectionType
	SectionImport
	SectionFunction
	SectionTable
	SectionMemory
	SectionGlobal
	SectionExport
	SectionStart
	SectionElement
	SectionCode
	SectionData
	SectionDataCount
)

Known section IDs.

func (SectionID) String

func (id SectionID) String() string

Jump to

Keyboard shortcuts

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