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

Configured compiler sessions and source units.

Functions

FunctionSummary
Frontend.load_supportLoads process-owned collection support and the native modules request names before units, and selects those modules, in order, for its compile-time calls.
Frontend.newBorrows a configured request for sequential units.
Frontend.openRuns the source stages.
Frontend.open_reportingRuns the source stages for a command that reports to stderr.
Frontend.open_sessionOpens an empty submission unit with the ordinary runtime prelude.
Frontend.preload_macro_librariesEvaluates the compile-time libraries and installs the compiler surface’s own definitions, once for the active build or translation target.
Frontend.startTokenizes one input into a fresh unit with its own isolated Context.
ParsedUnit.closeReleases the unit after its caller has inspected or exported its results.
ParsedUnit.collectCollects symbols and retains preprocessor outputs for adapter inspection.
ParsedUnit.parseParses a collected unit, retaining both its AST and unsuccessful reports.

Frontend

Frontend.load_support

void Frontend.load_support(CliRequest request)

Loads process-owned collection support and the native modules request names before units, and selects those modules, in order, for its compile-time calls.

Source: src/frontend.x:532

Frontend.new

Frontend Frontend.new(CliRequest request)

Borrows a configured request for sequential units. The request and this session must outlive its units. Initialize process support above any temporary command Context before creating a session inside that Context.

Source: src/frontend.x:543

Frontend.open

int Frontend.open(Frontend f, String filename, ParsedUnit &unit)

Runs the source stages. On either result, the caller must close the unit.

Source: src/frontend.x:94

Frontend.open_reporting

int Frontend.open_reporting(Frontend f, String filename, ParsedUnit &unit)

Runs the source stages for a command that reports to stderr. Collection and parsing print each diagnostic as it is reported; a tokenizing failure prints its diagnostics afterward. A failed unit is closed; the caller must close a successful one.

Source: src/frontend.x:102

Frontend.open_session

int Frontend.open_session(Frontend frontend, ParsedUnit &unit)

Opens an empty submission unit with the ordinary runtime prelude. Preload macro libraries first. The caller must close the unit on either result; submissions and inspection results borrow its Context.

Source: src/frontend.x:116

Frontend.preload_macro_libraries

int Frontend.preload_macro_libraries(Frontend frontend)

Evaluates the compile-time libraries and installs the compiler surface’s own definitions, once for the active build or translation target. Returns zero after reporting a failed preload, without publishing a partial session.

Source: src/frontend.x:479

Frontend.start

int Frontend.start(Frontend frontend, String filename, ParsedUnit &unit)

Tokenizes one input into a fresh unit with its own isolated Context. The caller must close the unit on either result.

Source: src/frontend.x:126

ParsedUnit

ParsedUnit.close

void ParsedUnit.close(ParsedUnit &unit)

Releases the unit after its caller has inspected or exported its results.

Source: src/frontend.x:166

ParsedUnit.collect

int ParsedUnit.collect(ParsedUnit &unit, Frontend frontend)

Collects symbols and retains preprocessor outputs for adapter inspection.

Source: src/frontend.x:132

ParsedUnit.parse

int ParsedUnit.parse(ParsedUnit &p)

Parses a collected unit, retaining both its AST and unsuccessful reports.

Source: src/frontend.x:155

Public types

TypeKindSummary
FrontendstructBorrows a configured request and owns shared native-preprocessor setup.
FrontendErrorSinkcallbackReceives borrowed native-preprocessor stderr synchronously during collect.
ParsedUnitstructOwns one isolated source lifetime, including unsuccessful diagnostics.

Frontend

typedef struct Frontend { CliRequest request; List include_dirs; Toolchain toolchain; FrontendErrorSink preprocessor_errors; } *Frontend

Borrows a configured request and owns shared native-preprocessor setup. Nested units close in reverse order; process caches outlive the session. The optional stderr sink runs synchronously; units also retain that text.

Source: src/frontend.x:23

FrontendErrorSink

typedef void (*FrontendErrorSink)(String text)

Receives borrowed native-preprocessor stderr synchronously during collect.

Source: src/frontend.x:17

ParsedUnit

typedef struct ParsedUnit { Context context; Compiler compiler, preprocessor; Map globals, enclosing_var_tags; List ast; String preprocessor_output, preprocessor_errors; int source_lines, generated_symbols; } ParsedUnit

Owns one isolated source lifetime, including unsuccessful diagnostics. Results remain borrowed until close; export values that must survive it.

Source: src/frontend.x:33

Design notes

Shares source setup, collection, parsing, and unit lifetimes between the command-line compiler and internal tools. Adapters own printing and exit.