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

The compiler’s semantic symbol table.

Functions

FunctionSummary
Compiler.aggregate_nameBinds a local aggregate tag before its fields, preserving native spelling.
Compiler.begin_semantic_transactionBegins a reversible transaction over the current semantic scope.
Compiler.declared_spellingReturns name as scoped_spelling does for a declaration, recording a spelling that took prefix so the names the compiler derives from it are known to hold their prefix already.
Compiler.drop_factDeletes one semantic binding fact.
Compiler.factReturns the List one semantic binding fact holds, or NULL when it is absent.
Compiler.file_prefixesReturns the static prefix of each file of the module unit.
Compiler.imported_providersReturns sorted imported packages that publish name.
Compiler.imported_spellingReturns an unambiguous imported spelling for name, or NULL.
Compiler.macro_definition_localsReturns the active macro definition’s borrowed local map, or NULL.
Compiler.macro_template_localReports whether binding is a local of the active macro definition or of a template that encloses it; a nested definition’s literal names share the enclosing template’s names.
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.private_prefixReturns the prefix that a file-scope declaration of type takes in the current module file, or NULL.
Compiler.record_declaration_visibilityRecords the visibility of one parsed top-level declaration.
Compiler.register_package_aliasRegisters one local package alias.
Compiler.register_package_memberRegisters one package member under a bare local spelling.
Compiler.scoped_spellingReturns name spelled in a declaration’s scope: with prefix, a file prefix, or else in the current package.
Compiler.semantic_binding_factsReturns the borrowed semantic-facts map indexed by binding.
Compiler.set_factSets one semantic binding fact.
Compiler.unprefixedReturns the source name of a spelling this unit gave a file prefix, or name.
Sym.aggregate_ofResolves typedefs or one pointer layer to an aggregate tag, or NULL.
Sym.at_file_scopeReturns whether declarations currently bind at file scope.
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.close_local_scopesSets aside the local scopes now open, so declarations bind at file scope until Sym.reopen_scopes restores the returned scopes.
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_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.declare_resolvedInstalls an aggregate or named type whose parser resolved its spelling.
Sym.declared_keyReturns the key a declaration of key with type ast takes in this unit: its file-private or package spelling at file scope, else key.
Sym.defineDefines key and returns its stable binding in the active scope.
Sym.define_globalDefines key in the unit’s writable base scope.
Sym.define_macroDefines or replaces a macro in the active lexical scope.
Sym.dropDeletes key from map so that an active transaction can restore it.
Sym.end_logStops one transaction’s semantic write log.
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 borrowed set of file-static declaration keys.
Sym.getReturns key’s type, 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_localReports whether a scope inside the base scopes declares key.
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.introducedReturns how many introduced bindings no scope holds: those Sym.introduce made, as opposed to the ones each scope makes once for a name it resolves.
Sym.is_array_typeReports whether type reaches the named Array value type.
Sym.is_file_staticReports whether binding names a file-scope static of this unit.
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_fieldRecords that the field name of aggregate was declared with the field keyword mark, such as delegate, and that aggregate declares one.
Sym.mark_staticMarks a declaration key as file-static.
Sym.marked_fieldsReturns the (NAME TYPE) rows of the fields of aggregate declared with mark, in declaration order.
Sym.newCreates the empty symbol table that compiler c owns.
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.putSets map[key] so that an active semantic transaction can restore it.
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.reopen_scopesReopens the local scopes Sym.close_local_scopes set aside.
Sym.resetResets symbol state to one base scope backed by globals.
Sym.reset_overlayResets symbol state to read base below the writable scope overlay.
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.sole_typedefReturns the name of the one file-scope typedef declared directly as type, or NULL when no typedef or several typedefs are.
Sym.transactingReturns whether a semantic transaction is open.
Sym.unit_symbolsReturns a fresh map of the base symbols with the current scope’s rows merged in.
Sym.unshadow_visibleEmits every local object spelled spelling that the current scope sees, the enclosing ones too, under one fresh spelling, so a file-scope name a template keeps reaches the global there, and returns them.
Sym.var_tag_for_typeReturns a type’s Var tag and optionally stores its resolved type.
Sym.visible_symbolsReturns the visible one-part source names and their semantic types.
SymTxn.commitPublishes an active semantic transaction and makes rollback a no-op.
SymTxn.commit_transientCommits an active transaction, retaining the original counters map.
SymTxn.local_macros_changedReturns whether the transaction’s active scope changed its macro map.
SymTxn.rollbackRestores every semantic value captured by an active transaction.

Compiler

Compiler.aggregate_name

Var Compiler.aggregate_name( Compiler c, 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. A macro template names its tags as template locals.

Source: src/symtab/declarations.x:276

Compiler.begin_semantic_transaction

SymTxn Compiler.begin_semantic_transaction(Compiler c)

Begins a reversible transaction over the current semantic scope.

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

Source: src/symtab/transactions.x:39

Compiler.declared_spelling

String Compiler.declared_spelling(Compiler c, String prefix, String name)

Returns name as scoped_spelling does for a declaration, recording a spelling that took prefix so the names the compiler derives from it are known to hold their prefix already. A replayed collected declaration was spelled when it was collected, so its names are final and are recorded as they are.

Source: src/symtab/namespaces.x:112

Compiler.drop_fact

void Compiler.drop_fact(Compiler c, Var key)

Deletes one semantic binding fact.

Source: src/symtab/bindings.x:189

Compiler.fact

List Compiler.fact(Compiler c, Var key)

Returns the List one semantic binding fact holds, or NULL when it is absent.

Source: src/symtab/bindings.x:179

Compiler.file_prefixes

List Compiler.file_prefixes(Compiler c)

Returns the static prefix of each file of the module unit.

Source: src/symtab/namespaces.x:135

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/symtab/namespaces.x:233

Compiler.imported_spelling

String Compiler.imported_spelling(Compiler c, String name)

Returns an unambiguous imported spelling for name, or NULL.

Source: src/symtab/namespaces.x:245

Compiler.macro_definition_locals

Map Compiler.macro_definition_locals(Compiler c)

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

Source: src/symtab/scopes.x:189

Compiler.macro_template_local

int Compiler.macro_template_local(Compiler c, List binding)

Reports whether binding is a local of the active macro definition or of a template that encloses it; a nested definition’s literal names share the enclosing template’s names.

Source: src/symtab/scopes.x:197

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/symtab/namespaces.x:218

Compiler.package_spelling

String Compiler.package_spelling(Compiler c, String name)

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

Idempotence lets parsing and declaration rewrites share this operation.

Source: src/symtab/namespaces.x:155

Compiler.private_prefix

String Compiler.private_prefix(Compiler c, Type type)

Returns the prefix that a file-scope declaration of type takes in the current module file, or NULL. A static takes it, and so does each declaration of a static typedef or static class; a module declaration and every declaration outside a module unit do not.

Source: src/symtab/namespaces.x:86

Compiler.record_declaration_visibility

void Compiler.record_declaration_visibility(Compiler c, List declaration)

Records the visibility of one parsed top-level declaration. Lexical privacy and static storage mark bindings in Sym; typedef rows are retained for placing generated protocol declarations at the same boundary.

Source: src/symtab/namespaces.x:9

Compiler.register_package_alias

void Compiler.register_package_alias( Compiler c, 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/symtab/namespaces.x:167

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/symtab/namespaces.x:180

Compiler.scoped_spelling

String Compiler.scoped_spelling(Compiler c, String prefix, String name)

Returns name spelled in a declaration’s scope: with prefix, a file prefix, or else in the current package. A name the compiler derived from a spelling this unit already prefixed, such as second__Node_new or Var_second__node for a private class second__Node, stays unchanged; it is unique in the unit, so code generated outside the file still reaches it. Ordinary source spellings always take their file’s prefix, even when they resemble another generated spelling.

Source: src/symtab/namespaces.x:100

Compiler.semantic_binding_facts

Map Compiler.semantic_binding_facts(Compiler c)

Returns the borrowed semantic-facts map indexed by binding.

Write it through set_fact and drop_fact, which a semantic transaction can restore.

Source: src/symtab/bindings.x:175

Compiler.set_fact

void Compiler.set_fact(Compiler c, Var key, Var value)

Sets one semantic binding fact.

Source: src/symtab/bindings.x:185

Compiler.unprefixed

String Compiler.unprefixed(Compiler c, String name)

Returns the source name of a spelling this unit gave a file prefix, or name. Var tags and descriptor names use that short name.

Source: src/symtab/namespaces.x:146

Sym

Sym.aggregate_of

Type Sym.aggregate_of(Sym s, Type type)

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

Source: src/symtab/types.x:320

Sym.at_file_scope

int Sym.at_file_scope(Sym s)

Returns whether declarations currently bind at file scope.

Source: src/symtab/scopes.x:76

Sym.base_symbols

Map Sym.base_symbols(Sym s)

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/symtab/scopes.x:104

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/symtab/declarations.x:255

Sym.binding_is_local

int Sym.binding_is_local(Sym s, List binding)

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

Source: src/symtab/bindings.x:155

Sym.binding_is_local_before

int Sym.binding_is_local_before(Sym s, 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/symtab/bindings.x:162

Sym.close_local_scopes

Block Sym.close_local_scopes(Sym s)

Sets aside the local scopes now open, so declarations bind at file scope until Sym.reopen_scopes restores the returned scopes.

Source: src/symtab/scopes.x:80

Sym.current_binding

List Sym.current_binding(Sym s, List key)

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

Source: src/symtab/bindings.x:141

Sym.current_symbols

Map Sym.current_symbols(Sym s)

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

Source: src/symtab/scopes.x:111

Sym.declare

List Sym.declare(Sym s, 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/symtab/declarations.x:12

Sym.declare_enumerator

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

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

Source: src/symtab/bindings.x:77

Sym.declare_field_order

void Sym.declare_field_order(Sym s, 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/symtab/types.x:276

Sym.declare_resolved

List Sym.declare_resolved(Sym s, List context, List key, List ast)

Installs an aggregate or named type whose parser resolved its spelling.

Source: src/symtab/declarations.x:16

Sym.declared_key

List Sym.declared_key(Sym s, List context, List key, List ast)

Returns the key a declaration of key with type ast takes in this unit: its file-private or package spelling at file scope, else key. Retained declarations keep their already resolved spelling.

Source: src/symtab/declarations.x:45

Sym.define

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

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

Source: src/symtab/bindings.x:18

Sym.define_global

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

Defines key in the unit’s writable base scope.

The definition survives the expression scope that first resolved it. Its binding is issued at the first reference, as for a row an included file contributes, so the unit numbers its bindings the same whether it defined the row here or replayed it from an interface.

Source: src/symtab/bindings.x:70

Sym.define_macro

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

Defines or replaces a macro in the active lexical scope.

Replacing a name already defined in this scope does not increase the local macro count.

Source: src/symtab/scopes.x:167

Sym.drop

void Sym.drop(Sym s, Map map, Var key)

Deletes key from map so that an active transaction can restore it.

Source: src/symtab/transactions.x:12

Sym.end_log

void Sym.end_log(Sym s)

Stops one transaction’s semantic write log.

Source: src/symtab/transactions.x:124

Sym.enumerator_owner

Symbol Sym.enumerator_owner(Sym s, List key)

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

Source: src/symtab/bindings.x:148

Sym.field_order

List Sym.field_order(Sym s, Type type)

Returns recorded fields in source order, or NULL.

Source: src/symtab/types.x:298

Sym.file_statics

Map Sym.file_statics(Sym s)

Returns the borrowed set of file-static declaration keys.

Source: src/symtab/scopes.x:125

Sym.get

List Sym.get(Sym s, List key)

Returns key’s type, or NULL. A plain key tries the current module file’s static spelling first and retries a miss in package space.

Source: src/symtab/bindings.x:196

Sym.get_exact

List Sym.get_exact(Sym s, List key)

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

Source: src/symtab/bindings.x:204

Sym.global_symbols

Map Sym.global_symbols(Sym s)

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

Source: src/symtab/scopes.x:97

Sym.has_local

int Sym.has_local(Sym s, List key)

Reports whether a scope inside the base scopes declares key.

Source: src/symtab/bindings.x:207

Sym.has_local_macros

int Sym.has_local_macros(Sym s)

Returns whether any lexical scope contains a local macro definition.

Source: src/symtab/scopes.x:175

Sym.introduce

List Sym.introduce(Sym s, String spelling)

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

Source: src/symtab/bindings.x:138

Sym.introduced

int Sym.introduced(Sym s)

Returns how many introduced bindings no scope holds: those Sym.introduce made, as opposed to the ones each scope makes once for a name it resolves.

Source: src/symtab/bindings.x:130

Sym.is_array_type

int Sym.is_array_type(Sym s, Type type)

Reports whether type reaches the named Array value type.

Source: src/symtab/types.x:234

Sym.is_file_static

int Sym.is_file_static(Sym s, Var binding)

Reports whether binding names a file-scope static of this unit.

Source: src/symtab/declarations.x:101

Sym.is_map_type

int Sym.is_map_type(Sym s, Type type)

Reports whether type reaches the named Map value type.

Source: src/symtab/types.x:238

Sym.is_named_value_type

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

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

Source: src/symtab/types.x:241

Sym.is_string_type

int Sym.is_string_type(Sym s, Type type)

Reports whether type reaches the named String value type.

Source: src/symtab/types.x:230

Sym.is_var_type

int Sym.is_var_type(Sym s, Type type)

Reports whether type reaches the named Var value type.

Source: src/symtab/types.x:227

Sym.local_type

Type Sym.local_type(Sym s, 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/symtab/types.x:119

Sym.lookup

List Sym.lookup(Sym s, List key, Type &?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/symtab/bindings.x:254

Sym.lookup_field

Type Sym.lookup_field(Sym s, 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/symtab/types.x:256

Sym.lookup_macro

List Sym.lookup_macro(Sym s, Atom name)

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

Source: src/symtab/scopes.x:178

Sym.mark_field

void Sym.mark_field(Sym s, Type aggregate, Symbol mark, String name)

Records that the field name of aggregate was declared with the field keyword mark, such as delegate, and that aggregate declares one.

Source: src/symtab/types.x:302

Sym.mark_static

void Sym.mark_static(Sym s, List key)

Marks a declaration key as file-static.

Source: src/symtab/scopes.x:128

Sym.marked_fields

List Sym.marked_fields(Sym s, Type aggregate, Symbol mark)

Returns the (NAME TYPE) rows of the fields of aggregate declared with mark, in declaration order.

Source: src/symtab/types.x:309

Sym.new

Sym Sym.new(Compiler c)

Creates the empty symbol table that compiler c owns.

Source: src/symtab/scopes.x:4

Sym.next_typedef

Type Sym.next_typedef(Sym s, 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/symtab/types.x:67

Sym.normalize_declared_type

Type Sym.normalize_declared_type(Sym s, Type type)

Resolves typedef bases while retaining every declarator qualifier.

Source: src/symtab/types.x:88

Sym.pop_scope

SymScope Sym.pop_scope(Sym s)

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

Source: src/symtab/scopes.x:65

Sym.push_new_scope

void Sym.push_new_scope(Sym s)

Pushes a new empty lexical scope.

Source: src/symtab/scopes.x:59

Sym.push_scope

void Sym.push_scope(Sym s, SymScope scope)

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

Source: src/symtab/scopes.x:62

Sym.put

void Sym.put(Sym s, Map map, Var key, Var value)

Sets map[key] so that an active semantic transaction can restore it. Semantic writes to scope, file-static, and binding-fact maps use this.

Source: src/symtab/transactions.x:6

Sym.reference

List Sym.reference(Sym s, List key, Type &?type)

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

Stores NULL through type when no declaration supplies a type.

Source: src/symtab/bindings.x:261

Sym.reference_global

List Sym.reference_global(Sym s, 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/symtab/bindings.x:274

Sym.reopen_scopes

void Sym.reopen_scopes(Sym s, Block local)

Reopens the local scopes Sym.close_local_scopes set aside.

Source: src/symtab/scopes.x:89

Sym.reset

void Sym.reset(Sym s, Map globals)

Resets symbol state to one base scope backed by globals.

Later definitions mutate that caller-supplied map.

Source: src/symtab/scopes.x:27

Sym.reset_overlay

void Sym.reset_overlay(Sym s, Map base, Map overlay)

Resets symbol state to read base below the writable scope overlay.

Later definitions mutate overlay; base is only read.

Source: src/symtab/scopes.x:36

Sym.resolve_global

List Sym.resolve_global(Sym s, List key, Type &?type)

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

Returns NULL when no base scope contains the key.

Source: src/symtab/bindings.x:268

Sym.resolve_key

Type Sym.resolve_key(Sym s, Type key)

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

Source: src/symtab/types.x:20

Sym.resolve_numeric_type

Type Sym.resolve_numeric_type(Sym s, 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/symtab/types.x:158

Sym.scope_count

int Sym.scope_count(Sym s)

Returns the number of semantic scopes, including base scopes.

Source: src/symtab/scopes.x:73

Sym.seed_var_tags

void Sym.seed_var_tags(Sym s, Map symbols)

Registers declared T_var converters in the active Type unit.

Source: src/symtab/bindings.x:57

Sym.set

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

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

Source: src/symtab/bindings.x:6

Sym.sole_typedef

Type Sym.sole_typedef(Sym s, Type type)

Returns the name of the one file-scope typedef declared directly as type, or NULL when no typedef or several typedefs are.

Source: src/symtab/types.x:75

Sym.transacting

int Sym.transacting(Sym s)

Returns whether a semantic transaction is open.

Source: src/symtab/transactions.x:121

Sym.unit_symbols

Map Sym.unit_symbols(Sym s)

Returns a fresh map of the base symbols with the current scope’s rows merged in.

Source: src/symtab/scopes.x:118

Sym.unshadow_visible

List Sym.unshadow_visible(Sym s, String spelling)

Emits every local object spelled spelling that the current scope sees, the enclosing ones too, under one fresh spelling, so a file-scope name a template keeps reaches the global there, and returns them. Locals of other scopes keep their spellings for the native macros that name them.

Source: src/symtab/declarations.x:234

Sym.var_tag_for_type

Symbol Sym.var_tag_for_type(Sym s, 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/symtab/types.x:206

Sym.visible_symbols

List Sym.visible_symbols(Sym s)

Returns the visible one-part source names and their semantic types. Inner scopes win. The result is a fresh List; types remain borrowed.

Source: src/symtab/scopes.x:132

SymTxn

SymTxn.commit

void SymTxn.commit(SymTxn &?s)

Publishes an active semantic transaction and makes rollback a no-op. Its writes are already in the scope maps, so code holding a borrowed map observes a committed expansion. An absent or inactive transaction has no effect.

Source: src/symtab/transactions.x:135

SymTxn.commit_transient

void SymTxn.commit_transient(SymTxn &s)

Commits an active transaction, retaining the original counters map. The caller may then release the transaction’s construction scope. Parsing and evaluation must allocate outside that temporary scope.

Source: src/symtab/transactions.x:157

SymTxn.local_macros_changed

int SymTxn.local_macros_changed(SymTxn &s)

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

Source: src/symtab/transactions.x:104

SymTxn.rollback

void SymTxn.rollback(SymTxn &?s)

Restores every semantic value captured by an active transaction. An absent or inactive transaction has no effect.

Source: src/symtab/transactions.x:177

Public types

TypeKindSummary
SymaliasHolds a compiler’s declarations in nested scopes.

Sym

module typedef struct Sym { Block scopes, Map globals, statics, binding_facts, prefixed; int base_scopes, local_macro_names; Block undo, int transactions; Compiler c; } *Sym

Holds a compiler’s declarations in nested scopes. The lowest base_scopes contain file-scope declarations. Active transactions retain the rows each write replaces in undo.

Source: src/symtab/symtab.x:122

Design notes

Sym holds one compiler’s declarations as a stack of scopes searched from inner to outer; its lowest scopes hold file-scope declarations. It issues the binding identity of each declared name, resolves typedef chains and aggregate fields, and records which file-scope names are private. A SymTxn stages the rows a macro binds, so a failed expansion leaves the table as it was.