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

Core x2c compiler state and operations.

Functions

FunctionSummary
home_absolute_pathReturns the absolute path that a home_portable_path spelling names.
home_portable_pathReturns path relative to the canonical x2c home when it lies below the home, otherwise path.
Compiler._at_function_arrowReports whether the current two tokens are =>.
Compiler._skip_shallow_expressionSkips a balanced shallow expression without consuming its terminator.
Compiler.add_earlyAppends a generated declaration to the early-declaration queue.
Compiler.add_initAppends a statement to file initialization order under phase, which is <protocol> for protocol setup, or <early>, <mid>, or <late> for the file initializer’s three stages.
Compiler.add_translation_dependencyRecords a path dependency not embedded in generated C.
Compiler.aggregate_nameBinds a local aggregate tag before its fields, preserving native spelling.
Compiler.anchor_originWraps a parsed node in the source location of its opening token.
Compiler.begin_semantic_transactionBegins a reversible transaction over the current semantic scope.
Compiler.borrow_diagnosticsShares a caller’s diagnostic stream while preserving its emission policy.
Compiler.borrow_unit_semanticsShares the symbol table, literal cache, and protocol registries of the unit owner is translating, so a child that binds declarations binds them into that unit.
Compiler.cacheInterns a constant key and returns its stable (cache id) reference.
Compiler.cache_cons_cellCaches a cons cell when both parts have immutable cache forms.
Compiler.cache_literal_listReturns a runtime List expression for cached compiler-owned syntax.
Compiler.canonical_pathReturns the spelling that identifies the file at path.
Compiler.close_childRetains a child’s final diagnostics and closes its owned Lisp session.
Compiler.copy_source_declarationCarries declaration metadata with one actual symbol contribution.
Compiler.define_match_bindersDefines a typed Match pattern’s definite binders in the current scope.
Compiler.emitted_binding_nameReturns a binding’s selected emitted spelling.
Compiler.expectRequires and consumes the current token type.
Compiler.free_lispDestroys a compiler’s owned Lisp session, if any.
Compiler.freeze_declaration_syntaxRetains declaration syntax across source segments and cached interfaces.
Compiler.fresh_nameAllocates the next compiler-private C spelling for stem.
Compiler.full_parseParses and types the positioned source against globs.
Compiler.gensymReturns a fresh semantic identity for an anonymous aggregate.
Compiler.imported_providersReturns sorted imported packages that publish name.
Compiler.imported_spellingReturns an unambiguous imported spelling for name, or NULL.
Compiler.init_statementsReturns the statements queued for phase, in the order they were added.
Compiler.leading_preprocReturns source-ordered preprocessor nodes in the preceding trivia.
Compiler.macro_definition_localsReturns the active macro definition’s borrowed local map, or NULL.
Compiler.match_pattern_bindersReturns definite binders from a typed Match pattern AST.
Compiler.match_pattern_flat_headReturns the head of a flat Symbol-and-captures pattern, or zero.
Compiler.match_pattern_head_symbolReturns a typed Match pattern’s fixed literal head symbol, or zero.
Compiler.match_pattern_is_staticReports whether a typed Match pattern has a fully static value graph.
Compiler.match_pattern_valueRecovers a pattern value graph, using x2c-dyn for computed values.
Compiler.merge_source_declarationsCarries declaration metadata beside a completed symbol-map merge.
Compiler.merge_translation_dependenciesMerges another translation’s dependency rows into this compiler.
Compiler.newCreates a compiler with independent package and generated-name state.
Compiler.new_sharedCreates a compiler sharing its owner’s package and generated-name state.
Compiler.nextConsumes the current token and advances past following trivia.
Compiler.own_diagnosticsRoutes this compiler’s diagnostic store through its own printer.
Compiler.package_member_spellingReturns a visible with name’s package-prefixed spelling, or NULL.
Compiler.package_spellingReturns a name in the current package namespace, preserving prefixes.
Compiler.parsing_source_syntaxReports the outer deferred source parser, excluding macro templates.
Compiler.peekReturns the non-trivia token type steps from parser position.
Compiler.queue_declaration_effectQueues a source Lisp form until declaration production needs its state.
Compiler.read_sourceReads a source through the request view and retains exact response bytes.
Compiler.record_originRecords a token’s location and returns its one-based occurrence.
Compiler.record_source_declarationRecords a physical declaration using the binding’s actual scope and key.
Compiler.record_source_referenceRecords a resolved reference without inventing spans for constructed ASTs.
Compiler.register_package_aliasRegisters one local package alias.
Compiler.register_package_memberRegisters one package member under a bare local spelling.
Compiler.return_unit_stateReturns that state to owner, so the next segment starts where this one finished and any Lisp environment this segment created stays alive after the shadow is released.
Compiler.run_declaration_effectsRuns pending effects for declaration production or CPP macro evaluation.
Compiler.select_declaration_defaultsSelects the owning file’s declaration defaults after all its segments.
Compiler.semantic_binding_factsReturns the current borrowed semantic-facts map indexed by binding.
Compiler.shallow_parseCollects file-scope declarations into globals without parsing bodies.
Compiler.shallow_parse_overlayCollects declarations with reads over base then overlay.
Compiler.skip_script_statementMoves past one run of a script unit’s statement tokens, through a ; or a closing } outside every bracket.
Compiler.skip_trivia_fromReturns the first non-trivia token at or after token.
Compiler.take_diagnosticsMoves collected child reports into the caller’s store without re-emitting.
Compiler.take_unit_stateTakes over owner’s macro, object-like #define, import, keyword, and Lisp state for one segment of a collected file.
Compiler.testConsumes type when current and reports whether it matched.
Compiler.thaw_declaration_syntaxRestores a retained declaration recipe in the current parsing lifetime.
Compiler.tokenizeScans source and positions the compiler at its first non-trivia token.
Compiler.update_source_visibilityApplies public and private pragma directives to source visibility state and records each object-like #define name, less those #undef drops, for the literal warning.
Compiler.varBoxes the compiler’s pointer; the caller keeps the compiler.
Map.merge_translation_dependencyMerges one translation dependency, preserving an existing content hash.
Sym.base_symbolsCopies all base-scope symbols into a fresh map in source order.
Sym.bind_identityInstalls an existing binding with ast’s qualifier-preserving type.
Sym.binding_is_localReports whether binding belongs to a scope inside the base scopes.
Sym.binding_is_local_beforeReports whether binding belongs to a local scope below scope_count.
Sym.current_bindingReturns key’s binding in the current scope, or NULL.
Sym.current_symbolsReturns the current scope’s mutable symbol map, or NULL.
Sym.declareAnalyzes a complete declaration type and installs its stored declared type.
Sym.declare_delegate_fieldMarks one named aggregate field as a delegate.
Sym.declare_enumeratorAssociates an enumerator key with its owner in the active scope.
Sym.declare_field_orderRecords declaration AST fields in source order after binding finishes.
Sym.defineDefines key and returns its stable binding in the active scope.
Sym.define_globalDefines key in the unit’s writable base scope and returns its binding.
Sym.define_macroDefines or replaces a macro in the active lexical scope.
Sym.delegate_aggregateResolves typedefs or one pointer layer to an aggregate tag, or NULL.
Sym.enumerator_ownerReturns the current scope’s enum owner for key, or zero.
Sym.field_orderReturns recorded fields in source order, or NULL.
Sym.file_staticsReturns the current borrowed set of file-static declaration keys.
Sym.getReturns key’s type, retrying a bare key in package space, or NULL.
Sym.get_exactReturns key’s type without package fallback, or NULL.
Sym.global_symbolsReturns the mutable global symbol map supplied to the latest reset.
Sym.has_local_macrosReturns whether any lexical scope contains a local macro definition.
Sym.introduceAllocates a fresh binding identity for a compiler-introduced spelling.
Sym.is_array_typeReports whether type reaches the named Array value type.
Sym.is_map_typeReports whether type reaches the named Map value type.
Sym.is_named_value_typeReports whether type reaches a named value type before its definition.
Sym.is_string_typeReports whether type reaches the named String value type.
Sym.is_var_typeReports whether type reaches the named Var value type.
Sym.local_typeResolves a block-local typedef to the type saved at its declaration.
Sym.lookupResolves an existing key and optionally stores its semantic type.
Sym.lookup_fieldReturns an aggregate field’s declared type, or NULL.
Sym.lookup_macroReturns the innermost visible local macro named name, or NULL.
Sym.mark_staticMarks a declaration key as file-static.
Sym.next_typedefResolves one typedef hop and counts against the shared cycle budget.
Sym.normalize_declared_typeResolves typedef bases while retaining every declarator qualifier.
Sym.pop_scopePops the innermost scope, or returns an empty scope when none exists.
Sym.push_new_scopePushes a new empty lexical scope.
Sym.push_scopePushes a caller-supplied lexical scope while retaining its map objects.
Sym.referenceResolves key or creates a forward binding in the current scope.
Sym.reference_globalResolves a global name or creates its forward binding in the base scope.
Sym.resetResets symbol state to one base scope backed by globals.
Sym.resolve_globalResolves a binding through base scopes and optionally stores its type.
Sym.resolve_keyResolves a canonical typedef key to the end of its declared chain.
Sym.resolve_numeric_typeResolves a numeric typedef without reducing semantic object types.
Sym.scope_countReturns the number of semantic scopes, including base scopes.
Sym.seed_var_tagsRegisters declared T_var converters in the active Type unit.
Sym.setSets a semantic type for key in the required active scope.
Sym.var_tag_for_typeReturns a type’s Var tag and optionally stores its resolved type.
SymTxn.commitPublishes an active semantic transaction and makes rollback a no-op.
SymTxn.local_macros_changedReturns whether the transaction’s active scope changed its macro map.
SymTxn.rollbackRestores every semantic value captured by an active transaction.
Symbol.group_stepReturns 1 for a token type that opens a delimited group, -1 for one that closes a group, and 0 otherwise.
Token.after_groupReturns the first non-trivia token after the group t opens, or after t when it opens no group.
Token.group_closeReturns the token that closes the group t opens, t itself when it opens no group, or the eof token when the group never closes.
Var.compilerRecovers the compiler pointer boxed by Compiler.var.

Functions

home_absolute_path

String home_absolute_path(String spelling)

Returns the absolute path that a home_portable_path spelling names.

Source: src/compiler.x:455

home_portable_path

String home_portable_path(String path)

Returns path relative to the canonical x2c home when it lies below the home, otherwise path. Interfaces, retained declarations, and generated identities spell paths this way, so they do not depend on where the home is installed.

Source: src/compiler.x:449

Compiler

Compiler._at_function_arrow

int Compiler._at_function_arrow(Compiler compiler)

Reports whether the current two tokens are =>.

Source: src/compiler.x:914

Compiler._skip_shallow_expression

void Compiler._skip_shallow_expression(Compiler c, int stop_at_comma)

Skips a balanced shallow expression without consuming its terminator. A top-level comma also terminates the expression when stop_at_comma is nonzero.

Source: src/compiler.x:921

Compiler.add_early

void Compiler.add_early(Compiler compiler, List decl)

Appends a generated declaration to the early-declaration queue.

Source: src/compiler.x:2185

Compiler.add_init

void Compiler.add_init(Compiler compiler, Symbol phase, List stmt)

Appends a statement to file initialization order under phase, which is <protocol> for protocol setup, or <early>, <mid>, or <late> for the file initializer’s three stages.

Source: src/compiler.x:2193

Compiler.add_translation_dependency

void Compiler.add_translation_dependency(Compiler compiler, String path)

Records a path dependency not embedded in generated C.

Source: src/compiler.x:205

Compiler.aggregate_name

Var Compiler.aggregate_name( Compiler compiler, Symbol kind, Var name, int definition)

Binds a local aggregate tag before its fields, preserving native spelling. A reference reuses the nearest visible tag; a definition or standalone forward declaration introduces the tag in the current lexical scope.

Source: src/compiler.x:3326

Compiler.anchor_origin

List Compiler.anchor_origin(Compiler compiler, List node, Token token)

Wraps a parsed node in the source location of its opening token.

A null node remains null. Macro construction uses its active m-origin marker; otherwise a node without a token remains unwrapped.

Source: src/compiler.x:868

Compiler.begin_semantic_transaction

SymTxn Compiler.begin_semantic_transaction(Compiler c)

Begins a reversible transaction over the current semantic scope.

The transaction stages the current scope maps, file-static and binding facts, binding and generated-name counters, and initializer names. It does not snapshot parser position or other compiler state.

Source: src/compiler.x:2279

Compiler.borrow_diagnostics

void Compiler.borrow_diagnostics(Compiler compiler, Compiler owner)

Shares a caller’s diagnostic stream while preserving its emission policy. The caller restores the saved printer after this child finishes.

Source: src/compiler.x:259

Compiler.borrow_unit_semantics

void Compiler.borrow_unit_semantics(Compiler compiler, Compiler owner)

Shares the symbol table, literal cache, and protocol registries of the unit owner is translating, so a child that binds declarations binds them into that unit. A meta definition in a macro import is bound here and emitted by owner, so both compilers must read one table: its (cache id) references index owner’s keys, and its operations resolve through owner’s protocol rows. Both install into one macro session, so they also read one record of which meta functions reach file-scope state.

Source: src/compiler.x:273

Compiler.cache

List Compiler.cache(Compiler c, List key)

Interns a constant key and returns its stable (cache id) reference.

Source: src/compiler.x:1990

Compiler.cache_cons_cell

List Compiler.cache_cons_cell(Compiler compiler, List head, List tail)

Caches a cons cell when both parts have immutable cache forms.

Returns NULL when runtime literals are required or either part cannot be represented by the immutable cache graph.

Source: src/compiler.x:2003

Compiler.cache_literal_list

List Compiler.cache_literal_list(Compiler compiler, List values)

Returns a runtime List expression for cached compiler-owned syntax.

values may contain nested Lists, Strings, and Symbols.

Source: src/compiler.x:2049

Compiler.canonical_path

String Compiler.canonical_path(Compiler c, String path)

Returns the spelling that identifies the file at path. Through a source view it is the absolute path, because an unsaved file need not exist on disk; otherwise it is the real path, or path itself when that does not resolve.

Source: src/compiler.x:438

Compiler.close_child

void Compiler.close_child(Compiler compiler, Compiler child)

Retains a child’s final diagnostics and closes its owned Lisp session.

Source: src/compiler.x:302

Compiler.copy_source_declaration

void Compiler.copy_source_declaration( Compiler compiler, Map target, Map source, List key)

Carries declaration metadata with one actual symbol contribution.

Source: src/compiler.x:459

Compiler.define_match_binders

void Compiler.define_match_binders(Compiler compiler, List pattern)

Defines a typed Match pattern’s definite binders in the current scope.

Source: src/compiler.x:2176

Compiler.emitted_binding_name

String Compiler.emitted_binding_name(Compiler compiler, List binding)

Returns a binding’s selected emitted spelling.

A binding without an explicit emission rename uses its identity spelling.

Source: src/compiler.x:556

Compiler.expect

Symbol Compiler.expect(Compiler c, Symbol type)

Requires and consumes the current token type.

A mismatch reports a parse diagnostic. An active recovery boundary raises <malformed>; without one, diagnostic reporting exits.

Source: src/compiler.x:784

Compiler.free_lisp

void Compiler.free_lisp(Compiler c)

Destroys a compiler’s owned Lisp session, if any.

A borrowed session is left alive. Owned sessions not freed here are destroyed when the compiler’s Scope ends. This is final compiler cleanup: it clears the diagnostic store and the compiler must not be reused. At process exit, root Scope cleanup follows shutdown hooks and canonical pool cleanup. Close explicitly while any native session dependencies live.

Source: src/compiler.x:232

Compiler.freeze_declaration_syntax

Var Compiler.freeze_declaration_syntax(Compiler c, Var syntax)

Retains declaration syntax across source segments and cached interfaces. Tokens and origin indices become portable source data; marker-shaped user Lists are escaped so thawing preserves their values.

Source: src/compiler.x:1015

Compiler.fresh_name

String Compiler.fresh_name(Compiler compiler, String stem)

Allocates the next compiler-private C spelling for stem.

Related compilers increment the same per-stem counter, except while a macro import is being parsed, which counts separately. An import’s meta bodies are parsed in every unit that imports the file and in none that is built from the .xi prelude, so a name minted there must not move the unit’s own counter or the two modes emit different C. Those names carry an m before the stem, so they cannot collide with the unit’s.

Source: src/compiler.x:543

Compiler.full_parse

List Compiler.full_parse(Compiler c, Map globs, int generated_symbols)

Parses and types the positioned source against globs.

The result is a source-ordered top-level AST. This resets per-parse origins, macro state, and protocol resolution. generated_symbols publishes external adapter signatures before parsing.

Source: src/compiler.x:1714

Compiler.gensym

List Compiler.gensym(Compiler c)

Returns a fresh semantic identity for an anonymous aggregate. Identities are scoped to the compiler’s current file and numbered per file, so every process mints the same sequence for one file and two files never share an identity. No emission path prints one.

Source: src/compiler.x:3498

Compiler.imported_providers

List Compiler.imported_providers(Compiler c, String name)

Returns sorted imported packages that publish name.

Package-owned methods use <package>__<Type>_<member> internally while consumers retain the spelling from the package header. Sorting keeps ambiguity diagnostics deterministic.

Source: src/compiler.x:2803

Compiler.imported_spelling

String Compiler.imported_spelling(Compiler compiler, String name)

Returns an unambiguous imported spelling for name, or NULL.

Source: src/compiler.x:2815

Compiler.init_statements

List Compiler.init_statements(Compiler compiler, Symbol phase)

Returns the statements queued for phase, in the order they were added.

Source: src/compiler.x:2198

Compiler.leading_preproc

List Compiler.leading_preproc(Compiler compiler)

Returns source-ordered preprocessor nodes in the preceding trivia.

Spaces and comments remain trivia rather than becoming AST nodes.

Source: src/compiler.x:1505

Compiler.macro_definition_locals

Map Compiler.macro_definition_locals(Compiler compiler)

Returns the active macro definition’s borrowed local map, or NULL.

Source: src/compiler.x:529

Compiler.match_pattern_binders

List Compiler.match_pattern_binders(Compiler c, List pattern, List *possible)

Returns definite binders from a typed Match pattern AST.

When possible is non-null, stores every binder appearing on any path.

Source: src/compiler.x:2166

Compiler.match_pattern_flat_head

Symbol Compiler.match_pattern_flat_head( Compiler compiler, List pattern, List binders, List *tags)

Returns the head of a flat Symbol-and-captures pattern, or zero.

Each element after the head is a unique named ? binder or a typed capture of one. When tags is non-null, stores one entry per binder in order: the capture’s tag Symbol, or integer zero when untyped.

Source: src/compiler.x:2141

Compiler.match_pattern_head_symbol

Symbol Compiler.match_pattern_head_symbol(Compiler compiler, List pattern)

Returns a typed Match pattern’s fixed literal head symbol, or zero.

A binder, guard, non-list value, or computed head has no fixed symbol. Other pattern elements may remain dynamic because a literal head alone constrains the first input element.

Source: src/compiler.x:2110

Compiler.match_pattern_is_static

int Compiler.match_pattern_is_static(Compiler compiler, List pattern)

Reports whether a typed Match pattern has a fully static value graph.

Source: src/compiler.x:2101

Compiler.match_pattern_value

Var Compiler.match_pattern_value(Compiler c, Var node)

Recovers a pattern value graph, using x2c-dyn for computed values.

Source: src/compiler.x:2067

Compiler.merge_source_declarations

void Compiler.merge_source_declarations(Compiler c, Map target, Map source)

Carries declaration metadata beside a completed symbol-map merge.

Source: src/compiler.x:470

Compiler.merge_translation_dependencies

void Compiler.merge_translation_dependencies(Compiler c, Map dependencies)

Merges another translation’s dependency rows into this compiler.

Source: src/compiler.x:210

Compiler.new

Compiler Compiler.new(void)

Creates a compiler with independent package and generated-name state.

Source: src/compiler.x:382

Compiler.new_shared

Compiler Compiler.new_shared(Compiler owner)

Creates a compiler sharing its owner’s package and generated-name state.

Source: src/compiler.x:385

Compiler.next

void Compiler.next(Compiler compiler)

Consumes the current token and advances past following trivia.

This updates the unmatched-brace stack. An unmatched } reports a parse diagnostic, which raises <malformed> under recovery and otherwise exits.

Source: src/compiler.x:813

Compiler.own_diagnostics

void Compiler.own_diagnostics(Compiler compiler)

Routes this compiler’s diagnostic store through its own printer.

Compilers that share a store call this when taking the diagnostic stream back from another compiler.

Source: src/compiler.x:252

Compiler.package_member_spelling

String Compiler.package_member_spelling(Compiler c, String name)

Returns a visible with name’s package-prefixed spelling, or NULL.

An ordinary declaration of the local spelling shadows the with name.

Source: src/compiler.x:2788

Compiler.package_spelling

String Compiler.package_spelling(Compiler compiler, String name)

Returns a name in the current package namespace, preserving prefixes.

Idempotence lets parsing and declaration rewrites share this operation.

Source: src/compiler.x:2719

Compiler.parsing_source_syntax

int Compiler.parsing_source_syntax(Compiler c)

Reports the outer deferred source parser, excluding macro templates.

Source: src/compiler.x:525

Compiler.peek

Symbol Compiler.peek(Compiler compiler, int steps)

Returns the non-trivia token type steps from parser position.

Zero reads the current token; positive and negative steps count forward and backward through non-trivia tokens. The parser cursor is unchanged.

Source: src/compiler.x:766

Compiler.queue_declaration_effect

void Compiler.queue_declaration_effect( Compiler c, String form, Token first, Token after)

Queues a source Lisp form until declaration production needs its state. Files without declaration producers keep ordinary full-parse evaluation.

Source: src/compiler.x:1092

Compiler.read_source

int Compiler.read_source(Compiler c, String path, String volatile *text)

Reads a source through the request view and retains exact response bytes.

Source: src/compiler.x:427

Compiler.record_origin

int Compiler.record_origin(Compiler c, Token token)

Records a token’s location and returns its one-based occurrence.

A null token returns zero. Callers pass the token that opened a construct, so an (at N node) wrapper retains its start for transform diagnostics after compiler.token has reached end of file.

Source: src/compiler.x:854

Compiler.record_source_declaration

void Compiler.record_source_declaration( Compiler c, List binding, Token first, Token after)

Records a physical declaration using the binding’s actual scope and key.

Source: src/compiler.x:489

Compiler.record_source_reference

void Compiler.record_source_reference( Compiler c, List binding, Type type, Token first, Token after)

Records a resolved reference without inventing spans for constructed ASTs.

Source: src/compiler.x:510

Compiler.register_package_alias

void Compiler.register_package_alias( Compiler compiler, String name, String alias, Token token)

Registers one local package alias.

Shallow collection and full parsing both see an import, so repeating the same package and alias is a no-op. Another binding of the local spelling is a parse error.

Source: src/compiler.x:2754

Compiler.register_package_member

void Compiler.register_package_member( Compiler c, String name, String member, String local, Token member_token, Token local_token)

Registers one package member under a bare local spelling.

The package member must already exist in the symbol table. Repeating the same binding is a no-op; any conflicting local binding is an error.

Source: src/compiler.x:2767

Compiler.return_unit_state

void Compiler.return_unit_state(Compiler compiler, Compiler owner)

Returns that state to owner, so the next segment starts where this one finished and any Lisp environment this segment created stays alive after the shadow is released.

Source: src/compiler.x:412

Compiler.run_declaration_effects

void Compiler.run_declaration_effects(Compiler c)

Runs pending effects for declaration production or CPP macro evaluation.

Source: src/compiler.x:1102

Compiler.select_declaration_defaults

Map Compiler.select_declaration_defaults( Compiler compiler, String path, Map symbols, Array parts, Map definitions)

Selects the owning file’s declaration defaults after all its segments. The selected signatures join ordinary declarations before protocol and body binding; discarded candidates never bind their bodies. Returns added signatures for the caller to retain in the header-cache lifetime.

Source: src/compiler.x:1277

Compiler.semantic_binding_facts

Map Compiler.semantic_binding_facts(Compiler c)

Returns the current borrowed semantic-facts map indexed by binding.

A semantic transaction may replace this map, so reacquire it afterwards.

Source: src/compiler.x:522

Compiler.shallow_parse

void Compiler.shallow_parse(Compiler c, Map globals)

Collects file-scope declarations into globals without parsing bodies.

Source: src/compiler.x:1472

Compiler.shallow_parse_overlay

void Compiler.shallow_parse_overlay(Compiler c, Map base, Map overlay)

Collects declarations with reads over base then overlay.

Writes go to overlay, which captures exactly what this translation contributes above base.

Source: src/compiler.x:1487

Compiler.skip_script_statement

void Compiler.skip_script_statement(Compiler c)

Moves past one run of a script unit’s statement tokens, through a ; or a closing } outside every bracket. A statement that ends early this way leaves its remainder as the next run, and runs are rejoined in order.

Source: src/compiler.x:934

Compiler.skip_trivia_from

Token Compiler.skip_trivia_from(Compiler compiler, Token token)

Returns the first non-trivia token at or after token.

Source: src/compiler.x:726

Compiler.take_diagnostics

void Compiler.take_diagnostics(Compiler compiler, Compiler child)

Moves collected child reports into the caller’s store without re-emitting. Shared stores already contain their entries. The child’s separate store remains configured and empty after its reports have been transferred.

Source: src/compiler.x:291

Compiler.take_unit_state

void Compiler.take_unit_state(Compiler compiler, Compiler owner)

Takes over owner’s macro, object-like #define, import, keyword, and Lisp state for one segment of a collected file. Segments are one translation unit, so a shadow uses the unit’s Lisp environment rather than its own.

Source: src/compiler.x:397

Compiler.test

inline int Compiler.test(Compiler compiler, Symbol type)

Consumes type when current and reports whether it matched.

Source: src/compiler.x:821

Compiler.thaw_declaration_syntax

Var Compiler.thaw_declaration_syntax(Compiler c, Var syntax)

Restores a retained declaration recipe in the current parsing lifetime.

Source: src/compiler.x:1050

Compiler.tokenize

void Compiler.tokenize(Compiler c, char *text)

Scans source and positions the compiler at its first non-trivia token.

The compiler borrows text for diagnostics and macro source capture until translation finishes.

Source: src/compiler.x:686

Compiler.update_source_visibility

void Compiler.update_source_visibility(Compiler c, List directives)

Applies public and private pragma directives to source visibility state and records each object-like #define name, less those #undef drops, for the literal warning.

A negative visibility state disables pragma tracking for this token stream; macro names are recorded regardless.

Source: src/compiler.x:1617

Compiler.var

Var Compiler.var(Compiler compiler)

Boxes the compiler’s pointer; the caller keeps the compiler.

Source: src/compiler.x:176

Map

Map.merge_translation_dependency

void Map.merge_translation_dependency(Map m, String path, Var content_hash)

Merges one translation dependency, preserving an existing content hash.

Source: src/compiler.x:197

Sym

Sym.base_symbols

Map Sym.base_symbols(Sym sym)

Copies all base-scope symbols into a fresh map in source order.

Package collection uses this so it resolves against the prelude and the importing unit’s already-visible includes without mutating either.

Source: src/compiler.x:2408

Sym.bind_identity

List Sym.bind_identity(Sym s, List context, List binding, List ast)

Installs an existing binding with ast’s qualifier-preserving type.

Source: src/compiler.x:2916

Sym.binding_is_local

int Sym.binding_is_local(Sym sym, List binding)

Reports whether binding belongs to a scope inside the base scopes.

Source: src/compiler.x:2673

Sym.binding_is_local_before

int Sym.binding_is_local_before(Sym sym, List binding, int scope_count)

Reports whether binding belongs to a local scope below scope_count.

Counts beyond the current scope depth are clamped to that depth.

Source: src/compiler.x:2680

Sym.current_binding

List Sym.current_binding(Sym sym, List key)

Returns key’s binding in the current scope, or NULL.

Source: src/compiler.x:2433

Sym.current_symbols

Map Sym.current_symbols(Sym sym)

Returns the current scope’s mutable symbol map, or NULL.

Source: src/compiler.x:2427

Sym.declare

List Sym.declare(Sym sym, List context, List key, List ast)

Analyzes a complete declaration type and installs its stored declared type.

Returns the declared binding. At file scope this also records static visibility; local declarations record automatic-storage and declared-type facts. Stored types discard storage and inline while retaining const, restrict, and volatile.

Source: src/compiler.x:2859

Sym.declare_delegate_field

void Sym.declare_delegate_field(Sym sym, Type aggregate, String name)

Marks one named aggregate field as a delegate.

Source: src/compiler.x:3475

Sym.declare_enumerator

void Sym.declare_enumerator(Sym sym, List key, Symbol owner)

Associates an enumerator key with its owner in the active scope.

Source: src/compiler.x:2449

Sym.declare_field_order

void Sym.declare_field_order(Sym sym, Type type, List fields)

Records declaration AST fields in source order after binding finishes.

Field types already use member keys. Unnamed rows retain their type and an empty name so initializer traversal preserves anonymous subobjects.

Source: src/compiler.x:3454

Sym.define

List Sym.define(Sym sym, List key, List type)

Defines key and returns its stable binding in the active scope.

Source: src/compiler.x:2569

Sym.define_global

List Sym.define_global(Sym sym, List key, List type)

Defines key in the unit’s writable base scope and returns its binding.

The definition survives the expression scope that first resolved it.

Source: src/compiler.x:2580

Sym.define_macro

void Sym.define_macro(Sym sym, Atom name, List definition)

Defines or replaces a macro in the active lexical scope.

Captured bindings are recorded for later shadow handling. Replacing a name already defined in this scope does not increase the local macro count.

Source: src/compiler.x:2460

Sym.delegate_aggregate

Type Sym.delegate_aggregate(Sym sym, Type type)

Resolves typedefs or one pointer layer to an aggregate tag, or NULL.

Source: src/compiler.x:3480

Sym.enumerator_owner

Symbol Sym.enumerator_owner(Sym sym, List key)

Returns the current scope’s enum owner for key, or zero.

Source: src/compiler.x:2441

Sym.field_order

List Sym.field_order(Sym sym, Type type)

Returns recorded fields in source order, or NULL.

Source: src/compiler.x:3472

Sym.file_statics

Map Sym.file_statics(Sym sym)

Returns the current borrowed set of file-static declaration keys.

A semantic transaction may replace this map, so reacquire it afterwards.

Source: src/compiler.x:2419

Sym.get

List Sym.get(Sym sym, List key)

Returns key’s type, retrying a bare key in package space, or NULL.

Source: src/compiler.x:2611

Sym.get_exact

List Sym.get_exact(Sym sym, List key)

Returns key’s type without package fallback, or NULL.

Source: src/compiler.x:2588

Sym.global_symbols

Map Sym.global_symbols(Sym sym)

Returns the mutable global symbol map supplied to the latest reset.

Source: src/compiler.x:2401

Sym.has_local_macros

int Sym.has_local_macros(Sym sym)

Returns whether any lexical scope contains a local macro definition.

Source: src/compiler.x:2472

Sym.introduce

List Sym.introduce(Sym sym, String spelling)

Allocates a fresh binding identity for a compiler-introduced spelling.

Source: src/compiler.x:2689

Sym.is_array_type

int Sym.is_array_type(Sym sym, Type type)

Reports whether type reaches the named Array value type.

Source: src/compiler.x:3414

Sym.is_map_type

int Sym.is_map_type(Sym s, Type type)

Reports whether type reaches the named Map value type.

Source: src/compiler.x:3418

Sym.is_named_value_type

int Sym.is_named_value_type(Sym sym, Type type, String name)

Reports whether type reaches a named value type before its definition.

Source: src/compiler.x:3421

Sym.is_string_type

int Sym.is_string_type(Sym sym, Type type)

Reports whether type reaches the named String value type.

Source: src/compiler.x:3410

Sym.is_var_type

int Sym.is_var_type(Sym s, Type type)

Reports whether type reaches the named Var value type.

Source: src/compiler.x:3407

Sym.local_type

Type Sym.local_type(Sym sym, Type type)

Resolves a block-local typedef to the type saved at its declaration. File-scope names retain their semantic identity. Local alias definitions are resolved before they are installed, so one lookup crosses the whole local chain without consulting names shadowed since its declaration.

Source: src/compiler.x:3297

Sym.lookup

List Sym.lookup(Sym sym, List key, List *type)

Resolves an existing key and optionally stores its semantic type.

A symbol row without a binding receives a stable binding identity. A total miss returns NULL and stores NULL through type when provided.

Source: src/compiler.x:2646

Sym.lookup_field

Type Sym.lookup_field(Sym sym, Type type, List field)

Returns an aggregate field’s declared type, or NULL. A member of an anonymous struct or union belongs to its enclosing aggregate in C, so unnamed rows are searched the way a designated initializer already reaches them.

Source: src/compiler.x:3434

Sym.lookup_macro

List Sym.lookup_macro(Sym sym, Atom name)

Returns the innermost visible local macro named name, or NULL.

Source: src/compiler.x:2478

Sym.mark_static

void Sym.mark_static(Sym sym, List key)

Marks a declaration key as file-static.

Source: src/compiler.x:2422

Sym.next_typedef

Type Sym.next_typedef(Sym sym, Type type, int *hops)

Resolves one typedef hop and counts against the shared cycle budget.

hops is an in-out counter initialized by the caller for the whole walk. Returns NULL for an unresolved link. The shared budget turns a cycle into the same diagnostic as full-chain resolution.

Source: src/compiler.x:3229

Sym.normalize_declared_type

Type Sym.normalize_declared_type(Sym sym, Type type)

Resolves typedef bases while retaining every declarator qualifier.

Source: src/compiler.x:3366

Sym.pop_scope

SymScope Sym.pop_scope(Sym s)

Pops the innermost scope, or returns an empty scope when none exists.

Source: src/compiler.x:3524

Sym.push_new_scope

void Sym.push_new_scope(Sym sym)

Pushes a new empty lexical scope.

Source: src/compiler.x:3509

Sym.push_scope

void Sym.push_scope(Sym sym, SymScope scope)

Pushes a caller-supplied lexical scope while retaining its map objects.

Source: src/compiler.x:3519

Sym.reference

List Sym.reference(Sym sym, List key, List *type)

Resolves key or creates a forward binding in the current scope.

Stores NULL through type when no declaration supplies a type.

Source: src/compiler.x:2653

Sym.reference_global

List Sym.reference_global(Sym sym, List key)

Resolves a global name or creates its forward binding in the base scope. Local declarations cannot capture a retained macro’s global reference.

Source: src/compiler.x:2666

Sym.reset

void Sym.reset(Sym sym, Map globals)

Resets symbol state to one base scope backed by globals.

Later definitions mutate that caller-supplied map.

Source: src/compiler.x:2392

Sym.resolve_global

List Sym.resolve_global(Sym sym, List key, List *type)

Resolves a binding through base scopes and optionally stores its type.

Returns NULL when no base scope contains the key.

Source: src/compiler.x:2660

Sym.resolve_key

Type Sym.resolve_key(Sym sym, Type key)

Resolves a canonical typedef key to the end of its declared chain.

Source: src/compiler.x:3217

Sym.resolve_numeric_type

Type Sym.resolve_numeric_type(Sym sym, Type type)

Resolves a numeric typedef without reducing semantic object types.

Returns NULL when resolution yields neither a numeric type nor a recognized builtin numeric typedef.

Source: src/compiler.x:3278

Sym.scope_count

int Sym.scope_count(Sym sym)

Returns the number of semantic scopes, including base scopes.

Source: src/compiler.x:2475

Sym.seed_var_tags

void Sym.seed_var_tags(Sym sym, Map symbols)

Registers declared T_var converters in the active Type unit.

Source: src/compiler.x:2562

Sym.set

void Sym.set(Sym s, List key, List type)

Sets a semantic type for key in the required active scope.

Source: src/compiler.x:2494

Sym.var_tag_for_type

Symbol Sym.var_tag_for_type(Sym sym, Type type, Type *resolved)

Returns a type’s Var tag and optionally stores its resolved type.

resolved receives the final type even when the result is zero because no Var tag is registered. A null input stores NULL and returns zero.

Source: src/compiler.x:3397

SymTxn

SymTxn.commit

void SymTxn.commit(SymTxn s)

Publishes an active semantic transaction and makes rollback a no-op.

Source: src/compiler.x:2314

SymTxn.local_macros_changed

int SymTxn.local_macros_changed(SymTxn s)

Returns whether the transaction’s active scope changed its macro map.

Source: src/compiler.x:2334

SymTxn.rollback

void SymTxn.rollback(SymTxn transaction)

Restores every semantic value captured by an active transaction.

Source: src/compiler.x:2343

Symbol

Symbol.group_step

int Symbol.group_step(Symbol s)

Returns 1 for a token type that opens a delimited group, -1 for one that closes a group, and 0 otherwise. Every opener spelling ends in the (, [, or { that its closer matches.

Source: src/compiler.x:733

Token

Token.after_group

Token Token.after_group(Token t)

Returns the first non-trivia token after the group t opens, or after t when it opens no group. A group that never closes yields eof.

Source: src/compiler.x:756

Token.group_close

Token Token.group_close(Token t)

Returns the token that closes the group t opens, t itself when it opens no group, or the eof token when the group never closes.

Source: src/compiler.x:747

Var

Var.compiler

Compiler Var.compiler(Var value)

Recovers the compiler pointer boxed by Compiler.var.

Source: src/compiler.x:179

Public types

TypeKindSummary
CompilerstructHolds mutable state for one source translation.
DiagnosticsstructNames the positioned diagnostic store routed by a Compiler.
GenNamesstructHolds scope-owned generated-name state shared by related compilers.
ScriptUnitstructDescribes the #! script unit a translation unit was started from: its canonical path, its first line as written, and whether it defines main itself.
SymstructNames the scope-owned semantic table belonging to one compiler.
SymScopestructHolds the three mutable maps that form one lexical semantic scope.
SymTxnstructNames a scope-owned, one-use semantic transaction.

Compiler

typedef struct Compiler { String filename, text, root_dir; String package, List package_dirs; Map package_roots, package_aliases, package_members; Token token; Tokenizer tokenizer; List return_type, include_dirs; Map deps; List aggregate_type, macro_stack, declaration_effects, Sym sym; SymScope params; Map key_ids, macros, kw_aliases; Map object_macros; List arms; Map arm_stacks; Token directives_taken; Map kw_seen; Map fixed; Map protocols, conforms, protocol_helpers; Map proto_cache; Map adoptions; Map macro_holes; int source_syntax; Map local_macro_captures; List lambda_scopes; Array match_types; Map imports; Map init_tokens, static_init_deps, fn_defs; Array id_keys, inits; String init_fn, fini_fn; Array early_decls, int prelude; Array meta_defs; Map meta_folds, meta_impure, meta_comptime; int runtime_inc, runtime_hdrs, collect_protocols, shallow, source_private; int meta_body; int import_protocols; int in_pattern, match_is, runtime_literals, inline_header; int builtin_defs, in_proto, macro_count, recovery_depth; int declaration_projection, declaration_produced; int needs_exception; int local_macro_capture_scopes; String fn_name, Diagnostics diagnostics, Array braces, import_stack; ScriptUnit unit_script, script; Lisp macro_lisp, String import_src, int borrowed_lisp; int inherited_lisp; GenNames names; Array origins, int origin, source_map; SourceView sources; int source_facts, source_primary; Array source_occurrences; Map source_definitions, source_declarations, source_texts; } *Compiler

Holds mutable state for one source translation.

The structure, its state, and its owned compile-time Lisp session belong to the current Scope. Compiler.free_lisp permits early session cleanup; otherwise Scope teardown releases it. All Lisp calls must return first.

Source: src/compiler.x:70

Diagnostics

typedef struct Diagnostics *Diagnostics

Names the positioned diagnostic store routed by a Compiler.

Source: src/compiler.x:22

GenNames

typedef struct GenNames { Map counters, adapters; int next_binding; } *GenNames

Holds scope-owned generated-name state shared by related compilers.

Compiler.new initializes every valid instance; callers borrow it from the compiler rather than constructing or freeing it. next_binding is the last binding identity issued in the translation unit: collection, shadow, package, and full-parse compilers all draw from it, so a binding number names one live declaration across every symbol table in the unit. Rows replayed from an interface keep that interface’s own numbering, which starts at 1, so their numbers identify declarations only within their own rows.

Source: src/compiler.x:45

ScriptUnit

typedef struct ScriptUnit { String path, shebang; int defines_main; } *ScriptUnit

Describes the #! script unit a translation unit was started from: its canonical path, its first line as written, and whether it defines main itself. Every compiler of that unit shares one record, so collection sees the same script settings the full parse does.

Source: src/compiler.x:29

Sym

typedef struct Sym *Sym

Names the scope-owned semantic table belonging to one compiler.

Source: src/compiler.x:60

SymScope

typedef struct SymScope { Map symbols, bindings, enumerators, macros; } SymScope

Holds the three mutable maps that form one lexical semantic scope.

Active scopes have initialized maps. The zero value is only the sentinel returned when an empty scope stack is popped.

Source: src/compiler.x:55

SymTxn

typedef struct SymTxn *SymTxn

Names a scope-owned, one-use semantic transaction.

Source: src/compiler.x:62

Design notes

Coordinates tokenization, shallow declaration discovery, full parsing, symbol scopes, diagnostics, and generated initialization. Shallow parsing skips function bodies; full parsing produces the AST of the source.

Symbol lookup walks the scope stack from inner to outer. Diagnostics may exit immediately or raise <malformed> while a recovery boundary is active.