Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/stage.x
The values crossing between meta code and the program.
Functions
| Function | Summary |
|---|---|
literal_text_value | Returns the value of a String or character literal from its source spelling, quotes included: adjacent pieces are unescaped on their own and joined, as C does, and a character is its code. |
Compiler.check_meta_call | Refuses a run-time call to a meta function this compiler derived compile-time only. |
Compiler.folded_constant | Returns the value of the folded constant node, or void when part of it is only known at run time. |
Compiler.meta_argument | Returns the value the argument expression node of a $ call passes to a parameter of type want, or of no declared type when want is NULL: a constant, captured syntax, or the result of another $ call, which call evaluates. |
Compiler.meta_is_comptime_only | Returns whether fn is a meta function this compiler recorded as compile-time only, whose runtime form the unit does not emit. |
Compiler.meta_value_expression | Returns literal code for a compile-time value, preserving declared when supplied. |
Functions
literal_text_value
Var literal_text_value(String spelling)
Returns the value of a String or character literal from its source
spelling, quotes included: adjacent pieces are unescaped on their own
and joined, as C does, and a character is its code.
Source: src/stage.x:213
Compiler
Compiler.check_meta_call
void Compiler.check_meta_call(Compiler c, List callee, Token origin)
Refuses a run-time call to a meta function this compiler derived
compile-time only.
Such a function reaches a Meta operation, so it exists only inside a
compiler and the unit emits no definition for it. Unchecked, the call
reaches the linker as an undefined symbol, which names the C spelling
and not the source. Another meta function may call it: calling one is
what makes the caller compile-time only too, so a body being parsed
under the marker is left alone.
Source: src/stage.x:448
Compiler.folded_constant
Var Compiler.folded_constant(Compiler c, Var node)
Returns the value of the folded constant node, or void when part of it
is only known at run time. Literal folding hoists a constant into the
compiler cache and leaves (cache ID), a graph of ids over cons,
var and string leaves.
Source: src/stage.x:139
Compiler.meta_argument
Var Compiler.meta_argument( Compiler c, List node, Type want, Token site, MetaCall call)
Returns the value the argument expression node of a $ call passes to
a parameter of type want, or of no declared type when want is NULL:
a constant, captured syntax, or the result of another $ call, which
call evaluates. Captured literal syntax reaches a parameter that is not
syntax as the literal’s value, a TypeInfo parameter as the description
of its type, and a Source parameter with its source text. Anything
else is reported at site.
Source: src/stage.x:64
Compiler.meta_is_comptime_only
int Compiler.meta_is_comptime_only(Compiler c, List fn)
Returns whether fn is a meta function this compiler recorded as
compile-time only, whose runtime form the unit does not emit.
Source: src/stage.x:459
Compiler.meta_value_expression
List Compiler.meta_value_expression( Compiler c, Type declared, Var value, Token site)
Returns literal code for a compile-time value, preserving declared
when supplied. An Array or Map, at any depth, becomes a literal that
builds a fresh collection on every execution; other data comes from the
literal cache. A cycle or a collection held twice is reported at site.
Returns NULL for code Lists or values without a literal representation.
Source: src/stage.x:241
Design notes
This file owns what crosses between meta code and the program: the
arguments a $ call passes, evaluated from constants, captured syntax,
and other $ calls; the literal code a result becomes; and the rule
that a function reaching a compiler operation has no runtime form. A
unit’s meta group and its emission are in meta-group.x; the
compiler’s side of the project helper is in meta-helper-client.x.