pub enum TypeRepr {
Int {
size: usize,
},
Bool,
SpaceAddress {
size: usize,
space: MemorySpaceId,
},
Aggregate {
fields: Vec<AggregateField>,
},
Struct {
name: String,
size: usize,
fields: Vec<AggregateField>,
},
StructPointer {
size: usize,
pointee: TypeId,
},
Array {
elem: TypeId,
count: usize,
},
List {
elem: TypeId,
bound: Option<usize>,
},
FunctionReturn {
owner: FunctionId,
fields: Vec<AggregateField>,
},
CodePointer {
size: usize,
},
}Expand description
Serializable description of a concrete Type.
There are only three concrete types, each fully described by a byte width and
(for pointers) the memory space it points into. TypeManager serializes its
type table as a Vec<TypeRepr> and replays the get_or_make_* constructors
on load, which reproduces both the interned TypeId indices and the lookup
maps exactly.
Variants§
Int
Bool
A byte-stored boolean whose value domain is {0, 1}. Minted only by
comparisons and the true/false literals; size() is always 1.
SpaceAddress
Aggregate
A fixed, ordered group of named field types — the functional-IR
representation of a tuple. Used by argpromote to return
(real_return, write-set). Abstract: it has no physical return-register
ABI.
Fields
fields: Vec<AggregateField>Struct
A named, nominal struct with explicit per-field byte offsets — the
pointee of a StructPointer. Identity is the name, not the field
list, so two structs with coincident layouts stay distinct. Sparse: only
the fields of interest are listed; size is the real struct size and
need not equal the fields’ extent.
StructPointer
A pointer to a nominal Struct (or any other type),
of the given byte width. pointee is the TypeId it points at.
Array
A fixed-length homogeneous array of count elements of type elem,
laid out contiguously. Its byte width is count * sizeof(elem).
Deliberately disguised as a width-N scalar: it answers
Type::size like any integer and does not expose Type::fields,
so structural passes (mem2reg, alias, DCE, GVN value-numbering) handle it
unchanged. Only element-aware sites (argpromote, the Extract/Range
over Map rewrite, emulation) consult Type::array. Lane projection is
defined as a contiguous bit-slice: Extract(arr, k) ≡ Range(arr, k*sizeof(elem), sizeof(elem)).
List
A variable-length homogeneous sequence of elem — the result of
take_while. bound is the static storage upper bound
in elements (Some(n) for a take_while over a fixed [T; n] array), or
None when the source is an unbounded pointer (a char* string of unknown
length). Like Array a bounded list is disguised as a
width-N scalar (its size is the bound footprint); an unbounded list has
no materialized footprint (size 0) — it is a handle consumed only by
len/map, never stored. Only Type::list tells either apart from a
fixed array; the runtime length is the position of the first failing element.
FunctionReturn
A function-owned return record. Unlike structural Aggregate
values, identity belongs to owner: two functions with identical fields
still have distinct types, and the owner may revise the fields later while
preserving the same TypeId. Kept last to preserve the existing bincode
discriminants of previously persisted type variants.
CodePointer
A pointer to code — a function/callable address, of the given byte
width. Minted by the infer_code_pointers pass for a value used as the
target of an indirect call. Deliberately structureless (no signature yet):
it marks “this scalar is a code address,” enough to drive call-target
typing and (future) resolution/exploration. Kept last to preserve the
bincode discriminants of previously persisted variants.