pub struct Types { /* private fields */ }Expand description
Every type in one translation unit.
Implementations§
Source§impl Types
impl Types
Sourcepub fn new() -> Types
pub fn new() -> Types
A table holding the basic types and nothing else.
The basic types are interned here rather than on first use so that asking for int is
an array read. They are the ones asked for by far the most often, because every
integer promotion produces one.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the table is empty, which it never is once Types::new has run.
Sourcepub fn quals(&self, id: TypeId) -> Qualifiers
pub fn quals(&self, id: TypeId) -> Qualifiers
Sourcepub fn canonical(&self, id: TypeId) -> TypeId
pub fn canonical(&self, id: TypeId) -> TypeId
The canonical form of id, with every typedef resolved at every depth.
This is what every semantic rule reads. id itself is what every diagnostic prints.
§Panics
Panics if id came from a different table.
Sourcepub fn is_sugar(&self, id: TypeId) -> bool
pub fn is_sugar(&self, id: TypeId) -> bool
Whether id is written with a typedef name somewhere inside it.
§Panics
Panics if id came from a different table.
Sourcepub fn boolean(&self) -> TypeId
pub fn boolean(&self) -> TypeId
bool, which is _Bool in the older spellings.
Named this way because bool is a Rust keyword and r#bool at every call site would
be a worse trade than one unusual name here.
Sourcepub fn bit_int(&mut self, signed: bool, width: u32) -> TypeId
pub fn bit_int(&mut self, signed: bool, width: u32) -> TypeId
_BitInt(width), signed or not.
The width is not checked against the target’s maximum here. That check belongs where there is a span to point at, and building the type anyway means the rest of the declaration still gets checked instead of collapsing into a cascade.
Sourcepub fn vector(&mut self, elem: TypeId, len: u32) -> TypeId
pub fn vector(&mut self, elem: TypeId, len: u32) -> TypeId
A GNU vector of len elements of elem.
Sourcepub fn function(&mut self, signature: FunctionType) -> TypeId
pub fn function(&mut self, signature: FunctionType) -> TypeId
A function type, deduplicated by content.
§Panics
Panics past four billion distinct function types in one translation unit. The alternative to panicking is handing back an id that means a different type, so the limit is stated rather than worked around.
Sourcepub fn signature(&self, id: FunctionId) -> &FunctionType
pub fn signature(&self, id: FunctionId) -> &FunctionType
Sourcepub fn declare_record(
&mut self,
kind: RecordKind,
tag: Option<Symbol>,
) -> RecordId
pub fn declare_record( &mut self, kind: RecordKind, tag: Option<Symbol>, ) -> RecordId
Declares a struct or union that has been named but not yet laid out.
Each call makes a new type even for the same tag, because a record type in C is its declaration. Redeclaring a tag in an inner scope makes a different type, and the two being distinct is what the scope rules mean.
§Panics
Panics past four billion record declarations in one translation unit.
Sourcepub fn record_info(&self, id: RecordId) -> &RecordInfo
pub fn record_info(&self, id: RecordId) -> &RecordInfo
Sourcepub fn complete_record(&mut self, id: RecordId, laid_out: RecordLayout)
pub fn complete_record(&mut self, id: RecordId, laid_out: RecordLayout)
Completes a record by recording what layout_record produced.
§Panics
Panics if id came from a different table.
Sourcepub fn field(&self, id: RecordId, name: Symbol) -> Option<&Field>
pub fn field(&self, id: RecordId, name: Symbol) -> Option<&Field>
The member of a record with the given name.
Direct members only. Reaching into an anonymous member is a name lookup with a path to build rather than a search, so it belongs to whoever is resolving the expression.
§Panics
Panics if id came from a different table.
Sourcepub fn declare_enum(&mut self, tag: Option<Symbol>) -> EnumId
pub fn declare_enum(&mut self, tag: Option<Symbol>) -> EnumId
Declares an enum whose underlying type is not decided yet.
§Panics
Panics past four billion enumeration declarations in one translation unit.
Sourcepub fn enumeration(&mut self, id: EnumId) -> TypeId
pub fn enumeration(&mut self, id: EnumId) -> TypeId
The type of a declared enumeration.
Sourcepub fn complete_enum(&mut self, id: EnumId, underlying: TypeId, fixed: bool)
pub fn complete_enum(&mut self, id: EnumId, underlying: TypeId, fixed: bool)
Records what an enumeration is represented in, and whether the program said so.
§Panics
Panics if id came from a different table.
Sourcepub fn typedef(&mut self, name: Symbol, underlying: TypeId) -> TypeId
pub fn typedef(&mut self, name: Symbol, underlying: TypeId) -> TypeId
A typedef name standing for underlying.
Sourcepub fn qualified(&mut self, id: TypeId, quals: Qualifiers) -> TypeId
pub fn qualified(&mut self, id: TypeId, quals: Qualifiers) -> TypeId
id with quals added to whatever it already carries.
Qualifying an array qualifies its element type and leaves the array itself unqualified,
which is 6.7.3p10 and is not a shortcut. An array type has no qualifiers of its own,
and if it did then const on an array parameter would mean nothing at all.
Sourcepub fn unqualified(&mut self, id: TypeId) -> TypeId
pub fn unqualified(&mut self, id: TypeId) -> TypeId
id with every qualifier removed from its outermost node.
Only the outermost, because that is what the standard means by the unqualified version
of a type. The pointee of a const char * stays const.