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
impl TypeTable
pub const fn error_type(&self) -> TypeId
pub const fn any(&self) -> TypeId
pub const fn unknown(&self) -> TypeId
pub const fn never(&self) -> TypeId
pub const fn void(&self) -> TypeId
pub const fn null_type(&self) -> TypeId
pub const fn undefined_type(&self) -> TypeId
pub const fn boolean(&self) -> TypeId
pub const fn number(&self) -> TypeId
pub const fn bigint(&self) -> TypeId
pub const fn string(&self) -> TypeId
pub const fn symbol_type(&self) -> TypeId
pub const fn object(&self) -> TypeId
Sourcepub fn boolean_literal(&mut self, value: bool) -> TypeId
pub fn boolean_literal(&mut self, value: bool) -> TypeId
Interns a boolean literal type.
Sourcepub fn number_literal(&mut self, text: &str) -> TypeId
pub fn number_literal(&mut self, text: &str) -> TypeId
Interns a numeric literal type keyed by its source lexeme.
Sourcepub fn string_literal(&mut self, text: &str) -> TypeId
pub fn string_literal(&mut self, text: &str) -> TypeId
Interns a string literal type keyed by its source lexeme.
Sourcepub fn bigint_literal(&mut self, text: &str) -> TypeId
pub fn bigint_literal(&mut self, text: &str) -> TypeId
Interns a bigint literal type keyed by its source lexeme.
Sourcepub fn numeric_enum(&mut self, symbol: SymbolId) -> TypeId
pub fn numeric_enum(&mut self, symbol: SymbolId) -> TypeId
Interns a numeric enum value type.
Sourcepub fn object_type(&mut self, properties: Vec<PropertyType>) -> TypeId
pub fn object_type(&mut self, properties: Vec<PropertyType>) -> TypeId
Interns an object type after canonically ordering its members by name.
Sourcepub fn function(
&mut self,
parameters: Vec<TypeId>,
return_type: TypeId,
) -> TypeId
pub fn function( &mut self, parameters: Vec<TypeId>, return_type: TypeId, ) -> TypeId
Interns a function type.
Sourcepub fn union(&mut self, members: &[TypeId]) -> TypeId
pub fn union(&mut self, members: &[TypeId]) -> TypeId
Interns a union, normalizing absorption, never removal, and duplicates.
Sourcepub fn assignable(&self, source: TypeId, target: TypeId) -> bool
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.
Sourcepub fn relation(&self, source: TypeId, target: TypeId) -> TypeRelation
pub fn relation(&self, source: TypeId, target: TypeId) -> TypeRelation
Computes compatibility once while retaining every accepted unsound concession for rule consumers.