Skip to main content

TypeTable

Struct TypeTable 

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

An interning table for structural types plus the assignability relation.

The table is append-only while checking and frozen into the immutable SemanticModel. It is also a standalone reusable value: TypeTable::new yields the primitive types so the algebra can be exercised directly.

Implementations§

Source§

impl TypeTable

Source

pub fn new() -> Self

Creates a table pre-populated with every primitive type.

Source

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

Returns the interned representation of a type identity.

Source

pub const fn error_type(&self) -> TypeId

Source

pub const fn any(&self) -> TypeId

Source

pub const fn unknown(&self) -> TypeId

Source

pub const fn never(&self) -> TypeId

Source

pub const fn void(&self) -> TypeId

Source

pub const fn null_type(&self) -> TypeId

Source

pub const fn undefined_type(&self) -> TypeId

Source

pub const fn boolean(&self) -> TypeId

Source

pub const fn number(&self) -> TypeId

Source

pub const fn bigint(&self) -> TypeId

Source

pub const fn string(&self) -> TypeId

Source

pub const fn symbol_type(&self) -> TypeId

Source

pub const fn object(&self) -> TypeId

Source

pub fn boolean_literal(&mut self, value: bool) -> TypeId

Interns a boolean literal type.

Source

pub fn number_literal(&mut self, text: &str) -> TypeId

Interns a numeric literal type keyed by its source lexeme.

Source

pub fn string_literal(&mut self, text: &str) -> TypeId

Interns a string literal type keyed by its source lexeme.

Source

pub fn bigint_literal(&mut self, text: &str) -> TypeId

Interns a bigint literal type keyed by its source lexeme.

Source

pub fn named(&mut self, symbol: SymbolId) -> TypeId

Interns a nominal named type.

Source

pub fn numeric_enum(&mut self, symbol: SymbolId) -> TypeId

Interns a numeric enum value type.

Source

pub fn array(&mut self, element: TypeId) -> TypeId

Interns an array type over element.

Source

pub fn object_type(&mut self, properties: Vec<PropertyType>) -> TypeId

Interns an object type after canonically ordering its members by name.

Source

pub fn function( &mut self, parameters: Vec<TypeId>, return_type: TypeId, ) -> TypeId

Interns a function type.

Source

pub fn union(&mut self, members: &[TypeId]) -> TypeId

Interns a union, normalizing absorption, never removal, and duplicates.

Source

pub fn assignable(&self, source: TypeId, target: TypeId) -> bool

Returns whether a value of source may be assigned where target is expected, using structural rules over the modeled type space.

Source

pub fn relation(&self, source: TypeId, target: TypeId) -> TypeRelation

Computes compatibility once while retaining every accepted unsound concession for rule consumers.

Trait Implementations§

Source§

impl Clone for TypeTable

Source§

fn clone(&self) -> TypeTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeTable

Source§

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

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

impl Default for TypeTable

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.