codegen

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecType     byte = 1
	SecImports  byte = 2
	SecFunction byte = 3
	SecExport   byte = 7
	SecCode     byte = 10
)
View Source
const (
	LocalTypeI32 byte = 0x7F
	LocalTypeF32 byte = 0x7D
)
View Source
const (
	OpCodeEnd          byte = 0x0B
	OpCodeReturn       byte = 0x0F
	OpCodeCallFunction byte = 0x10

	OpCodeLocalGet byte = 0x20
	OpCodeLocalSet byte = 0x21

	OpCodeI32Const          byte = 0x41
	OpCodeI32Add            byte = 0x6A
	OpCodeI32Sub            byte = 0x6B
	OpCodeI32Mul            byte = 0x6C
	OpCodeI32SignedDivision byte = 0x6D
	OpCodeI32And            byte = 0x71

	OpCodeF32Const    byte = 0x43
	OpCodeF32Neg      byte = 0x8C
	OpCodeF32Add      byte = 0x92
	OpCodeF32Sub      byte = 0x93
	OpCodeF32Mul      byte = 0x94
	OpCodeF32Division byte = 0x95
)

Variables

This section is empty.

Functions

func EncodeF32

func EncodeF32(f float32) []byte

EncodeF32 converts a float32 to its 4-byte little-endian representation

func EncodeSLEB128

func EncodeSLEB128(n int32) []byte

Encodes signed integers to Little Endian Binary 128-bit format

func EncodeULEB128

func EncodeULEB128(n uint32) []byte

Encodes unsigned integers to Little Endian Binary 128-bit format

Types

type WASMModule

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

func NewModule

func NewModule(program *ast.Program) *WASMModule

func (*WASMModule) Generate

func (m *WASMModule) Generate() error

func (*WASMModule) Save

func (m *WASMModule) Save(filename string) error

Jump to

Keyboard shortcuts

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