pub struct DefinitionStore { /* private fields */ }Expand description
Thread-safe storage for type definitions.
Uses DashMap for concurrent access from multiple checking threads.
§Usage
let store = DefinitionStore::new();
// Register a type alias
let def_id = store.register(DefinitionInfo::type_alias(
interner.intern_string("Foo"),
vec![],
TypeId::NUMBER,
));
// Look up later
let info = store.get(def_id).expect("definition exists");Implementations§
Source§impl DefinitionStore
impl DefinitionStore
Sourcepub fn register(&self, info: DefinitionInfo) -> DefId
pub fn register(&self, info: DefinitionInfo) -> DefId
Register a new definition and return its DefId.
Sourcepub fn get(&self, id: DefId) -> Option<DefinitionInfo>
pub fn get(&self, id: DefId) -> Option<DefinitionInfo>
Get definition info by DefId.
Sourcepub fn get_symbol_id(&self, id: DefId) -> Option<u32>
pub fn get_symbol_id(&self, id: DefId) -> Option<u32>
Get the binder SymbolId for a DefId.
Returns the SymbolId (as raw u32) that this DefId was created from.
This is available across checker contexts because it’s stored directly
in the DefinitionInfo (which is shared via DefinitionStore).
Sourcepub fn get_type_params(&self, id: DefId) -> Option<Vec<TypeParamInfo>>
pub fn get_type_params(&self, id: DefId) -> Option<Vec<TypeParamInfo>>
Get type parameters for a definition.
Sourcepub fn get_instance_shape(&self, id: DefId) -> Option<Arc<ObjectShape>>
pub fn get_instance_shape(&self, id: DefId) -> Option<Arc<ObjectShape>>
Get the instance shape for a class/interface.
Sourcepub fn get_static_shape(&self, id: DefId) -> Option<Arc<ObjectShape>>
pub fn get_static_shape(&self, id: DefId) -> Option<Arc<ObjectShape>>
Get the static shape for a class.
Sourcepub fn get_extends(&self, id: DefId) -> Option<DefId>
pub fn get_extends(&self, id: DefId) -> Option<DefId>
Get parent class DefId for a class.
Sourcepub fn get_implements(&self, id: DefId) -> Option<Vec<DefId>>
pub fn get_implements(&self, id: DefId) -> Option<Vec<DefId>>
Get implemented interfaces for a class/interface.
Sourcepub fn set_body(&self, id: DefId, body: TypeId)
pub fn set_body(&self, id: DefId, body: TypeId)
Update the body TypeId for a definition (for lazy evaluation).
Sourcepub fn set_instance_shape(&self, id: DefId, shape: Arc<ObjectShape>)
pub fn set_instance_shape(&self, id: DefId, shape: Arc<ObjectShape>)
Update the instance shape for a type definition.
This is used by checker code when a concrete object-like shape is computed for an interface/class definition and should be recorded for diagnostics.
Sourcepub fn get_exports(&self, id: DefId) -> Option<Vec<(Atom, DefId)>>
pub fn get_exports(&self, id: DefId) -> Option<Vec<(Atom, DefId)>>
Get exports for a namespace/module DefId.
Sourcepub fn get_enum_members(
&self,
id: DefId,
) -> Option<Vec<(Atom, EnumMemberValue)>>
pub fn get_enum_members( &self, id: DefId, ) -> Option<Vec<(Atom, EnumMemberValue)>>
Get enum members for an enum DefId.
Sourcepub fn set_exports(&self, id: DefId, exports: Vec<(Atom, DefId)>)
pub fn set_exports(&self, id: DefId, exports: Vec<(Atom, DefId)>)
Update exports for a definition (for lazy population).
Sourcepub fn add_export(&self, id: DefId, name: Atom, export_def: DefId)
pub fn add_export(&self, id: DefId, name: Atom, export_def: DefId)
Add an export to an existing definition.
Sourcepub fn set_enum_members(&self, id: DefId, members: Vec<(Atom, EnumMemberValue)>)
pub fn set_enum_members(&self, id: DefId, members: Vec<(Atom, EnumMemberValue)>)
Update enum members for a definition (for lazy population).
Sourcepub fn find_def_by_shape(&self, shape: &ObjectShape) -> Option<DefId>
pub fn find_def_by_shape(&self, shape: &ObjectShape) -> Option<DefId>
Find a DefId by its instance shape.
This is used by the TypeFormatter to preserve interface names in error messages.
When an Object type matches an interface’s instance shape, we use the interface name
instead of expanding the object literal.