Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/transform.x

X2c AST transformation pipeline.

Functions

FunctionSummary
transform_array_literalConverts an (array ...) or (varray ...) node to source-ordered (varray ...) form, converting every typed element to Var.
transform_map_literalConverts a (map ...) or (vmap ...) node to source-ordered (vmap (vpair ...)) form, converting every typed key and value to Var.
Compiler.transformLowers a bound and typed top-level AST to the normalized form consumed by emission.

Functions

transform_array_literal

List transform_array_literal(Compiler compiler, List ast)

Converts an (array ...) or (varray ...) node to source-ordered (varray ...) form, converting every typed element to Var.

Source: src/transform.x:1082

transform_map_literal

List transform_map_literal(Compiler compiler, List ast)

Converts a (map ...) or (vmap ...) node to source-ordered (vmap (vpair ...)) form, converting every typed key and value to Var.

Source: src/transform.x:1096

Compiler

Compiler.transform

List Compiler.transform(Compiler compiler, List ast)

Lowers a bound and typed top-level AST to the normalized form consumed by emission. compiler must own the AST’s bindings, origins, and conversion state. The call drives the input and synthesized early declarations to identity fixed points, appends those declarations after the input units, and may add generated origins or diagnostics to compiler.

Source: src/transform.x:1852

Design notes

Lowers typed expressions, literals, and control flow into the AST forms consumed by C emission.

Each pass transforms a typed AST and returns an immutable List tree. The driver repeats the passes until the tree stops changing, using structural identity to detect changes. The active Compiler reports errors.