Struct debris_llir::type_context::TypeContext
source · pub struct TypeContext {
cache: RefCell<FxHashMap<TypeId, ClassRef>>,
null: OnceCell<ObjectRef>,
never: OnceCell<ObjectRef>,
}
Expand description
Caches all classes. Could maybe be used as an arena in the future in cases the Rc design is not fast enough. TODO: Right now the stored classes create cycles which lead to memory leaks. This should be fixed quickly.
Fields§
§cache: RefCell<FxHashMap<TypeId, ClassRef>>
Cache for classes
The key is the type of the Payload Struct.
null: OnceCell<ObjectRef>
The null singleton
never: OnceCell<ObjectRef>
The never singleton
Implementations§
source§impl TypeContext
impl TypeContext
pub fn null(&self) -> ObjectRef
pub fn never(&self) -> ObjectRef
sourcepub fn static_class_obj<T: ObjectPayload>(&self) -> ObjectRef
pub fn static_class_obj<T: ObjectPayload>(&self) -> ObjectRef
Returns an object ref to the static class of the given type
pub fn get<T: ObjectPayload>(&self) -> Option<ClassRef>
pub fn insert<T: ObjectPayload>(&self, class: ClassRef)
Trait Implementations§
source§impl Debug for TypeContext
impl Debug for TypeContext
source§impl Default for TypeContext
impl Default for TypeContext
source§fn default() -> TypeContext
fn default() -> TypeContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TypeContext
impl !Send for TypeContext
impl !Sync for TypeContext
impl Unpin for TypeContext
impl !UnwindSafe for TypeContext
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