Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/callables/callables.x
Callable values lowered to C helpers.
Functions
| Function | Summary |
|---|---|
Compiler.adapt_lambda_arg | Adapts a lowered noncapturing lambda helper to a typed callback. |
Compiler.capture_environment | Binds the file-static context type name with the field rows fields, for callable defers and function-pointer Func values. |
Compiler.context_func_adapter | Builds an adapter with type’s public signature that passes its own Func as the first argument of target, before the declared arguments. |
Compiler.func_parameters | Returns (SIGNATURE (STORAGE READ)...) for an adapter of a Var function taking the lambda parameter rows entries: its Func signature as a cached List, and each argument as _func_reads reads it from argv of the Func fn. |
Compiler.func_signature | Returns the canonical signature shared by native and meta Func adapters. |
Compiler.lift_func_expression | Converts a resolved function-like expression to Func when supported. |
Compiler.lower_typed_adapter_expr | Lowers a resolved tadapt expression to a typed callback helper. |
Compiler.maybe_adapt_func_arg | Adapts a direct native function argument when FuncAdapter is expected. |
Compiler.prepend_setup | Puts setup at the entry of a block or typed expression body. |
Compiler
Compiler.adapt_lambda_arg
List Compiler.adapt_lambda_arg(Compiler c, List argument, List expected_type)
Adapts a lowered noncapturing lambda helper to a typed callback.
argument must be a resolved helper reference produced by
Compiler.lower_lambda_expr, optionally wrapped in parentheses.
expected_type must describe a fixed, nonvariadic function. Unless its
parameters and result are already Var,
a queued static helper converts callback arguments to the lowered lambda’s
original parameter types before calling it, then converts its Var result
to the expected return type. Already compatible or unsupported shapes pass
through unchanged.
Source: src/callables/callbacks.x:167
Compiler.capture_environment
List Compiler.capture_environment(Compiler c, List name, List fields)
Binds the file-static context type name with the field rows fields,
for callable defers and function-pointer Func values. The complete
typedef is bound at once, so each field keeps its member type. It binds
at file scope whatever local scope is open.
Source: src/callables/adapters.x:84
Compiler.context_func_adapter
List Compiler.context_func_adapter(Compiler c, Type type, List target)
Builds an adapter with type’s public signature that passes its own
Func as the first argument of target, before the declared arguments.
The target can read per-instance bindings with Func.context.
Source: src/callables/adapters.x:215
Compiler.func_parameters
List Compiler.func_parameters( Compiler c, List entries, List fn, List argv)
Returns (SIGNATURE (STORAGE READ)...) for an adapter of a Var
function taking the lambda parameter rows entries: its Func
signature as a cached List, and each argument as _func_reads
reads it from argv of the Func fn.
Source: src/callables/adapters.x:282
Compiler.func_signature
List Compiler.func_signature(Compiler c, Type type)
Returns the canonical signature shared by native and meta Func adapters.
Source: src/callables/adapters.x:386
Compiler.lift_func_expression
List Compiler.lift_func_expression(Compiler c, List expression)
Converts a resolved function-like expression to Func when supported.
Existing Func values pass through. Direct fixed functions reuse a
file-static handle; other function-typed and function-pointer expressions
are evaluated once and copied into a new context-bound Func, with null
pointers producing null Func. Lambda expressions are lowered first, and
unrelated expressions pass through unchanged. Public inline functions
reach the queued helpers through generated bridge functions.
Source: src/callables/values.x:13
Compiler.lower_typed_adapter_expr
List Compiler.lower_typed_adapter_expr(Compiler c, List expression)
Lowers a resolved tadapt expression to a typed callback helper.
expression must have the resolved shape
(expr TARGET (tadapt ORIGIN (expr SOURCE (ident BINDING)))).
Compatible helpers are cached by source binding and target type, queued
with Compiler.add_early, and returned as typed identifiers; other
expressions pass through unchanged.
Source: src/callables/callbacks.x:55
Compiler.maybe_adapt_func_arg
List Compiler.maybe_adapt_func_arg( Compiler c, List argument, List expected_type)
Adapts a direct native function argument when FuncAdapter is expected.
A noncapturing lambda is lowered to its direct function designator. Other
arguments must be resolved direct designators, possibly parenthesized,
cast, or addressed; an indirect function-pointer value is rejected.
A function already having the adapter’s pointee type passes through,
and new helpers are cached and queued with Compiler.add_early.
Source: src/callables/adapters.x:126
Compiler.prepend_setup
List Compiler.prepend_setup(Compiler c, List body, List setup)
Puts setup at the entry of a block or typed expression body.
Source: src/callables/adapters.x:97
Design notes
A callable value that C cannot spell directly becomes a static helper
queued with Compiler.add_early. Every Func helper shares one
FuncAdapter ABI: arguments are read in index order from the argument
vector, and the result is boxed into a Var.
src/components/lambda-functions.x
lowers lambdas.