core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpCore

func DumpCore(mainCore Expr, modCores map[string][]Bind) string

DumpCore renders the program body thunk followed by every module's bindings, modules in sorted order for a stable result.

Types

type Addr

type Addr struct {
	Kind   AddrKind
	Slot   int
	Module string
}

type AddrKind

type AddrKind uint8
const (
	AddrLocal AddrKind = iota
	AddrUpvalue
	AddrModule
)

type App

type App struct {
	Head Expr
	Args []Expr
	Pos  source.SourcePos
}

type Bind

type Bind struct {
	Slot int
	Name string
	Body Expr
}

type Case

type Case struct {
	Pattern Pattern
	Body    Expr
	Frame   int
}

type Compose

type Compose struct {
	Forward bool
	Fns     []Expr
}

type Cons

type Cons struct{ Head, Tail Expr }

type Const

type Const struct{ Val value.Value }

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

func Lower

func Lower(program *syntax.Program, modules map[string]*syntax.Module, res *syntax.Resolution) (Expr, map[string][]Bind)

Lower produces the Core for the program body (wrapped in a memoising thunk that carries the body's frame size) and for every module's public bindings.

type FrameBuilder

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

FrameBuilder tracks slot allocation for one activation (the program body, a module binding, or a lambda) and the upvalues a nested lambda captures from it. freeNames and slotNames are debug-only; they are never read by the machine.

type Lambda

type Lambda struct {
	Cases     []Case
	Free      []Addr
	FreeNames []string // debug: name of each captured variable, parallel to Free
	Frame     int
	NoMatch   source.SourcePos // span of the whole pattern set, for the "no pattern matched" error
}

type Let

type Let struct {
	Binds []Bind
	Body  Expr
}

type Lowerer

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

type Num

type Num struct{ Val float64 }

type Pattern

type Pattern interface {
	// contains filtered or unexported methods
}

type PatternConst

type PatternConst struct {
	Val value.Value
}

type PatternTuple

type PatternTuple struct {
	Fields []Pattern // arity 2 is cons
}

type PatternVar

type PatternVar struct {
	Slot int
	Name string // the bound variable's name, kept for traces and show
}

type Prim

type Prim struct {
	Op   value.PrimOp
	Args []Expr
	Pos  source.SourcePos
}

type Stdin

type Stdin struct{ Bytes bool }

Stdin is a reference to one of the two standard-input streams: the code-point stream, or the byte stream when Bytes is set. It is a node of its own rather than a Const holding the stream value, because the stream is a stateful thunk that is created on demand at run time — a constant pool is for immutable values, and one holding a live stream has nothing sensible to render in the AST or bytecode dumps.

type Thunk

type Thunk struct {
	Body  Expr
	Frame int
	Name  string
	Pos   source.SourcePos // debug: definition site, for the bytecode dump
}

type Tuple

type Tuple struct{ Fields []Expr }

type Var

type Var struct{ Addr Addr }

Jump to

Keyboard shortcuts

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