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

Protocol collection and per-unit semantic registry.

Functions

FunctionSummary
Compiler.derived_memberReturns the protocol member used to derive a comparison operator.
Compiler.dump_conformancePrints stable conformance rows for typedefs in globs.
Compiler.generate_protocol_adaptersGenerates adapters and descriptor registration for resolved conformances.
Compiler.install_generated_protocol_symbolsPublishes generated protocol call signatures into a live symbol map.
Compiler.operator_memberReturns the protocol member corresponding to a direct binary operator.
Compiler.parse_protocol_declarationParses a protocol body or concrete adoption at the current token.
Compiler.protocol_members_forReturns the resolved conformance for participant and base, if any.
Compiler.protocol_rejects_direct_memberReports whether conformance supersedes an ambient direct member.
Compiler.protocol_update_helperReturns a generated helper for a direct protocol-backed update.
Compiler.publish_protocol_nodeValidates and installs one normalized protocol or adoption node.
Compiler.rebuild_protocolsRebuilds the per-unit protocol and adoption registries from symbols.
Compiler.record_declaration_visibilityRecords the visibility of one parsed top-level declaration.
Compiler.resolve_protocol_memberResolves an operator-facing protocol member for participant.
Compiler.resolve_protocol_methodResolves a method-facing protocol member for participant.
Compiler.resolve_protocolsResolves every visible adoption into the current conformance registry.

Compiler

Compiler.derived_member

Symbol Compiler.derived_member(Compiler compiler, Symbol op)

Returns the protocol member used to derive a comparison operator. Inequality derives from equal, ordered comparisons derive from compare, and unsupported operators return zero.

Source: src/protocol.x:1453

Compiler.dump_conformance

void Compiler.dump_conformance(Compiler compiler, Map globs)

Prints stable conformance rows for typedefs in globs. Rows are ordered by participant and protocol and identify whether each adoption is owned by this unit, making the output suitable for comparing live and artifact symbol modes.

Source: src/protocol.x:1423

Compiler.generate_protocol_adapters

List Compiler.generate_protocol_adapters(Compiler c, List ast)

Generates adapters and descriptor registration for resolved conformances. Native aliases are inserted at the participant’s inferred public or private boundary. Ordinary adapters and descriptor thunks are added to the compiler’s early output. Returns ast with native insertions applied.

Source: src/protocol.x:2142

Compiler.install_generated_protocol_symbols

void Compiler.install_generated_protocol_symbols( Compiler c, Map symbols)

Publishes generated protocol call signatures into a live symbol map. The map becomes the active Sym table, then protocol rows are rebuilt and resolved so live collection exposes the same external native aliases and ordinary generated members as artifact-backed lookup. A null map is a no-op.

Source: src/protocol.x:1112

Compiler.operator_member

Symbol Compiler.operator_member(Compiler compiler, Symbol op)

Returns the protocol member corresponding to a direct binary operator. Returns zero when the operator has no direct protocol mapping.

Source: src/protocol.x:1383

Compiler.parse_protocol_declaration

List Compiler.parse_protocol_declaration(Compiler c)

Parses a protocol body or concrete adoption at the current token. The method consumes through the closing brace or semicolon. Full parsing publishes the normalized row immediately. Macro-hole parsing returns syntax for later binding; shallow parsing publishes only when protocol collection is enabled and otherwise returns the uninstalled node.

Source: src/protocol.x:2285

Compiler.protocol_members_for

List Compiler.protocol_members_for( Compiler compiler, Type participant, Type base)

Returns the resolved conformance for participant and base, if any. Lookup canonicalizes the participant and may use the nearest adopted typedef ancestor. Native conformances install their generated bindings before the cached conformance row is returned.

Source: src/protocol.x:1316

Compiler.protocol_rejects_direct_member

int Compiler.protocol_rejects_direct_member( Compiler compiler, Type participant, String member)

Reports whether conformance supersedes an ambient direct member. The answer is cached for the canonical participant and includes the first visible adopted ancestor that declares the member.

Source: src/protocol.x:1340

Compiler.protocol_update_helper

String Compiler.protocol_update_helper( Compiler c, Type participant, String member, int postfix)

Returns a generated helper for a direct protocol-backed update. The resolved member must have exactly (Participant, RHS) -> Participant. A matching helper is emitted once into the compiler’s early declarations; postfix selects whether it returns the old or stored value. Returns null when the member cannot implement this update shape.

Source: src/protocol.x:1710

Compiler.publish_protocol_node

List Compiler.publish_protocol_node( Compiler c, List node, Token participant_token, Token representation_token)

Validates and installs one normalized protocol or adoption node. The node must carry a protocol record or supported adoption shape with its storage and source location. Installation invalidates cached protocol decisions and returns the canonical published node. Generated contexts may also retain that node in Sym for replay.

Source: src/protocol.x:513

Compiler.rebuild_protocols

void Compiler.rebuild_protocols(Compiler compiler, Map symbols)

Rebuilds the per-unit protocol and adoption registries from symbols. Existing rows, helper decisions, and lookup caches are discarded; a null map leaves those registries empty. Conformance reset and resolution belong to resolve_protocols.

Source: src/protocol.x:264

Compiler.record_declaration_visibility

void Compiler.record_declaration_visibility( Compiler compiler, 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/protocol.x:85

Compiler.resolve_protocol_member

List Compiler.resolve_protocol_member( Compiler compiler, Type participant, String member_name)

Resolves an operator-facing protocol member for participant. Returns a (binding signature) pair for the selected implementation or null when no eligible resolved member exists; positive and negative results are cached.

Source: src/protocol.x:1691

Compiler.resolve_protocol_method

List Compiler.resolve_protocol_method( Compiler compiler, Type participant, String member_name)

Resolves a method-facing protocol member for participant. Returns a (binding signature) pair for the selected implementation or null when no eligible resolved member exists; positive and negative results are cached separately from operator lookup.

Source: src/protocol.x:1700

Compiler.resolve_protocols

void Compiler.resolve_protocols(Compiler compiler)

Resolves every visible adoption into the current conformance registry. Resolution starts from an empty registry; diagnostics are located only for adoptions owned by the current translation unit.

Source: src/protocol.x:1079

Design notes

This module carries protocol and adoption rows from parsing through resolved conformance and generated adapters. Registries are rebuilt per translation unit; static rows are visible only when their canonical source path is the current unit.