wasm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateWasmCode

func GenerateWasmCode(node *ast.Node) string

func SerializeSSA

func SerializeSSA(graph *ir.Graph) (string, error)

SerializeSSA emits a standalone WAT module from a typed SSA graph. Supports primitive numeric/boolean values, canonical if/phi control flow, and structured while loops (back edges produced by lowerWhile in ssa.go). Unsupported graph shapes return an error instead of falling back silently.

func SerializeSSAProgram

func SerializeSSAProgram(functions []Function, entry *ir.Graph) (string, error)

SerializeSSAProgram emits a standalone WAT module containing one function per entry in functions plus an exported "main" entrypoint for entry. Calls between functions (including recursion) are resolved by name via ir.OpCall. With no functions, this produces byte-identical output to SerializeSSA(entry).

func ValidateWAT

func ValidateWAT(source string) error

ValidateWAT parses and type-checks the folded instruction subset emitted by this backend. External tools remain the authority for the complete WAT grammar, but malformed instructions cannot pass merely because parentheses happen to balance.

Types

type Function

type Function struct {
	Name   string
	Params []ir.Param
	Return ast.TypeInfo
	Graph  *ir.Graph
}

Function is one named, typed function ready for multi-function Wasm program serialization via SerializeSSAProgram. Graph is produced by ir.LowerSSAFunction from the same Params.

type NativeLayout

type NativeLayout struct {
	ValueType    string
	Size         uint64
	Align        uint64
	Indirect     bool
	FieldOffsets map[string]uint64
}

NativeLayout is the representation selected by the Wasm backend for a typed HowlFrame value. Aggregate values are represented by a linear-memory pointer until Wasm memory access/code generation is added for them.

Jump to

Keyboard shortcuts

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