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

One x2c unit’s translation state and its two parses.

Functions

FunctionSummary
Compiler.absolute_home_pathReturns the absolute path that a Compiler.portable_path spelling names.
Compiler.add_earlyAppends a declaration the kernel generated to the unit’s pending support.
Compiler.add_initAppends the lowered statement stmt to the file initialization area phase.
Compiler.add_supportAppends the declaration decl to the unit’s pending support as it is: a definition offered to every function rule, or a written one.
Compiler.add_translation_dependencyRecords a path dependency not embedded in generated C.
Compiler.anchor_originWraps a parsed node in the source location of its opening token.
Compiler.at_completionReports whether the parser is at the private REPL completion marker.
Compiler.at_wordReports whether the current token is the identifier word.
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.cache_literal_varInterns an immutable value and returns its (cache id) reference.
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.collect_compile_time_definitionCollects macro definitions or keyword aliases before the full source parse.
Compiler.collect_unit_macroExpands the file-scope unit macro at the cursor for collection and reports whether it did.
Compiler.copy_source_declarationCarries declaration metadata with one actual symbol contribution.
Compiler.define_pattern_bindersDeclares pattern locals and returns their capture-token/binding pairs.
Compiler.emitted_binding_nameReturns a binding’s selected emitted spelling.
Compiler.expectRequires and consumes the current token type.
Compiler.finish_collected_declarationRecords declaration visibility and meta facts, then skips its body.
Compiler.free_lispDestroys a compiler’s owned Lisp session, if any.
Compiler.freeze_declaration_syntaxRetains exported syntax across translation units 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.mark_completionRetags the token beginning at position as a private completion marker.
Compiler.mark_reference_presentRecords a nonnull optional parameter for the current lexical path.
Compiler.match_capture_valueReturns the typed expression reading one native match capture slot.
Compiler.match_pattern_bindersReturns definite binders from a typed Match pattern AST.
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.match_value_is_staticReports whether a recovered pattern value graph is fully static.
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.optional_reference_testReturns the optional-reference parameter tested by condition, or NULL.
Compiler.own_diagnosticsRoutes this compiler’s diagnostic store through its own printer.
Compiler.owns_package_sourceReports whether an x2c source belongs to the current package root.
Compiler.pattern_binder_declarationsBuilds ordinary declarations from a pattern scope’s issued bindings.
Compiler.peekReturns the non-trivia token type steps from parser position.
Compiler.portable_pathReturns path relative to the canonical x2c home when it lies below the home, otherwise path.
Compiler.present_referencesReturns the optional references proven present in this lexical path.
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_inline_functionRecords the header linkage of a public inline definition.
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.replay_declaration_sourceBinds a retained declaration production at the cursor, then advances past its source.
Compiler.require_inputRaises <incomplete> when a required grammar item reaches the supplied input boundary.
Compiler.restore_reference_presenceRestores the optional-reference facts saved before a lexical path.
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.settle_referenceMarks the optional reference binding present after an if when the arm that runs without it cannot fall through: no when the true arm proves presence, yes otherwise.
Compiler.shallow_parseCollects file-scope declarations into globals without parsing bodies.
Compiler.shallow_parse_overlayCollects declarations with reads over base then overlay.
Compiler.share_meta_groupShares owner’s pending meta group and the definitions it reads, which belong with the Lisp session that holds the group’s stubs.
Compiler.skip_collected_script_statementSkips a collected script statement, or diagnoses one beside main.
Compiler.skip_script_statementMoves past one run of a script unit’s statement tokens, through a ; or a closing } outside every bracket.
Compiler.start_collectionStarts a collection pass with the built-in macros.
Compiler.take_unit_stateTakes over owner’s macro, object-like #define, include, keyword, literal cache, and Lisp state for one segment of a collected file.
Compiler.take_wordConsumes the identifier word when current and reports whether it matched.
Compiler.testConsumes type when current and reports whether it matched.
Compiler.thaw_declaration_syntaxRestores exported syntax in the importing unit’s parsing lifetime.
Compiler.tokenizeScans source and positions the compiler at its first non-trivia token.
Compiler.varBoxes the compiler’s pointer; the caller keeps the compiler.
Map.merge_translation_dependencyMerges one translation dependency, preserving an existing content hash.
Path.realReturns the real path of the existing file at path, or NULL when path is NULL or does not resolve.
Path.resolved_absoluteReturns Path.absolute(path), resolving an existing file through Path.real.
Pending.areaReturns the storage of the destination area.
Pending.checkpointReturns the mark that restore returns every destination to.
Pending.initializesWhether any file initialization area holds a statement.
Pending.resetGives every destination fresh, empty storage.
Pending.restoreDrops the code queued since mark.
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.
Token.skip_triviaReturns the first token at or after token that is not a space, comment, or preprocessor line.
Var.compilerRecovers the compiler pointer boxed by Compiler.var.

Compiler

Compiler.absolute_home_path

String Compiler.absolute_home_path(String spelling)

Returns the absolute path that a Compiler.portable_path spelling names.

Source: src/compiler/source-files.x:87

Compiler.add_early

void Compiler.add_early(Compiler c, List decl)

Appends a declaration the kernel generated to the unit’s pending support. It is implementation, so its definitions are written.

Source: src/compiler/pending.x:5

Compiler.add_init

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

Appends the lowered statement stmt to the file initialization area phase. Bound code that still needs lowering, such as a String literal, would reach C as is.

Source: src/compiler/pending.x:18

Compiler.add_support

void Compiler.add_support(Compiler c, List decl)

Appends the declaration decl to the unit’s pending support as it is: a definition offered to every function rule, or a written one.

Source: src/compiler/pending.x:11

Compiler.add_translation_dependency

void Compiler.add_translation_dependency(Compiler c, String path)

Records a path dependency not embedded in generated C.

Source: src/compiler/source-files.x:99

Compiler.anchor_origin

List Compiler.anchor_origin(Compiler c, 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/source-locations.x:29

Compiler.at_completion

int Compiler.at_completion(Compiler c)

Reports whether the parser is at the private REPL completion marker.

Source: src/compiler/parsing/tokens.x:257

Compiler.at_word

int Compiler.at_word(Compiler c, String word)

Reports whether the current token is the identifier word. A contextual keyword such as with or as is an ordinary identifier elsewhere. This query does not consume tokens.

Source: src/compiler/parsing/tokens.x:194

Compiler.cache

List Compiler.cache(Compiler c, List key)

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

Source: src/compiler/literal-cache.x:4

Compiler.cache_cons_cell

List Compiler.cache_cons_cell(Compiler c, 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/literal-cache.x:28

Compiler.cache_literal_list

List Compiler.cache_literal_list(Compiler c, List values)

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

values may contain nested Lists, Strings, integer Vars, and Symbols.

Source: src/compiler/literal-cache.x:90

Compiler.cache_literal_var

List Compiler.cache_literal_var(Compiler c, Var value)

Interns an immutable value and returns its (cache id) reference. value is a List of such values, a String, a number with its tag, or a Symbol; any other value returns NULL.

Source: src/compiler/literal-cache.x:45

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/source-files.x:17

Compiler.close_child

void Compiler.close_child(Compiler c, Compiler child)

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

Source: src/compiler/lifecycle.x:25

Compiler.collect_compile_time_definition

void Compiler.collect_compile_time_definition(Compiler c, int keyword)

Collects macro definitions or keyword aliases before the full source parse. The owning source reports malformed definitions during its full parse, which can recover at later forms. Included providers reject them here.

Source: src/compiler/parsing/collection.x:77

Compiler.collect_unit_macro

int Compiler.collect_unit_macro(Compiler c)

Expands the file-scope unit macro at the cursor for collection and reports whether it did. A required expansion reports its errors. A tried expansion that fails keeps nothing and leaves the cursor at the invocation, so collection skips it and the full parse reports it.

Source: src/compiler/declarations/production.x:66

Compiler.copy_source_declaration

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

Carries declaration metadata with one actual symbol contribution.

Source: src/compiler/source-locations.x:82

Compiler.define_pattern_binders

List Compiler.define_pattern_binders(Compiler c, List pattern)

Declares pattern locals and returns their capture-token/binding pairs.

Source: src/compiler/patterns.x:89

Compiler.emitted_binding_name

String Compiler.emitted_binding_name(Compiler c, List binding)

Returns a binding’s selected emitted spelling.

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

Source: src/compiler/binding-facts.x:10

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/parsing/tokens.x:149

Compiler.finish_collected_declaration

void Compiler.finish_collected_declaration( Compiler c, List declaration, Token meta, int native)

Records declaration visibility and meta facts, then skips its body. The declaration is already bound by the shared top-level parser.

Source: src/compiler/parsing/collection.x:99

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/lifecycle.x:138

Compiler.freeze_declaration_syntax

Var Compiler.freeze_declaration_syntax(Compiler c, Var syntax)

Retains exported syntax across translation units 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/declarations/portable-syntax.x:11

Compiler.fresh_name

String Compiler.fresh_name(Compiler c, String stem)

Allocates the next compiler-private C spelling for stem. Related compilers increment the same per-stem counter.

Source: src/compiler/names.x:6

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 macro state and protocol resolution; origins live for the whole unit. generated_symbols publishes external adapter signatures before parsing.

Source: src/compiler/parsing/parse.x:12

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/names.x:21

Compiler.mark_completion

void Compiler.mark_completion(Compiler c, int position)

Retags the token beginning at position as a private completion marker.

Source: src/compiler/parsing/tokens.x:246

Compiler.mark_reference_present

void Compiler.mark_reference_present(Compiler c, List binding)

Records a nonnull optional parameter for the current lexical path.

Source: src/compiler/binding-facts.x:22

Compiler.match_capture_value

List Compiler.match_capture_value(Var binder, int index)

Returns the typed expression reading one native match capture slot.

Source: src/compiler/patterns.x:108

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/patterns.x:78

Compiler.match_pattern_is_static

int Compiler.match_pattern_is_static(Compiler c, List pattern)

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

Source: src/compiler/patterns.x:66

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/patterns.x:8

Compiler.match_value_is_static

int Compiler.match_value_is_static(Var value)

Reports whether a recovered pattern value graph is fully static.

Source: src/compiler/patterns.x:57

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/source-locations.x:93

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/source-files.x:104

Compiler.new

Compiler Compiler.new(void)

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

Source: src/compiler/lifecycle.x:63

Compiler.new_shared

Compiler Compiler.new_shared(Compiler owner)

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

Source: src/compiler/lifecycle.x:66

Compiler.next

void Compiler.next(Compiler c)

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/parsing/tokens.x:163

Compiler.optional_reference_test

List Compiler.optional_reference_test( Compiler c, List condition, int &truth)

Returns the optional-reference parameter tested by condition, or NULL. truth is set to whether the condition’s true arm proves that the caller supplied an object. Only a direct truth or null test proves presence.

Source: src/compiler/binding-facts.x:48

Compiler.own_diagnostics

void Compiler.own_diagnostics(Compiler c)

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/lifecycle.x:20

Compiler.owns_package_source

int Compiler.owns_package_source(Compiler c, String path)

Reports whether an x2c source belongs to the current package root. Native headers and source outside that root keep their own names.

Source: src/compiler/source-files.x:26

Compiler.pattern_binder_declarations

List Compiler.pattern_binder_declarations( Compiler c, List bindings, List handle)

Builds ordinary declarations from a pattern scope’s issued bindings. A catch reads through its handler; a match reads its capture slots.

Source: src/compiler/patterns.x:115

Compiler.peek

Symbol Compiler.peek(Compiler c, 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/parsing/tokens.x:92

Compiler.portable_path

String Compiler.portable_path(String path)

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

Source: src/compiler/source-files.x:81

Compiler.present_references

List Compiler.present_references(Compiler c)

Returns the optional references proven present in this lexical path.

Source: src/compiler/binding-facts.x:18

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. A null after replays an included effect without an owning source span.

Source: src/compiler/declarations/production.x:11

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/source-files.x:6

Compiler.record_inline_function

void Compiler.record_inline_function(Compiler c, List declaration)

Records the header linkage of a public inline definition. Semantic function types discard storage, so this declaration fact survives there.

Source: src/compiler/parsing/collection.x:140

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 c.token has reached end of file.

Source: src/compiler/source-locations.x:13

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/source-locations.x:38

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/source-locations.x:73

Compiler.replay_declaration_source

List Compiler.replay_declaration_source(Compiler c)

Binds a retained declaration production at the cursor, then advances past its source. Returns NULL when collection retained no production.

Source: src/compiler/declarations/production.x:127

Compiler.require_input

void Compiler.require_input(Compiler c)

Raises <incomplete> when a required grammar item reaches the supplied input boundary. The caller sets a token in the current token stream after tokenizing; tokenization clears it. Semantic failures do not call this.

Source: src/compiler/parsing/tokens.x:140

Compiler.restore_reference_presence

void Compiler.restore_reference_presence(Compiler c, List before)

Restores the optional-reference facts saved before a lexical path.

Source: src/compiler/binding-facts.x:38

Compiler.return_unit_state

void Compiler.return_unit_state(Compiler c, 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/lifecycle.x:54

Compiler.run_declaration_effects

void Compiler.run_declaration_effects(Compiler c)

Runs pending effects for declaration production or CPP macro evaluation.

Source: src/compiler/declarations/production.x:27

Compiler.select_declaration_defaults

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

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/declarations/defaults.x:23

Compiler.settle_reference

void Compiler.settle_reference( Compiler c, List binding, int true_is_present, List yes, List no)

Marks the optional reference binding present after an if when the arm that runs without it cannot fall through: no when the true arm proves presence, yes otherwise. A missing no arm falls through.

Source: src/compiler/binding-facts.x:31

Compiler.shallow_parse

void Compiler.shallow_parse(Compiler c, Map globals)

Collects file-scope declarations into globals without parsing bodies.

Source: src/compiler/parsing/collection.x:4

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/parsing/collection.x:18

Compiler.share_meta_group

void Compiler.share_meta_group(Compiler c, Compiler owner)

Shares owner’s pending meta group and the definitions it reads, which belong with the Lisp session that holds the group’s stubs.

Source: src/compiler/lifecycle.x:34

Compiler.skip_collected_script_statement

int Compiler.skip_collected_script_statement(Compiler c)

Skips a collected script statement, or diagnoses one beside main. Called after top-level directives establish source visibility.

Source: src/compiler/parsing/scripts.x:83

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/parsing/scripts.x:97

Compiler.start_collection

void Compiler.start_collection(Compiler c)

Starts a collection pass with the built-in macros. It parses no bodies, and an import it reads installs the protocols visible to it when a template or meta body first asks for one.

Source: src/compiler/parsing/collection.x:58

Compiler.take_unit_state

void Compiler.take_unit_state(Compiler c, Compiler owner)

Takes over owner’s macro, object-like #define, include, keyword, literal cache, and Lisp state for one segment of a collected file. Segments are one translation unit, so retained macro bodies index the unit’s literal cache and use its Lisp environment.

Source: src/compiler/lifecycle.x:43

Compiler.take_word

int Compiler.take_word(Compiler c, String word)

Consumes the identifier word when current and reports whether it matched.

Source: src/compiler/parsing/tokens.x:199

Compiler.test

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

Consumes type when current and reports whether it matched.

Source: src/compiler/parsing/tokens.x:185

Compiler.thaw_declaration_syntax

Var Compiler.thaw_declaration_syntax(Compiler c, Var syntax)

Restores exported syntax in the importing unit’s parsing lifetime.

Source: src/compiler/declarations/portable-syntax.x:66

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/parsing/tokens.x:8

Compiler.var

Var Compiler.var(Compiler c)

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

Source: src/compiler/lifecycle.x:5

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/source-files.x:91

Path

Path.real

String Path.real(String path)

Returns the real path of the existing file at path, or NULL when path is NULL or does not resolve. Each spelling is resolved once per process.

Source: src/compiler/source-files.x:43

Path.resolved_absolute

String Path.resolved_absolute(String path)

Returns Path.absolute(path), resolving an existing file through Path.real.

Source: src/compiler/source-files.x:56

Pending

Pending.area

Array Pending.area(Pending &p, Symbol area)

Returns the storage of the destination area.

Source: src/compiler/pending.x:28

Pending.checkpoint

PendingMark Pending.checkpoint(Pending &p)

Returns the mark that restore returns every destination to.

Source: src/compiler/pending.x:38

Pending.initializes

int Pending.initializes(Pending &p)

Whether any file initialization area holds a statement.

Source: src/compiler/pending.x:32

Pending.reset

void Pending.reset(Pending &p)

Gives every destination fresh, empty storage.

Source: src/compiler/pending.x:23

Pending.restore

void Pending.restore(Pending &p, PendingMark mark)

Drops the code queued since mark.

Source: src/compiler/pending.x:46

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/parsing/tokens.x:214

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/parsing/tokens.x:238

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/parsing/tokens.x:229

Token.skip_trivia

Token Token.skip_trivia(Token token)

Returns the first token at or after token that is not a space, comment, or preprocessor line. The stream must end in eof.

Source: src/compiler/parsing/tokens.x:112

Var

Var.compiler

Compiler Var.compiler(Var value)

Recovers the compiler pointer boxed by Compiler.var.

Source: src/compiler/lifecycle.x:8

Public types

TypeKindSummary
AncestorstructOne syntax the parser is inside, which x2c_enclosing answers: a function body with its declaration in node, and lowering set while the transform lowers it, a block item with the token or origin it starts at, or an initialized declarator with its declaration base in base and its (bind ...) node in node.
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.
ModuleSourcestructDescribes an x2c source whose module block names member files: text holds the file’s own text, own, with each member’s text in place of the block.
PendingstructHolds generated code awaiting insertion, by Pending.area destination: unit support declarations, which Compiler.transform lowers after the unit, then the lowered statements of each file initialization area.
PendingMarkstructHolds each destination’s length for Pending.restore.
ScriptUnitstructDescribes the #! script unit a translation unit was started from: its canonical path, its first line as written, and whether it defines main itself.
SlotWatchstructNames the slots a rewrite’s first lowering watches; see “prepared replacements” in macros.x.
SymstructNames the scope-owned semantic table belonging to one compiler.
SymScopestructHolds the three mutable maps that form one lexical semantic scope.
SymTxnstructHolds one reversible semantic transaction in caller storage.

Ancestor

typedef struct Ancestor { Symbol what; Token token; int origin, lowering, callback; List base, node; } Ancestor

One syntax the parser is inside, which x2c_enclosing answers: a function body with its declaration in node, and lowering set while the transform lowers it, a block item with the token or origin it starts at, or an initialized declarator with its declaration base in base and its (bind ...) node in node.

Source: src/compiler/compiler.x:99

Compiler

typedef struct Compiler { String filename, text, root_dir; String package, List package_dirs, package_source_dirs; Map package_roots, package_aliases, package_members, package_effects; Token token; Token input_boundary; Tokenizer tokenizer; Array line_markers; ModuleSource unit_source; List return_type, include_dirs; Map deps; List aggregate_type, macro_stack, declaration_effects, Sym sym; Map evaluated_effects; int expansion_floor; SymScope params; Map key_ids, macros, kw_aliases; List binding_rows, binding_sealed; Map object_macros; List arms; Map arm_stacks; Array layout_marks, packed_marks; Token directives_taken; Map protocols, conforms, protocol_helpers; Map proto_cache; Map adoptions; Map macro_holes; Map local_macro_captures; int macro_application; List lambda_scopes; Array match_types; Map imports; Map included_effects; Map init_tokens, static_init_deps, fn_defs; Array id_keys; String init_fn, fini_fn; Pending pending, int prelude; Map meta_comptime, meta_regions, meta_hashes, meta_calls; struct MetaHelper *meta_helper; Map native_meta; Map project_meta; Array unit_nodes, meta_group; Map meta_group_bound; int meta_build; int load_source; int runtime_inc, runtime_hdrs, collect_protocols, shallow, source_private; int module_declaration; int replaying_declaration; int public_bodies; int interface_provider, signature_only; int collection_native; Map collection_native_files; Array pending_inline_bodies; int layout; int meta_body; int capture_unit; List active_rewrites; List applying; Map rewrite_rules; Map prepared_rewrites; SlotWatch slot_watch; Token meta_statement; int import_protocols; int in_pattern, match_is, runtime_literals, inline_header; int permanent_literals; int builtin_defs, in_proto, macro_count, recovery_depth; int declaration_produced; int needs_exception; int local_macro_capture_scopes; int open_linkage; String fn_name, Diagnostics diagnostics, Array braces, import_stack; Block ancestors; Array placements; String lines_text, Array line_starts; ScriptUnit unit_script, script; Lisp macro_lisp, 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/compiler.x:113

Diagnostics

typedef struct Diagnostics *Diagnostics

Names the positioned diagnostic store routed by a Compiler.

Source: src/compiler/compiler.x:26

GenNames

typedef struct GenNames { Map counters, adapters, file_scope_owners; int next_binding, issued; } *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. Exported rows use their interface’s own numbering, which starts at 1; imported templates rebind those references in the consuming unit.

Source: src/compiler/compiler.x:62

ModuleSource

typedef struct ModuleSource { String text, own; Array markers; Map members; } *ModuleSource

Describes an x2c source whose module block names member files: text holds the file’s own text, own, with each member’s text in place of the block. markers are the line-marker rows that give each region of text its file, line, and byte offset there, with the text that precedes that offset on its line and the prefix that file’s statics take. The first row marks the start of text. members maps each member’s canonical path to its content hash.

Source: src/compiler/compiler.x:46

Pending

typedef struct Pending { Array areas[PENDING_AREAS]; } Pending

Holds generated code awaiting insertion, by Pending.area destination: unit support declarations, which Compiler.transform lowers after the unit, then the lowered statements of each file initialization area.

Source: src/compiler/compiler.x:82

PendingMark

typedef struct PendingMark { int lengths[PENDING_AREAS]; } PendingMark

Holds each destination’s length for Pending.restore.

Source: src/compiler/compiler.x:85

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

SlotWatch

typedef struct SlotWatch *SlotWatch

Names the slots a rewrite’s first lowering watches; see “prepared replacements” in macros.x.

Source: src/compiler/compiler.x:92

Sym

typedef struct Sym *Sym

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

Source: src/compiler/compiler.x:88

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

SymTxn

typedef struct SymTxn { Compiler c; int scope_index, next_binding, active, String initializer_name; String shutdown_name, Map counters; int local_macro_names, mark, meta_group_size, ancestors, placements; SymScope scope; Map statics, binding_facts; Map source_definitions; int source_occurrences; int extended, Map adapters; PendingMark pending, int origin_count, origin, needs_exception; } SymTxn

Holds one reversible semantic transaction in caller storage. The zero value is inactive. Keep an active transaction in one object; copying it does not coordinate completion. The symbol table’s undo log holds the rows it may restore from mark; the staged generated-name counters and other snapshots live in its initial Scope.

Source: src/compiler/compiler.x:292

Design notes

A Compiler owns the translation state of one unit: its token cursor, symbol table, and declaration state. Collection parses the unit shallowly, skipping function bodies; the full parse produces its AST. The related compilers of one unit share its package registries, generated names, and binding numbers. The symbol table is Sym, in symtab/symtab.x.

Diagnostics may exit immediately or raise <malformed> while a recovery boundary is active.