Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/generate.x
Generate C headers and source files.
Functions
| Function | Summary |
|---|---|
generate_code | Writes the generated C header and source for one lowered translation unit. |
Functions
generate_code
void generate_code(Compiler c, List ast, String dir)
Writes the generated C header and source for one lowered translation unit.
ast must be the normalized result of transform_ast for this compiler;
its filename, symbols, binding facts, cache keys, and initialization state
must still describe that same unit. dir must already exist. Generation
partitions the AST, materializes caches and once-only initialization,
performs the generation-phase source transform, and writes or replaces
<dir>/<source-stem>.h and .c. It appends generated bindings and
initialization work to the compiler and is not idempotent. The header is
written before the source, so an output failure may leave the header
replaced; failures are reported as emit diagnostics.
Source: src/generate.x:692
Design notes
Turns a normalized AST into formatted header and source files. It splits the header from the source, adds once-only translation-unit initialization and include guards, and writes the files. Filesystem failures retain their target and host error as compiler diagnostic notes.