pub struct TypeRegistry {
types: HashMap<TypeId, TypeInfo>,
function_type_cache: HashMap<FunctionType, TypeId>,
}
Expand description
Registry that stores all available types in the language
Fields§
§types: HashMap<TypeId, TypeInfo>
Map from TypeId to TypeInfo
function_type_cache: HashMap<FunctionType, TypeId>
Map from function signatures to TypeIds for fast function type deduplication
Implementations§
Source§impl TypeRegistry
impl TypeRegistry
Sourcepub fn new_instance() -> Self
pub fn new_instance() -> Self
Creates a new TypeRegistry with built-in types registered.
Sourcefn register_built_in_types(&mut self)
fn register_built_in_types(&mut self)
Registers all built-in types in the type registry
Sourcepub fn register_type(&mut self, name: &str, kind: TypeKind) -> TypeId
pub fn register_type(&mut self, name: &str, kind: TypeKind) -> TypeId
Sourcefn register_primitive_type(&mut self, name: &str, kind: TypeKind, id: TypeId)
fn register_primitive_type(&mut self, name: &str, kind: TypeKind, id: TypeId)
Registers a primitive type in the registry
§Arguments
name
- The name of the primitive typekind
- The kind of the primitive type (e.g., Integer, Float, etc.)id
- The TypeId for the primitive type
Sourcepub fn get_type_info(&self, id: &TypeId) -> Option<&TypeInfo>
pub fn get_type_info(&self, id: &TypeId) -> Option<&TypeInfo>
Sourcepub fn get_primitive_type(&self, id: &TypeId) -> Option<PrimitiveType>
pub fn get_primitive_type(&self, id: &TypeId) -> Option<PrimitiveType>
Sourcepub fn is_primitive_type(&self, id: &TypeId) -> bool
pub fn is_primitive_type(&self, id: &TypeId) -> bool
Sourcepub fn check_value_in_range(&self, value: &i64, type_id: &TypeId) -> bool
pub fn check_value_in_range(&self, value: &i64, type_id: &TypeId) -> bool
Sourcepub fn check_float_value_in_range(&self, value: &f64, type_id: &TypeId) -> bool
pub fn check_float_value_in_range(&self, value: &f64, type_id: &TypeId) -> bool
Sourcepub fn register_function_type(
&mut self,
param_types: Vec<TypeId>,
return_type: TypeId,
) -> TypeId
pub fn register_function_type( &mut self, param_types: Vec<TypeId>, return_type: TypeId, ) -> TypeId
Sourcepub fn is_function_type(&self, id: &TypeId) -> bool
pub fn is_function_type(&self, id: &TypeId) -> bool
Sourcepub fn get_function_type(&self, id: &TypeId) -> Option<&FunctionType>
pub fn get_function_type(&self, id: &TypeId) -> Option<&FunctionType>
Auto Trait Implementations§
impl Freeze for TypeRegistry
impl RefUnwindSafe for TypeRegistry
impl Send for TypeRegistry
impl Sync for TypeRegistry
impl Unpin for TypeRegistry
impl UnwindSafe for TypeRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more