Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/type.x
X2c semantic types.
Functions
| Function | Summary |
|---|---|
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.initialize | Initializes the process-lifetime scalar and fixed Var-tag tables. |
Type.is_aggregate | Returns whether type is any struct or union shape. |
Type.is_aggregate_tag | Returns whether type 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.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. |
List
List.type
inline Type List.type(List x)
Views x as a Type without validating its type shape.
Source: src/type.x:97
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:895
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:141
Symbol.is_inline
int Symbol.is_inline(Symbol sym)
Returns whether sym is the inline function specifier.
Source: src/type.x:111
Symbol.is_storage_class
int Symbol.is_storage_class(Symbol sym)
Returns whether sym is a storage-class specifier.
Source: src/type.x:102
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:120
Symbol.is_type_qualifier
int Symbol.is_type_qualifier(Symbol sym)
Returns whether sym is const, restrict, or volatile.
Source: src/type.x:114
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:712
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:568
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:491
Type.body
List Type.body(Type type)
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:417
Type.canonicalize
Type Type.canonicalize(Type type)
Removes non-typedef storage classes, inline, and type qualifiers from
type.
Source: src/type.x:612
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:74
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:60
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:618
Type.dereference
Type Type.dereference(Type type)
Removes one outer pointer-like or array modifier, or returns NULL.
Source: src/type.x:700
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:647
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:498
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:542
Type.initialize
void Type.initialize(void)
Initializes the process-lifetime scalar and fixed Var-tag tables.
Source: src/type.x:483
Type.is_aggregate
int Type.is_aggregate(Type type)
Returns whether type is any struct or union shape.
Source: src/type.x:147
Type.is_aggregate_tag
int Type.is_aggregate_tag(Type type)
Returns whether type is a body-free struct or union tag reference.
Source: src/type.x:150
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:157
Type.is_array
int Type.is_array(Type type)
Returns whether the outer declarator represented by type is an array.
Source: src/type.x:181
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:673
Type.is_bitfield
int Type.is_bitfield(Type type)
Returns whether the outer declarator represented by type is a
bitfield.
Source: src/type.x:192
Type.is_builtin
int Type.is_builtin(Type type)
Returns whether type is a builtin scalar, struct, union, or enum.
Source: src/type.x:662
Type.is_enum
int Type.is_enum(Type type)
Returns whether type is any enum shape.
Source: src/type.x:161
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:164
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:170
Type.is_extern
int Type.is_extern(Type type)
Returns whether type carries the extern storage class.
Source: src/type.x:780
Type.is_function
int Type.is_function(Type type)
Returns whether the outer declarator is a function or inline function.
Source: src/type.x:184
Type.is_inline
int Type.is_inline(Type type)
Returns whether type carries the inline function specifier.
Source: src/type.x:778
Type.is_integral
int Type.is_integral(Type type)
Returns whether type is a fixed integral scalar or an enum.
Source: src/type.x:686
Type.is_number
int Type.is_number(Type type)
Returns whether type is a fixed numeric scalar or an enum.
Source: src/type.x:683
Type.is_pointer
int Type.is_pointer(Type type)
Returns whether type begins with a pointer-like *, &, or ^.
Source: src/type.x:173
Type.is_static
int Type.is_static(Type type)
Returns whether type carries the static storage class.
Source: src/type.x:776
Type.is_threaded
int Type.is_threaded(Type type)
Returns whether type carries the threaded storage class.
Source: src/type.x:782
Type.is_typedef
int Type.is_typedef(Type type)
Returns whether type begins with the typedef storage class.
Source: src/type.x:677
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:665
Type.list
inline List Type.list(Type x)
Views x as its underlying List without validating its type shape.
Source: src/type.x:94
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:377
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:82
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:725
Type.reference
Type Type.reference(Type type)
Returns the pointer Type formed by prefixing type with *.
Source: src/type.x:707
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:521
Type.register_var_tag
void Type.register_var_tag(Type type, 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:508
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:200
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:288
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:407
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:534
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:296
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:305
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:553
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:750
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:91
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.