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

X2c semantic types.

Functions

FunctionSummary
List.type_from_astReturns the semantic Type represented by a complete (declare ...) AST.
Type.begin_unitStarts an empty set of source-declared Var rows for one translation unit.
Type.declaration_astReturns a complete (declare ...) AST for type and binding.
Type.declaration_baseReturns the declaration specifiers t without the pointer, array, or function modifiers an alias in them contributes, and sets modifiers to those modifiers, for Ast.append_modifiers to give each declarator.
Type.end_unitRestores the enclosing unit’s source-declared Var rows before the current unit’s Scope is released.
Type.fixed_var_tagReturns the process-lifetime Var tag fixed for type, or zero.
Type.parameter_astReturns a complete (param ...) AST for type and binding.
Type.partsAnswers Type.parts, declared in lib/meta.x, through type_declaration_parts, which a project’s helper shares.
Type.register_var_adoptionReplaces a registered type’s inferred Var tag with tag, or with the fixed tag of representation when tag is zero.
Type.register_var_tagRegisters one named type’s unit-local Var tag and exact forward converter.
Type.var_converterReturns the unit-local forward Var converter for the canonical form of type, or NULL.
Type.var_tagReturns the unit-local Var tag for type, falling back to its fixed tag.
Type.var_tag_rowReads the encoding row of tag into top, mask, and bottom and reports whether one exists.

List

List.type_from_ast

Type List.type_from_ast(List ast)

Returns the semantic Type represented by a complete (declare ...) AST. A declaration with one binding is unwrapped to that binding’s Type; multiple bindings return their Types in source order.

Source: src/type.x:27

Type

Type.begin_unit

Map Type.begin_unit(void)

Starts an empty set of source-declared Var rows for one translation unit. Returns the enclosing unit’s rows for restoration at close.

Source: src/type.x:295

Type.declaration_ast

List Type.declaration_ast(Type type, List binding)

Returns a complete (declare ...) AST for type and binding. A NULL binding produces an abstract declaration.

Source: src/type.x:194

Type.declaration_base

List Type.declaration_base(Type t, List &modifiers)

Returns the declaration specifiers t without the pointer, array, or function modifiers an alias in them contributes, and sets modifiers to those modifiers, for Ast.append_modifiers to give each declarator. Storage and source specifier text, such as ("_Noreturn"), stay on the base.

Source: src/type.x:175

Type.end_unit

void Type.end_unit(Map enclosing)

Restores the enclosing unit’s source-declared Var rows before the current unit’s Scope is released.

Source: src/type.x:304

Type.fixed_var_tag

Symbol Type.fixed_var_tag(Type type)

Returns the process-lifetime Var tag fixed for type, or zero.

Source: src/type.x:234

Type.parameter_ast

List Type.parameter_ast(Type type, List binding)

Returns a complete (param ...) AST for type and binding. A NULL binding produces an unnamed parameter.

Source: src/type.x:202

Type.parts

List Type.parts(Type type)

Answers Type.parts, declared in lib/meta.x, through type_declaration_parts, which a project’s helper shares.

Source: src/type.x:168

Type.register_var_adoption

void Type.register_var_adoption(Type type, Type representation, Symbol tag)

Replaces a registered type’s inferred Var tag with tag, or with the fixed tag of representation when tag is zero. Missing rows and untagged representations leave the table unchanged.

Source: src/type.x:283

Type.register_var_tag

void Type.register_var_tag(Type t, String name, String converter)

Registers one named type’s unit-local Var tag and exact forward converter. The first row for a canonical Type wins. A NULL type, name, or converter, or no active unit, leaves the table unchanged.

Source: src/type.x:271

Type.var_converter

String Type.var_converter(Type type)

Returns the unit-local forward Var converter for the canonical form of type, or NULL.

Source: src/type.x:245

Type.var_tag

Symbol Type.var_tag(Type type)

Returns the unit-local Var tag for type, falling back to its fixed tag.

Source: src/type.x:224

Type.var_tag_row

int Type.var_tag_row( Symbol tag, unsigned long &top, unsigned long &mask, unsigned long &bottom)

Reads the encoding row of tag into top, mask, and bottom and reports whether one exists. A tag whose decoded form carries a validity clause, an immediate width, or a user registration has no constant row.

Source: src/type.x:256

Design notes

Converts compiler declaration syntax to semantic types and owns the translation unit’s Var registrations. Structural Type operations live in lib/type.x.