ir

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ir defines the resolved, target-independent representation consumed by every backend. Unlike syntax AST nodes, IR expressions carry semantic types and declarations contain normalized names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	ExprBase
	Elements []Expression
}

type Assignment

type Assignment struct {
	Base
	Target   Expression
	Operator string
	Value    Expression
}

type Attribute

type Attribute struct {
	Name      string
	Arguments []CallArgument
}

type Base

type Base struct {
	Span            token.Span
	TrailingComment string
}

type Binary

type Binary struct {
	ExprBase
	Left     Expression
	Operator string
	Right    Expression
}

type Block

type Block struct {
	ExprBase
	Parameters []string
	Body       []Statement
	Brace      bool
}

type Break

type Break struct{ Base }

type Call

type Call struct {
	ExprBase
	Callee    Expression
	Arguments []CallArgument
	Block     *Block
	Codec     *CodecSchema
}

type CallArgument

type CallArgument struct {
	Name  string
	Value Expression
	Splat string
}

type Case

type Case struct {
	Base
	Value    Expression
	Leading  []Statement
	Branches []CaseBranch
	Else     []Statement
	HasElse  bool
}

type CaseBinding

type CaseBinding struct {
	Name  string
	Field string
	Type  types.Type
}

type CaseBranch

type CaseBranch struct {
	Base
	Value       Expression
	EnumName    string
	Member      string
	Bindings    []CaseBinding
	PayloadEnum bool
	Body        []Statement
}

type Class

type Class struct {
	Base
	Name       string
	Superclass Expression
	Implements []string
	Body       []Statement
}

type CodecField

type CodecField struct {
	Name     string
	WireName string
	Schema   *CodecSchema
}

type CodecSchema

type CodecSchema struct {
	Type      types.Type
	Kind      string
	Module    string
	Reference *Reference
	Element   *CodecSchema
	Fields    []CodecField
}

CodecSchema is the checked, target-independent shape used by typed JSON encode/decode intrinsics. Backends consume this schema instead of reflecting over a generated target type.

type Comment

type Comment struct {
	Base
	Text string
}

type Conversion added in v0.1.3

type Conversion struct {
	ExprBase
	Kind  ConversionKind
	Value Expression
}

type ConversionKind added in v0.1.3

type ConversionKind string
const IntegerToFloatConversion ConversionKind = "integer_to_float"

type Enum

type Enum struct {
	Base
	Name           string
	TypeParameters []string
	Body           []Statement
}

type EnumConstruct

type EnumConstruct struct {
	ExprBase
	EnumName      string
	Member        string
	TypeArguments []types.Type
	Arguments     []Expression
	Reference     *Reference
}

EnumConstruct preserves nominal variant construction through lowering. It must not become an ordinary call because every backend uses a different runtime representation for payload enums.

type EnumMember

type EnumMember struct {
	Base
	Name   string
	Fields []Parameter
}

type ExprBase

type ExprBase struct {
	Base
	Type types.Type
}

func NewExprBase

func NewExprBase(span token.Span, typ types.Type) ExprBase

func (ExprBase) ExprType

func (e ExprBase) ExprType() types.Type

type Expression

type Expression interface {
	ExprType() types.Type
	// contains filtered or unexported methods
}

type ExpressionStatement

type ExpressionStatement struct {
	Base
	Expression Expression
}

type Field

type Field struct {
	Base
	Name     string
	Type     types.Type
	Value    Expression
	ReadOnly bool
}

type Hash

type Hash struct {
	ExprBase
	Entries []HashEntry
}

type HashEntry

type HashEntry struct {
	Key   Expression
	Value Expression
}

type Identifier

type Identifier struct {
	ExprBase
	Name      string
	Owner     string
	Reference *Reference
}

type If

type If struct {
	Base
	Condition Expression
	Then      []Statement
	ElseIf    []IfBranch
	Else      []Statement
}

type IfBranch

type IfBranch struct {
	Condition Expression
	Body      []Statement
}

type Import

type Import struct {
	Base
	Path      string
	Symbols   []string
	Alias     string
	Namespace bool
	Kind      string
	Standard  bool
	Platform  bool
	Runtime   bool
	// IntrinsicSymbols are resolved at compile time and have no corresponding
	// runtime export in a compiler-owned source module.
	IntrinsicSymbols map[string]bool
	// SymbolKinds distinguishes value records from reference classes in
	// backends whose representation makes that distinction explicit.
	SymbolKinds map[string]string
}

type Index

type Index struct {
	ExprBase
	Receiver Expression
	Index    Expression
}

type Interface

type Interface struct {
	Base
	Name    string
	Methods []*Method
}

type InterpolatedString

type InterpolatedString struct {
	ExprBase
	Raw   string
	Parts []StringPart
}

type Iterate

type Iterate struct {
	Base
	Source    Expression
	Operation string
	SliceSize Expression
	WithIndex bool
	Item      string
	Index     string
	ItemType  types.Type
	Body      []Statement
}

Iterate is a structured loop rather than a callback invocation. Backends can therefore preserve TypeRB control-flow semantics inside an each block.

type Literal

type Literal struct {
	ExprBase
	Kind string
	Raw  string
}

type Member

type Member struct {
	ExprBase
	Receiver  Expression
	Name      string
	Safe      bool
	Namespace bool
	Reference *Reference
}

type Method

type Method struct {
	Base
	Name           string
	TypeParameters []string
	Parameters     []Parameter
	ReturnType     types.Type
	Body           []Statement
	Class          bool
}

type Module

type Module struct {
	Base
	Name string
	Body []Statement
}

type Native

type Native struct {
	Base
	Text string
}

type NativeBlock

type NativeBlock struct {
	Base
	Header string
	Body   []Statement
	Closer string
}

type NativeExpression

type NativeExpression struct {
	ExprBase
	Text string
}

type Next

type Next struct{ Base }

type Parameter

type Parameter struct {
	Name        string
	Type        types.Type
	Default     Expression
	Keyword     bool
	Rest        bool
	KeywordRest bool
}

type Program

type Program struct {
	Mode       string
	Package    string
	ModulePath string
	GoModule   string
	RubyLoader string
	Statements []Statement
}

type Range

type Range struct {
	ExprBase
	Start     Expression
	End       Expression
	Exclusive bool
}

type Record

type Record struct {
	Base
	Name string
	Body []Statement
}

type RecordField

type RecordField struct {
	Base
	Name       string
	Type       types.Type
	Attributes []Attribute
}

type Reference

type Reference struct {
	Package        string
	Alias          string
	Symbol         string
	ExportKind     string
	Intrinsic      string
	ReceiverMethod bool
}

Reference identifies a symbol resolved from an import or the portable prelude. Intrinsic is non-empty for compiler-known standard/platform calls; project references use Package, Alias, Symbol, and ExportKind for target-specific qualification.

type Return

type Return struct {
	Base
	Value Expression
}

type Statement

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

type StringPart

type StringPart struct {
	Text       string
	Expression Expression
}

type Symbol

type Symbol struct {
	ExprBase
	Name string
	Raw  string
}

type Transform

type Transform struct {
	ExprBase
	Source      Expression
	Operation   string
	Initial     Expression
	WithIndex   bool
	Item        string
	Index       string
	Accumulator string
	ItemType    types.Type
	Body        []Statement
	Result      Expression
}

Transform is a value-producing collection operation. It is distinct from a target callback so checker-derived item/result types and block semantics are retained until backend lowering.

type TypeApply

type TypeApply struct {
	ExprBase
	Receiver  Expression
	Arguments []types.Type
}

type Unary

type Unary struct {
	ExprBase
	Operator string
	Operand  Expression
}

type Variable

type Variable struct {
	Base
	Name     string
	Type     types.Type
	Value    Expression
	Mutable  bool
	Constant bool
	Owner    string
}

type While

type While struct {
	Base
	Condition Expression
	Body      []Statement
}

Jump to

Keyboard shortcuts

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