Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/transform/transform.x
X2c AST transformation pipeline.
Functions
| Function | Summary |
|---|---|
Compiler.call_in_order | Calls the typed callable callee with arguments, each converted to its parameter and evaluated once, in source order, as a statement expression. |
Compiler.lower_lambda_expr | Lowers a resolved lambda expression, under any position wrappers and parentheses, through the lambda rule of src/components/lambda-functions.x; other expressions pass through. |
Compiler.normalize | Normalizes one bound and typed node. |
Compiler.shipped_support | Adds to the unit’s pending support the file-scope code a rule gives the form source of kind, bound and lowered with the support. |
Compiler.transform | Lowers a bound and typed top-level AST to the normalized form consumed by emission. |
Compiler
Compiler.call_in_order
List Compiler.call_in_order(Compiler c, List callee, List arguments)
Calls the typed callable callee with arguments, each converted to
its parameter and evaluated once, in source order, as a statement
expression.
Source: src/transform/literals.x:225
Compiler.lower_lambda_expr
List Compiler.lower_lambda_expr(Compiler c, List expression)
Lowers a resolved lambda expression, under any position wrappers and
parentheses, through the lambda rule of
src/components/lambda-functions.x;
other expressions pass through. A noncapturing lambda typed Func,
which only a meta body leaves unlifted, lifts to a Func of its native
signature.
Source: src/transform/expressions.x:9
Compiler.normalize
Ast Compiler.normalize(Compiler c, Ast ast)
Normalizes one bound and typed node. Newly constructed syntax is normalized where it is produced; children enter the same operation, so completed units do not require another unit walk.
Source: src/transform/traversal.x:33
Compiler.shipped_support
void Compiler.shipped_support( Compiler c, Symbol kind, List source, String form)
Adds to the unit’s pending support the file-scope code a rule gives
the form source of kind, bound and lowered with the support. The
kernel has no lowering of its own for source, so no rule ends the
translation as _shipped_lowering does.
Source: src/transform/traversal.x:121
Compiler.transform
List Compiler.transform(Compiler c, List ast)
Lowers a bound and typed top-level AST to the normalized form consumed by
emission. c must own the AST’s bindings, origins, and conversion
state. Current-node rewrites finish before child traversal; containing
blocks absorb cleanup markers produced by declaration rewrites. Pending
support declarations are lowered and appended after the input units. Their
storage determines their interface visibility. The call may add
generated origins or diagnostics to c.
Source: src/transform/traversal.x:13
Design notes
Lowers typed expressions, literals, and statements into the AST forms
consumed by C emission. One recursive normalizer rewrites each node
where it is produced, and children enter the same operation, so a unit
is walked once. callables.x lowers the Func conversions it meets,
shipped components lower the forms the kernel no longer lowers, and
cleanup.x lowers each completed function’s cleanup regions. The
active Compiler reports errors.