Skip to main content

Types

Struct Types 

Source
pub struct Types { /* private fields */ }
Expand description

Every type in one translation unit.

Implementations§

Source§

impl Types

Source

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.

Source

pub fn len(&self) -> usize

How many distinct types there are.

Source

pub fn is_empty(&self) -> bool

Whether the table is empty, which it never is once Types::new has run.

Source

pub fn get(&self, id: TypeId) -> Type

The type id stands for, with its qualifiers.

§Panics

Panics if id came from a different table.

Source

pub fn kind(&self, id: TypeId) -> TypeKind

What id is, ignoring its qualifiers.

§Panics

Panics if id came from a different table.

Source

pub fn quals(&self, id: TypeId) -> Qualifiers

What id is qualified with.

§Panics

Panics if id came from a different table.

Source

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.

Source

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.

Source

pub fn void(&self) -> TypeId

void.

Source

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.

Source

pub fn int(&self, kind: IntKind) -> TypeId

One of the standard integer types.

Source

pub fn float(&self, kind: FloatKind) -> TypeId

One of the real floating types.

Source

pub fn complex(&mut self, kind: FloatKind) -> TypeId

_Complex T.

Source

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.

Source

pub fn pointer(&mut self, pointee: TypeId) -> TypeId

A pointer to pointee.

Source

pub fn atomic(&mut self, inner: TypeId) -> TypeId

_Atomic(inner).

Source

pub fn array(&mut self, elem: TypeId, len: ArrayLen) -> TypeId

An array of elem.

Source

pub fn vector(&mut self, elem: TypeId, len: u32) -> TypeId

A GNU vector of len elements of elem.

Source

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.

Source

pub fn signature(&self, id: FunctionId) -> &FunctionType

The signature behind a function type.

§Panics

Panics if id came from a different table.

Source

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.

Source

pub fn record(&mut self, id: RecordId) -> TypeId

The type of a declared record.

Source

pub fn record_info(&self, id: RecordId) -> &RecordInfo

What is known about a declared record.

§Panics

Panics if id came from a different table.

Source

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.

Source

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.

Source

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.

Source

pub fn enumeration(&mut self, id: EnumId) -> TypeId

The type of a declared enumeration.

Source

pub fn enum_info(&self, id: EnumId) -> &EnumInfo

What is known about a declared enumeration.

§Panics

Panics if id came from a different table.

Source

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.

Source

pub fn typedef(&mut self, name: Symbol, underlying: TypeId) -> TypeId

A typedef name standing for underlying.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Types

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Types

Source§

fn default() -> Types

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Types

§

impl RefUnwindSafe for Types

§

impl Send for Types

§

impl Sync for Types

§

impl Unpin for Types

§

impl UnsafeUnpin for Types

§

impl UnwindSafe for Types

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.