wasm

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Magic    = "\x00asm"
	Version1 = "\x01\x00\x00\x00"
)

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, sections []Section) error

Write writes a binary WebAssembly module to w.

func WriteModuleHeader

func WriteModuleHeader(w io.Writer) error

WriteModuleHeader writes a binary WebAssembly module header (version 1) to w.

func WriteSectionHeader

func WriteSectionHeader(w io.Writer, id SectionID, size uint64) (n int, err error)

WriteSectionHeader writes a binary WebAssembly section header to w. It returns the number of bytes written and/or an error.

func WriteString

func WriteString(w io.Writer, s string) (n int, err error)

WriteString writes a string to w as a LEB128 encoded length followed by the string bytes. Returns the number of bytes written and/or an error.

Types

type CustomSection

type CustomSection struct {
	Name     string
	Contents []byte
}

CustomSection represents a WebAssembly custom section.

func (*CustomSection) SectionContents

func (s *CustomSection) SectionContents() ([]byte, error)

SectionContents implements the Section interface.

func (*CustomSection) SectionID

func (*CustomSection) SectionID() SectionID

SectionID implements the Section interface.

type LinkingSection

type LinkingSection struct{}

func (*LinkingSection) SectionContents

func (s *LinkingSection) SectionContents() ([]byte, error)

SectionContents implements the Section interface.

func (*LinkingSection) SectionID

func (*LinkingSection) SectionID() SectionID

SectionID implements the Section interface.

type Section

type Section interface {
	// SectionID returns the section ID of this section.
	SectionID() SectionID

	// SectionContents returns the section contents as a byte slice.
	SectionContents() ([]byte, error)
}

Section represents an abstract WebAssembly section.

type SectionID

type SectionID uint8

SectionID represents a WebAssembly section SectionID.

const (
	SectionCustom    SectionID = 0
	SectionType      SectionID = 1
	SectionImport    SectionID = 2
	SectionFunction  SectionID = 3
	SectionTable     SectionID = 4
	SectionMemory    SectionID = 5
	SectionGlobal    SectionID = 6
	SectionExport    SectionID = 7
	SectionStart     SectionID = 8
	SectionElement   SectionID = 9
	SectionCode      SectionID = 10
	SectionData      SectionID = 11
	SectionDataCount SectionID = 12
)

Directories

Path Synopsis
Package sleb128 reads and writes signed LEB128 integers.
Package sleb128 reads and writes signed LEB128 integers.
Package uleb128 reads and writes unsigned LEB128 integers.
Package uleb128 reads and writes unsigned LEB128 integers.

Jump to

Keyboard shortcuts

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