bootstrapsnapshot

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 11 Imported by: 0

README

Internal bootstrap snapshots

This package exports a deliberately bounded, versioned data format from checked TypeRB IR. It is not a general backend or a public compiler extension API. Unsupported source constructs return explicit diagnostics.

Versions 3 and 4 lower if and while Boolean condition trees containing short-circuit &&, ||, and nested ! through existing branches, jumps and block parameters. The left operand runs once; the right runs only when needed. Loop backedges return to the original condition entry, and lexical bindings are carried to each continuation explicitly. No format opcode is added.

Logical value expressions outside these condition trees, including logical subexpressions in call arguments, remain unsupported. Supporting them requires carrying enclosing expression temporaries across blocks, not simply making binary instruction emission eager. Version 2 is unchanged. These are snapshot coverage limits, not restrictions on ordinary TypeRB language semantics.

Versions 3 and 4 also lower statement break and next in while through existing jump edges. Transfers select the nearest loop exit or original condition entry and carry the current values of the loop's outer bindings; body-local bindings do not escape. Conditional transfers use the same checked conditional lowering. A terminating loop body no longer requires an implicit backedge, so an early return keeps its method target. Function and closure lowerers do not inherit enclosing loop targets. Version 2 and unsupported iteration-block constructs retain their existing boundaries.

Documentation

Overview

Package bootstrapsnapshot serializes deliberately small, data-only subsets of the checked TypeRB IR for temporary compiler bootstrapping. It exposes no compiler object across the process boundary and is not a stable protocol.

Index

Constants

View Source
const (
	Format   = "type-rb-bootstrap-snapshot"
	Version2 = 2
	Version3 = 3
	Version4 = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayConstruct added in v0.3.48

type ArrayConstruct struct {
	Op        string   `json:"op"`
	Result    string   `json:"result"`
	Type      string   `json:"type"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type ArrayGet added in v0.3.48

type ArrayGet struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Type   string `json:"type"`
	Array  string `json:"array"`
	Index  string `json:"index"`
	Origin Origin `json:"origin"`
}

type ArrayPush added in v0.3.48

type ArrayPush struct {
	Op     string `json:"op"`
	Type   string `json:"type"`
	Array  string `json:"array"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type ArraySet added in v0.3.48

type ArraySet struct {
	Op     string `json:"op"`
	Type   string `json:"type"`
	Array  string `json:"array"`
	Index  string `json:"index"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type ArraySize added in v0.3.48

type ArraySize struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Type   string `json:"type"`
	Array  string `json:"array"`
	Origin Origin `json:"origin"`
}

type BinaryInstruction

type BinaryInstruction struct {
	Op       string `json:"op"`
	Result   string `json:"result"`
	Operator string `json:"operator"`
	Left     string `json:"left"`
	Right    string `json:"right"`
	Origin   Origin `json:"origin"`
}

type Block

type Block struct {
	ID           string      `json:"id"`
	Parameters   []Parameter `json:"parameters"`
	Origin       Origin      `json:"origin"`
	Instructions []any       `json:"instructions"`
	Terminator   any         `json:"terminator"`
}

type BooleanLiteral

type BooleanLiteral struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  bool   `json:"value"`
	Origin Origin `json:"origin"`
}

type BooleanNot

type BooleanNot struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type Branch

type Branch struct {
	Op             string   `json:"op"`
	Condition      string   `json:"condition"`
	WhenTrue       string   `json:"whenTrue"`
	TrueArguments  []string `json:"trueArguments"`
	WhenFalse      string   `json:"whenFalse"`
	FalseArguments []string `json:"falseArguments"`
	Origin         Origin   `json:"origin"`
}

type Call

type Call struct {
	Op        string   `json:"op"`
	Result    *string  `json:"result"`
	Function  string   `json:"function"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type ClosureCall added in v0.3.48

type ClosureCall struct {
	Op        string   `json:"op"`
	Result    *string  `json:"result"`
	Type      string   `json:"type"`
	Closure   string   `json:"closure"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type ClosureConstruct added in v0.3.48

type ClosureConstruct struct {
	Op       string   `json:"op"`
	Result   string   `json:"result"`
	Type     string   `json:"type"`
	Function string   `json:"function"`
	Captures []string `json:"captures"`
	Origin   Origin   `json:"origin"`
}

type Field

type Field struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type FloatLiteral

type FloatLiteral struct {
	Op     string  `json:"op"`
	Result string  `json:"result"`
	Value  float64 `json:"value"`
	Origin Origin  `json:"origin"`
}

type Function

type Function struct {
	ID         string      `json:"id"`
	Name       string      `json:"name"`
	Parameters []Parameter `json:"parameters"`
	Result     string      `json:"result"`
	Entry      string      `json:"entry"`
	Origin     Origin      `json:"origin"`
	Blocks     []Block     `json:"blocks"`
}

type FunctionV4 added in v0.3.48

type FunctionV4 struct {
	ID         string      `json:"id"`
	Name       string      `json:"name"`
	Captures   []Parameter `json:"captures"`
	Parameters []Parameter `json:"parameters"`
	Result     string      `json:"result"`
	Entry      string      `json:"entry"`
	Origin     Origin      `json:"origin"`
	Blocks     []Block     `json:"blocks"`
}

type IntegerLiteral

type IntegerLiteral struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  int64  `json:"value"`
	Origin Origin `json:"origin"`
}

type Jump

type Jump struct {
	Op        string   `json:"op"`
	Target    string   `json:"target"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type Origin

type Origin struct {
	Source      string `json:"source"`
	StartLine   int    `json:"startLine"`
	StartColumn int    `json:"startColumn"`
	EndLine     int    `json:"endLine"`
	EndColumn   int    `json:"endColumn"`
}

type Parameter

type Parameter struct {
	ID     string `json:"id"`
	Type   string `json:"type"`
	Origin Origin `json:"origin"`
}

type RecordConstruct

type RecordConstruct struct {
	Op        string   `json:"op"`
	Result    string   `json:"result"`
	Type      string   `json:"type"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type RecordProject

type RecordProject struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Type   string `json:"type"`
	Record string `json:"record"`
	Field  string `json:"field"`
	Origin Origin `json:"origin"`
}

type Return

type Return struct {
	Op     string  `json:"op"`
	Value  *string `json:"value"`
	Origin Origin  `json:"origin"`
}

type SnapshotV2

type SnapshotV2 struct {
	Format        string     `json:"format"`
	Version       int        `json:"version"`
	Module        string     `json:"module"`
	EntryFunction string     `json:"entryFunction"`
	Sources       []Source   `json:"sources"`
	Functions     []Function `json:"functions"`
}

func BuildV2

func BuildV2(artifacts []*compiler.Artifact, sourceRoot string) (SnapshotV2, error)

BuildV2 encodes the scalar-only version 2 bootstrap snapshot.

type SnapshotV3

type SnapshotV3 struct {
	Format        string           `json:"format"`
	Version       int              `json:"version"`
	Module        string           `json:"module"`
	EntryFunction string           `json:"entryFunction"`
	Sources       []Source         `json:"sources"`
	Types         []TypeDefinition `json:"types"`
	Functions     []Function       `json:"functions"`
}

func BuildV3

func BuildV3(artifacts []*compiler.Artifact, sourceRoot string) (SnapshotV3, error)

BuildV3 encodes the aggregate-capable version 3 bootstrap snapshot.

type SnapshotV4 added in v0.3.48

type SnapshotV4 struct {
	Format        string           `json:"format"`
	Version       int              `json:"version"`
	Module        string           `json:"module"`
	EntryFunction string           `json:"entryFunction"`
	Sources       []Source         `json:"sources"`
	Types         []TypeDefinition `json:"types"`
	Functions     []FunctionV4     `json:"functions"`
}

func BuildV4 added in v0.3.48

func BuildV4(artifacts []*compiler.Artifact, sourceRoot string) (SnapshotV4, error)

BuildV4 encodes managed values and first-class functions in bootstrap snapshot version 4.

type Source

type Source struct {
	ID   string `json:"id"`
	Path string `json:"path"`
}

type StringBinary added in v0.3.48

type StringBinary struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Left   string `json:"left"`
	Right  string `json:"right"`
	Origin Origin `json:"origin"`
}

type StringIndex added in v0.3.48

type StringIndex struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  string `json:"value"`
	Index  string `json:"index"`
	Origin Origin `json:"origin"`
}

type StringLiteral added in v0.3.48

type StringLiteral struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type StringSize added in v0.3.48

type StringSize struct {
	Op     string `json:"op"`
	Result string `json:"result"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type TypeDefinition

type TypeDefinition struct {
	Kind       string     `json:"kind"`
	ID         string     `json:"id"`
	Element    *string    `json:"element,omitempty"`
	Parameters *[]string  `json:"parameters,omitempty"`
	Result     *string    `json:"result,omitempty"`
	Fields     *[]Field   `json:"fields,omitempty"`
	Variants   *[]Variant `json:"variants,omitempty"`
}

type UnsupportedError

type UnsupportedError struct {
	Path    string
	Span    token.Span
	Feature string
	Version int
}

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

type Variant

type Variant struct {
	Name   string  `json:"name"`
	Fields []Field `json:"fields"`
}

type VariantConstruct

type VariantConstruct struct {
	Op        string   `json:"op"`
	Result    string   `json:"result"`
	Type      string   `json:"type"`
	Variant   string   `json:"variant"`
	Arguments []string `json:"arguments"`
	Origin    Origin   `json:"origin"`
}

type VariantProject

type VariantProject struct {
	Op      string `json:"op"`
	Result  string `json:"result"`
	Type    string `json:"type"`
	Value   string `json:"value"`
	Variant string `json:"variant"`
	Field   string `json:"field"`
	Origin  Origin `json:"origin"`
}

type VariantTest

type VariantTest struct {
	Op      string `json:"op"`
	Result  string `json:"result"`
	Type    string `json:"type"`
	Value   string `json:"value"`
	Variant string `json:"variant"`
	Origin  Origin `json:"origin"`
}

type WriteStatic

type WriteStatic struct {
	Op     string `json:"op"`
	Value  string `json:"value"`
	Origin Origin `json:"origin"`
}

type WriteString added in v0.3.48

type WriteString struct {
	Op      string `json:"op"`
	Value   string `json:"value"`
	Newline bool   `json:"newline"`
	Origin  Origin `json:"origin"`
}

Jump to

Keyboard shortcuts

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