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

C tokens from normalized x2c ASTs.

Functions

FunctionSummary
Compiler.emitEmits a bound, typed, transform-normalized AST sequence as flat C tokens.

Compiler

Compiler.emit

List Compiler.emit(Compiler c, List ast, Map cache_bindings)

Emits a bound, typed, transform-normalized AST sequence as flat C tokens. Source mapping adds src-at/ID pairs consumed by the formatter. The 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. cache_bindings maps semantic cache ids to generated slots; NULL keeps raw ids for inspection. 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/dispatch.x:92

Design notes

This module owns emission: it turns a bound, typed, transform-normalized AST into the token Lists that formatting prints as C. 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. transform.x has already placed each cleanup region’s statements on the exits that leave it.