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 ¶
- type Array
- type Assignment
- type Attribute
- type Base
- type Binary
- type Block
- type Break
- type Call
- type CallArgument
- type Case
- type CaseBinding
- type CaseBranch
- type Class
- type CodecField
- type CodecSchema
- type Comment
- type Conversion
- type ConversionKind
- type Enum
- type EnumCall
- type EnumConstruct
- type EnumMember
- type EnumRawValue
- type ExprBase
- type Expression
- type ExpressionStatement
- type Extension
- type Field
- type Hash
- type HashEntry
- type Identifier
- type If
- type IfBranch
- type Import
- type Index
- type Interface
- type InterpolatedString
- type Iterate
- type IterationBinding
- type IterationResult
- type JSXAttribute
- type JSXChild
- type JSXElement
- type JSXExpression
- type JSXText
- type Lambda
- type Literal
- type Member
- type MemberContract
- type Method
- type MethodSignature
- type Module
- type Native
- type NativeBlock
- type NativeExpression
- type Next
- type Parameter
- type Program
- type Range
- type Record
- type RecordField
- type Reference
- type Return
- type Statement
- type StringPart
- type StructuredBlock
- type StructuredBlockResult
- type Symbol
- type Temporary
- type Transform
- type TypeAlias
- type TypeApply
- type TypeContract
- type Unary
- type UnionMemberAlternative
- type Variable
- type While
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 ¶
func (Base) SourceSpan ¶ added in v0.2.4
type Binary ¶
type Binary struct {
ExprBase
Left Expression
Operator string
Right Expression
}
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 {
ExprBase
Value Expression
Leading []Statement
Branches []CaseBranch
Else []Statement
HasElse bool
TypeUnion bool
ElseResult Expression
ElseDiverges bool
ElseNarrowings []CaseBinding
}
type CaseBinding ¶
type CaseBranch ¶
type CaseBranch struct {
Base
Value Expression
Alternatives []Expression
EnumName string
Member string
Bindings []CaseBinding
PayloadEnum bool
TypePattern bool
MatchType types.Type
Narrowings []CaseBinding
Body []Statement
Result Expression
Diverges bool
}
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
RawType types.Type
RawValues []EnumRawValue
}
CodecSchema is the checked, target-independent value shape used by typed codecs and protocol bindings. Backends consume this schema instead of reflecting over a generated target type.
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"
const NonNullableToNullableConversion ConversionKind = "non_nullable_to_nullable"
const NullableToNonNullableConversion ConversionKind = "nullable_to_non_nullable"
const RangeToIterableConversion ConversionKind = "range_to_iterable"
const ResultFunctionToPromiseRejectionConversion ConversionKind = "result_function_to_promise_rejection"
const UnionIntegerToFloatConversion ConversionKind = "union_integer_to_float"
type EnumCall ¶ added in v0.2.1
type EnumCall struct {
ExprBase
EnumName string
Method string
Receiver Expression
Arguments []CallArgument
Reference *Reference
RawType types.Type
RawValues []EnumRawValue
}
EnumCall preserves source-level enum methods independently from backend enum representations. Generated raw_value/from_raw operations use the same node so every backend and the REPL share one checked semantic boundary.
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
RawValue Expression
}
type EnumRawValue ¶ added in v0.2.1
type Expression ¶
type ExpressionStatement ¶
type ExpressionStatement struct {
Base
Expression Expression
}
type Extension ¶ added in v0.1.11
type Extension interface {
ExtensionName() string
}
Extension is typed compile-time data contributed by a package integration. The core IR transports it without knowing package-specific schemas.
type HashEntry ¶
type HashEntry struct {
Key Expression
Value Expression
}
type Identifier ¶
type If ¶
type If struct {
ExprBase
Condition Expression
Then []Statement
ThenResult Expression
ThenDiverges bool
ElseIf []IfBranch
Else []Statement
ElseResult Expression
ElseDiverges bool
HasElse bool
}
type IfBranch ¶
type IfBranch struct {
Condition Expression
Body []Statement
Result Expression
Diverges bool
}
type Import ¶
type Import struct {
Base
Path string
// DeclaredPath retains the source spelling when Path is resolved to a
// canonical module identity. Language tooling uses it to link imports.
DeclaredPath string
Symbols []string
Alias string
Namespace bool
Kind string
Standard bool
Official bool
Platform bool
Native bool
Runtime bool
// RuntimeRequired records that generated code must load the source module
// for compiler-owned runtime behavior. Fully lowered intrinsics can leave
// this false.
RuntimeRequired bool
// Implicit identifies compiler-injected runtime dependencies that are not
// source-visible imports. Language tooling must not offer their exports as
// though the application imported them explicitly.
Implicit bool
// IntrinsicSymbols are lowered by the backend instead of being imported as
// named functions from a compiler-owned source module.
IntrinsicSymbols map[string]bool
// RuntimeIndependentSymbols are the intrinsic subset that does not
// reference the compiler-owned source module on any backend.
RuntimeIndependentSymbols map[string]bool
// SymbolKinds distinguishes value records from reference classes in
// backends whose representation makes that distinction explicit.
SymbolKinds map[string]string
// SymbolTypes, SymbolParameters, and SymbolTypeParameters retain imported
// declaration contracts for editor tooling even when the imported module has
// no generated TypeRB IR.
SymbolTypes map[string]types.Type
SymbolParameters map[string][]types.Type
SymbolTypeParameters map[string][]string
// TypeContracts retain the structural declarations referenced by native
// package signatures so editor tooling can instantiate their members.
TypeContracts map[string]TypeContract
// GeneratedTypeSymbols are target-package type exports referenced only by
// imported declaration contracts. They are emitted as type-only imports but
// stay invisible to source name resolution and editor completion.
GeneratedTypeSymbols []string
}
type Index ¶
type Index struct {
ExprBase
Receiver Expression
Index Expression
}
type InterpolatedString ¶
type InterpolatedString struct {
ExprBase
Raw string
Parts []StringPart
}
type Iterate ¶
type Iterate struct {
Base
Source Expression
Operation string
Intrinsic string
SliceSize Expression
WithIndex bool
Bindings []IterationBinding
Body []Statement
Result *IterationResult
// Fails, EffectSuccess, and CaptureEffect describe only a compiler-declared
// structured Result boundary. They do not represent function effects.
Fails types.Type
EffectSuccess types.Type
CaptureEffect bool
ResultBoundary bool
}
type IterationBinding ¶ added in v0.1.8
Iterate is a structured loop rather than a callback invocation. Backends can therefore preserve TypeRB control-flow semantics inside an each block. Bindings retain the checked type of every source-level block parameter.
type IterationResult ¶ added in v0.2.0
type IterationResult struct {
Variable *Variable
Target Expression
Return bool
Type types.Type
}
type JSXAttribute ¶ added in v0.2.3
type JSXAttribute struct {
Name string
Value Expression
Boolean bool
}
type JSXChild ¶ added in v0.2.3
type JSXChild interface {
// contains filtered or unexported methods
}
type JSXElement ¶ added in v0.2.3
type JSXElement struct {
ExprBase
Name string
Component Expression
Attributes []JSXAttribute
Children []JSXChild
Fragment bool
}
type JSXExpression ¶ added in v0.2.3
type JSXExpression struct {
Value Expression
}
type Lambda ¶ added in v0.2.3
Lambda is a first-class lexical function. Parameters and result remain target-independent so every backend can emit its native closure form.
type Member ¶
type Member struct {
ExprBase
Receiver Expression
Name string
Safe bool
Namespace bool
// ClassField distinguishes storage-backed class properties from methods and
// record fields so backends can preserve both `value.name` and `value.name()`.
ClassField bool
// UnionAlternatives asks representation-sensitive backends to project a
// common data member from an erased union value.
UnionAlternatives []UnionMemberAlternative
Reference *Reference
}
type MemberContract ¶ added in v0.2.26
type Method ¶
type Method struct {
Base
Name string
External bool
TargetName string
TypeParameters []string
Parameters []Parameter
Alternatives []MethodSignature
ReturnType types.Type
Body []Statement
Class bool
// Property exposes an external member without call syntax. Loadable
// properties additionally provide load(), reload(), and loaded?() controls.
Property bool
Loadable bool
}
type MethodSignature ¶ added in v0.2.0
type NativeExpression ¶
type Range ¶
type Range struct {
ExprBase
Start Expression
End Expression
Exclusive bool
}
type RecordField ¶
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 StringPart ¶
type StringPart struct {
Text string
Expression Expression
}
type StructuredBlock ¶ added in v0.2.0
type StructuredBlock struct {
Base
Call *Call
Intrinsic string
Bindings []IterationBinding
Body []Statement
Value Expression
Result *StructuredBlockResult
// Fails, EffectSuccess, and CaptureEffect describe only the structured
// Result boundary declared by the provider.
Fails types.Type
EffectSuccess types.Type
PropagateSuccess types.Type
CaptureEffect bool
}
type StructuredBlockResult ¶ added in v0.2.0
type StructuredBlockResult struct {
Variable *Variable
Target Expression
Return bool
Type types.Type
}
StructuredBlock keeps a compiler-owned, value-producing block call as a typed control-flow boundary. Backends decide how the intrinsic acquires and releases its scoped resource, while the block body and result remain normal TypeRB IR.
type Temporary ¶ added in v0.1.9
Temporary declares an uninitialized compiler-owned local. Portable source cannot construct this node; backend normalization uses it when a value- producing control-flow expression must be emitted as enclosing statements.
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 TypeContract ¶ added in v0.2.26
type TypeContract struct {
TypeParameters []string
AliasTarget *types.Type
Members map[string]MemberContract
}
type Unary ¶
type Unary struct {
ExprBase
Operator string
Operand Expression
}
type UnionMemberAlternative ¶ added in v0.2.3
type While ¶
type While struct {
Base
Condition Expression
Body []Statement
}