binary

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: MIT Imports: 8 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 = 0x0a
View Source
const ModuleVersion uint16 = 0x01

Variables

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

Functions

func Read

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

func ReadByte

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

func ReadBytes

func ReadBytes(reader io.Reader, size int) ([]byte, error)

func ReadComponent

func ReadComponent(reader io.Reader) (*api.Component, error)

func ReadExport

func ReadExport(reader io.Reader) (api.Export, error)

func ReadExports

func ReadExports(size uint32, reader io.Reader) ([]api.Export, error)

func ReadExpression

func ReadExpression(reader io.Reader) (*api.Expression, error)

func ReadFunc

func ReadFunc(reader io.Reader) (*api.Func, error)

func ReadFuncTypes

func ReadFuncTypes(size uint32, reader io.Reader) ([]*api.FuncType, error)

func ReadFuncs

func ReadFuncs(size uint32, reader io.Reader) ([]*api.Func, error)

func ReadInstruction

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

func ReadLebU128

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

func ReadModule

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

func ReadOpCode

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

func ReadPreamble

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

func ReadResultType

func ReadResultType(reader io.Reader) (api.ResultType, error)

func ReadString

func ReadString(reader io.Reader) (string, error)

func ReadType

func ReadType(reader io.Reader) (*api.FuncType, error)

func ReadUInt16

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

func ReadUInt32

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

func ReadValueType

func ReadValueType(reader io.Reader) (api.ValType, error)

func ReadValueTypeVector

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

func UpdateFuncsWithCode

func UpdateFuncsWithCode(module *api.Module, size uint32, reader io.Reader) error

Types

type ExportKind

type ExportKind byte
const FuncExportKind ExportKind = 0x00
const GlobalExportKind ExportKind = 0x03
const MemoryExportKind ExportKind = 0x02
const TableExportKind ExportKind = 0x01

type Section

type Section struct {
	ID   SectionID
	Data []byte
}

type SectionID

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

func ReadSectionHeader

func ReadSectionHeader(reader io.Reader) (SectionID, uint32, error)

type ValType

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

Jump to

Keyboard shortcuts

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