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/emit.x

Emit C tokens from x2c ASTs.

Functions

FunctionSummary
Compiler.emitEmits 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. 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. Invalid goto placement reports through the compiler’s <emit> diagnostic path. 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:1359

Design notes

Translates normalized ASTs into token Lists for downstream flattening and formatting. One stack-local Emitter holds cleanup guards and preserved automatic names, so emission is reentrant and a failed translation cannot contaminate later units. Cleanup lowering preserves handler order and the active exit kind across returns and loop exits.