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.discard_helperReturns (binding signature) for a generated helper that calls the function binding of type signature and then discards the unnamed argument temporaries which selects (bit n for argument n).
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 external native alias and ordinary adapter signatures.
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_discard_helperThe discard_helper for participant’s protocol member.
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 a protocol member for participant.
Compiler.resolve_protocolsResolves every visible adoption into the current conformance registry.
Compiler.reverse_converter_spellingReturns the conventional reverse converter spelling.

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:1438

Compiler.discard_helper

List Compiler.discard_helper( Compiler c, List binding, Type signature, String stem, int which)

Returns (binding signature) for a generated helper that calls the function binding of type signature and then discards the unnamed argument temporaries which selects (bit n for argument n). A discarded argument is one the compiler produced for this call alone, so its discard member may release what it owns before the enclosing scope ends. Returns null when no selected argument type has a discard member, or an ordinary pointer or aggregate result may borrow an argument.

Source: src/protocol.x:1762

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, so prelude and live symbol modes can be compared.

Source: src/protocol.x:1408

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:2238

Compiler.install_generated_protocol_symbols

void Compiler.install_generated_protocol_symbols(Compiler c)

Publishes external native alias and ordinary adapter signatures. Protocols must already be resolved in the active symbol table.

Source: src/protocol.x:1087

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:1369

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:2369

Compiler.protocol_discard_helper

List Compiler.protocol_discard_helper( Compiler c, Type participant, String member, int which)

The discard_helper for participant’s protocol member.

Source: src/protocol.x:1826

Compiler.protocol_members_for

List Compiler.protocol_members_for(Compiler c, 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:1289

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:1324

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:1684

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:501

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:261

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

Compiler.resolve_protocol_member

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

Resolves a 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. Inside the selected implementation itself the result is null, so the member’s own body keeps the native operation.

Source: src/protocol.x:1667

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:1059

Compiler.reverse_converter_spelling

String Compiler.reverse_converter_spelling( Compiler compiler, String base_name, String infix, String participant)

Returns the conventional reverse converter spelling. A Base.participant reverse converter is declared under the participant’s source spelling, and package mode rewrites that joined name as a whole, so the package prefix sits at the front of the derived binding instead of inside it. The split is keyed on a known package because a foreign header may spell __ in a type name.

Source: src/protocol.x:338

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.