Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/emit.x
Emit C tokens from x2c ASTs.
Functions
| Function | Summary |
|---|---|
Compiler.emit | Emits a bound, typed, transform-normalized AST sequence as flat C tokens. |
Compiler
Compiler.emit
List Compiler.emit(Compiler compiler, List ast)
Emits a bound, typed, transform-normalized AST sequence as flat C tokens.
Source mapping adds src-at/ID pairs consumed by the formatter.
compiler must own the AST’s binding facts and origins, and continue the
translation session’s shared generated-name state. This operation does not
bind, transform, or choose header and source placement; generation supplies
any added scaffolding in the same normalized grammar. It preserves the
top-level AST sequence and advances generated-name counters as it allocates
temporaries. Returned canonical Lists and Strings are owned by pools
active during emission; promote them before releasing those pools if the
tokens must survive.
Source: src/emit.x:1451
Design notes
Translates normalized ASTs into token Lists for downstream flattening and
formatting. One stack-local Emitter holds the current function’s name,
static objects, and native aliases, so emission is reentrant and a failed
translation cannot contaminate later units. cleanup.x has already placed
each cleanup region’s statements on the exits that leave it.