Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/type.x
X2c semantic types.
Functions
| Function | Summary |
|---|---|
ast_addressed_identifier | Returns the name whose address an expression takes, or NULL. |
ast_direct_identifier | Returns the name an expression designates directly, following the forms that still name the same object - parentheses, a member, an array index, a dereference - or NULL when the expression designates no single name. |
ast_indirect_identifier | Returns the name of the pointer an expression designates through, or NULL when it designates no object through a single name. |
ast_prototype_declarator | Returns declarator with the outermost volatile removed from each of its parameters. |
List.type | Views x as a Type without validating its type shape. |
List.type_from_ast | Returns the semantic Type represented by a complete (declare ...) AST. |
Symbol.is_builtin_type | Returns whether sym can begin a builtin C type specifier. |
Symbol.is_inline | Returns whether sym is the inline function specifier. |
Symbol.is_storage_class | Returns whether sym is a storage-class specifier. |
Symbol.is_type_modifier | Returns whether sym modifies the width or signedness of a scalar. |
Symbol.is_type_qualifier | Returns whether sym is const, restrict, or volatile. |
Type.apply | Returns the result Type of a function Type, following pointer and array modifiers, or NULL when the chain does not end at a function. |
Type.base_type | Returns the suffix of type beginning at its builtin or typedef base. |
Type.begin_unit | Starts an empty set of source-declared Var rows for one translation unit. |
Type.body | Returns the stored body portion of an enum, struct, or union Type. |
Type.canonicalize | Removes non-typedef storage classes, inline, and type qualifiers from type. |
Type.declaration_ast | Returns a complete (declare ...) AST for type and binding. |
Type.declaration_parts | Returns (base modifiers) for reconstructing a declaration of type. |
Type.declared | Returns the stored declaration Type after removing non-typedef storage classes and inline. |
Type.dereference | Removes one outer pointer-like or array modifier, or returns NULL. |
Type.discards_qualifiers | Returns whether handing a source value to a target declaration would silently drop a qualifier the target does not keep. |
Type.end_unit | Ends the source-declared Var-row lifetime before the unit Scope is released. |
Type.fixed_var_tag | Returns the process-lifetime Var tag fixed for type, or zero. |
Type.is_aggregate | Returns whether type is any struct or union shape. |
Type.is_aggregate_tag | Returns whether t is a body-free struct or union tag reference. |
Type.is_aggregate_tag_body | Returns whether type is a tagged struct or union definition. |
Type.is_array | Returns whether the outer declarator represented by type is an array. |
Type.is_bare_typedef_name | Returns whether type is one bare typedef-name String. |
Type.is_bitfield | Returns whether the outer declarator represented by type is a bitfield. |
Type.is_builtin | Returns whether type is a builtin scalar, struct, union, or enum. |
Type.is_enum | Returns whether type is any enum shape. |
Type.is_enum_tag | Returns whether type is a body-free enum tag reference. |
Type.is_enum_tag_body | Returns whether type is a tagged enum definition. |
Type.is_extern | Returns whether type carries the extern storage class. |
Type.is_function | Returns whether the outer declarator is a function or inline function. |
Type.is_inline | Returns whether type carries the inline function specifier. |
Type.is_integral | Returns whether type is a fixed integral scalar or an enum. |
Type.is_number | Returns whether type is a fixed numeric scalar or an enum. |
Type.is_pointer | Returns whether type begins with a pointer-like *, &, or ^. |
Type.is_static | Returns whether type carries the static storage class. |
Type.is_threaded | Returns whether type carries the threaded storage class. |
Type.is_typedef | Returns whether type begins with the typedef storage class. |
Type.is_typedef_name | Returns whether the base of type is exactly one typedef-name String. |
Type.list | Views x as its underlying List without validating its type shape. |
Type.numeric_literal | Returns the native type selected by a validated numeric token. |
Type.parameter_ast | Returns a complete (param ...) AST for type and binding. |
Type.promote | Applies integer promotion to type. |
Type.reference | Returns the pointer Type formed by prefixing type with *. |
Type.register_var_adoption | Replaces a registered type’s inferred Var tag with tag, or with the fixed tag of representation when tag is zero. |
Type.register_var_tag | Registers one named type’s unit-local Var tag and exact forward converter. |
Type.scalar | Returns the normalized builtin scalar spelling, or NULL when type is not one valid scalar combination. |
Type.scalar_tag | Returns the fixed Var numeric tag for type, or zero when none exists. |
Type.tag | Returns the one-element tag List of an enum, struct, or union Type. |
Type.var_converter | Returns the unit-local forward Var converter for the canonical form of type, or NULL. |
Type.var_numeric_extractor | Returns the numeric Var reader for type, or NULL when unsupported. |
Type.var_numeric_update_helper | Returns the native numeric update helper for type, or NULL when the scalar has no registered update helper. |
Type.var_tag | Returns the unit-local Var tag for type, falling back to its fixed tag. |
Type.var_tag_row | Reads the encoding row of tag into top, mask, and bottom and reports whether one exists. |
Type.widest | Returns the usual arithmetic result Type for two scalar operands. |
Var.type | Returns the List payload of x as a Type, or NULL for another tag. |
Functions
ast_addressed_identifier
String ast_addressed_identifier(Var value)
Returns the name whose address an expression takes, or NULL.
Source: src/type.x:78
ast_direct_identifier
String ast_direct_identifier(Var value)
Returns the name an expression designates directly, following the forms
that still name the same object - parentheses, a member, an array index,
a dereference - or NULL when the expression designates no single name.
A declaration qualifier that must reach one object, such as the volatile
an error transfer requires, applies to this name.
Source: src/type.x:122
ast_indirect_identifier
String ast_indirect_identifier(Var value)
Returns the name of the pointer an expression designates through, or
NULL when it designates no object through a single name. *pointer,
pointer[index], and pointer->member all change the object the pointer
holds, which ast_direct_identifier reports as no name at all.
Source: src/type.x:139
ast_prototype_declarator
List ast_prototype_declarator(List declarator)
Returns declarator with the outermost volatile removed from each of
its parameters. C ignores a parameter’s top-level qualifier when it
compares a prototype with its definition, and the qualifier the error
transfer requires belongs to the definition that writes the parameter,
not to the declaration its callers read.
Source: src/type.x:158
List
List.type
inline Type List.type(List x)
Views x as a Type without validating its type shape.
Source: src/type.x:203
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:1020
Symbol
Symbol.is_builtin_type
int Symbol.is_builtin_type(Symbol sym)
Returns whether sym can begin a builtin C type specifier.
Source: src/type.x:232
Symbol.is_inline
int Symbol.is_inline(Symbol sym)
Returns whether sym is the inline function specifier.
Source: src/type.x:219
Symbol.is_storage_class
int Symbol.is_storage_class(Symbol sym)
Returns whether sym is a storage-class specifier.
Source: src/type.x:216
Symbol.is_type_modifier
int Symbol.is_type_modifier(Symbol sym)
Returns whether sym modifies the width or signedness of a scalar.
Source: src/type.x:225
Symbol.is_type_qualifier
int Symbol.is_type_qualifier(Symbol sym)
Returns whether sym is const, restrict, or volatile.
Source: src/type.x:222
Type
Type.apply
Type Type.apply(Type type)
Returns the result Type of a function Type, following pointer and array
modifiers, or NULL when the chain does not end at a function.
Source: src/type.x:811
Type.base_type
Type Type.base_type(Type type)
Returns the suffix of type beginning at its builtin or typedef base.
The result shares the original List and is NULL when no base is
present.
Source: src/type.x:660
Type.begin_unit
void Type.begin_unit(void)
Starts an empty set of source-declared Var rows for one translation
unit.
Source: src/type.x:584
Type.body
List Type.body(Type t)
Returns the stored body portion of an enum, struct, or union Type.
Tag references and Types without a stored body return NULL.
Source: src/type.x:503
Type.canonicalize
Type Type.canonicalize(Type type)
Removes non-typedef storage classes, inline, and type qualifiers from
type.
Source: src/type.x:711
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:72
Type.declaration_parts
List Type.declaration_parts(Type type)
Returns (base modifiers) for reconstructing a declaration of type.
Function modifiers contain parameter AST nodes, and modifier order retains
C declarator precedence.
Source: src/type.x:61
Type.declared
Type Type.declared(Type type)
Returns the stored declaration Type after removing non-typedef storage
classes and inline. Those specifiers describe declaration placement;
const, restrict, and volatile describe the stored value and remain.
Source: src/type.x:717
Type.dereference
Type Type.dereference(Type type)
Removes one outer pointer-like or array modifier, or returns NULL.
Source: src/type.x:799
Type.discards_qualifiers
int Type.discards_qualifiers(Type source, Type target)
Returns whether handing a source value to a target declaration would
silently drop a qualifier the target does not keep. The leading
qualifiers of each type describe the copied value, not what it points
at, so only the deeper levels are compared. Callers use this where the
two types are otherwise the same; a conversion through a converter
function copies instead of aliasing.
Source: src/type.x:746
Type.end_unit
void Type.end_unit(void)
Ends the source-declared Var-row lifetime before the unit Scope is
released.
Source: src/type.x:591
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:634
Type.is_aggregate
int Type.is_aggregate(Type type)
Returns whether type is any struct or union shape.
Source: src/type.x:238
Type.is_aggregate_tag
int Type.is_aggregate_tag(Type t)
Returns whether t is a body-free struct or union tag reference.
Source: src/type.x:241
Type.is_aggregate_tag_body
int Type.is_aggregate_tag_body(Type type)
Returns whether type is a tagged struct or union definition.
Source: src/type.x:248
Type.is_array
int Type.is_array(Type type)
Returns whether the outer declarator represented by type is an array.
Source: src/type.x:272
Type.is_bare_typedef_name
int Type.is_bare_typedef_name(Type type)
Returns whether type is one bare typedef-name String.
Unlike is_typedef_name, this rejects pointer and array wrappers.
Source: src/type.x:772
Type.is_bitfield
int Type.is_bitfield(Type type)
Returns whether the outer declarator represented by type is a
bitfield.
Source: src/type.x:283
Type.is_builtin
int Type.is_builtin(Type type)
Returns whether type is a builtin scalar, struct, union, or enum.
Source: src/type.x:761
Type.is_enum
int Type.is_enum(Type type)
Returns whether type is any enum shape.
Source: src/type.x:252
Type.is_enum_tag
int Type.is_enum_tag(Type type)
Returns whether type is a body-free enum tag reference.
Source: src/type.x:255
Type.is_enum_tag_body
int Type.is_enum_tag_body(Type type)
Returns whether type is a tagged enum definition.
Source: src/type.x:261
Type.is_extern
int Type.is_extern(Type type)
Returns whether type carries the extern storage class.
Source: src/type.x:879
Type.is_function
int Type.is_function(Type type)
Returns whether the outer declarator is a function or inline function.
Source: src/type.x:275
Type.is_inline
int Type.is_inline(Type type)
Returns whether type carries the inline function specifier.
Source: src/type.x:877
Type.is_integral
int Type.is_integral(Type type)
Returns whether type is a fixed integral scalar or an enum.
Source: src/type.x:785
Type.is_number
int Type.is_number(Type type)
Returns whether type is a fixed numeric scalar or an enum.
Source: src/type.x:782
Type.is_pointer
int Type.is_pointer(Type type)
Returns whether type begins with a pointer-like *, &, or ^.
Source: src/type.x:264
Type.is_static
int Type.is_static(Type type)
Returns whether type carries the static storage class.
Source: src/type.x:875
Type.is_threaded
int Type.is_threaded(Type type)
Returns whether type carries the threaded storage class.
Source: src/type.x:881
Type.is_typedef
int Type.is_typedef(Type type)
Returns whether type begins with the typedef storage class.
Source: src/type.x:776
Type.is_typedef_name
int Type.is_typedef_name(Type type)
Returns whether the base of type is exactly one typedef-name String.
Source: src/type.x:764
Type.list
inline List Type.list(Type x)
Views x as its underlying List without validating its type shape.
Source: src/type.x:200
Type.numeric_literal
Type Type.numeric_literal(String text, int floating)
Returns the native type selected by a validated numeric token.
floating selects floating suffix rules; an integer outside all supported
native families returns NULL.
Source: src/type.x:463
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:188
Type.promote
Type Type.promote(Type type)
Applies integer promotion to type.
Enums and narrow integers become int; other scalars retain their
canonical spelling, and a non-scalar returns NULL.
Source: src/type.x:824
Type.reference
Type Type.reference(Type type)
Returns the pointer Type formed by prefixing type with *.
Source: src/type.x:806
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:613
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:601
Type.scalar
Type Type.scalar(Type type)
Returns the normalized builtin scalar spelling, or NULL when type is
not one valid scalar combination. Storage classes and qualifiers do not
affect the result.
Source: src/type.x:291
Type.scalar_tag
Symbol Type.scalar_tag(Type type)
Returns the fixed Var numeric tag for type, or zero when none exists.
Source: src/type.x:374
Type.tag
List Type.tag(Type type)
Returns the one-element tag List of an enum, struct, or union Type.
For a compiler-generated anonymous tag, that element is a gensym node. A
shape with no tag slot returns NULL.
Source: src/type.x:493
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:626
Type.var_numeric_extractor
String Type.var_numeric_extractor(Type type)
Returns the numeric Var reader for type, or NULL when unsupported.
Enums use Var_int after conversion to their shared integer tag.
Source: src/type.x:382
Type.var_numeric_update_helper
String Type.var_numeric_update_helper(Type type)
Returns the native numeric update helper for type, or NULL when the
scalar has no registered update helper.
Source: src/type.x:391
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:645
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:570
Type.widest
Type Type.widest(Type a, Type b)
Returns the usual arithmetic result Type for two scalar operands.
A missing or non-scalar operand produces NULL.
Source: src/type.x:849
Var
Var.type
inline Type Var.type(Var x)
Returns the List payload of x as a Type, or NULL for another tag.
Source: src/type.x:197
Public types
| Type | Kind | Summary |
|---|---|---|
Type | alias | Represents a semantic type as a canonical List of declarator modifiers followed by its base type. |
Type
typedef List Type
Represents a semantic type as a canonical List of declarator modifiers
followed by its base type. NULL denotes no type, and nonempty values have
the canonical List-pool lifetime.
Source: src/type.x:17
Design notes
Represents semantic types as Lists, with operations for inspection,
canonicalization, classification, and Var conversion. Scalar
normalization produces primitive C spellings; semantic runtime typedefs
keep their declared identity.