Struct debris_llir::DebrisObject
source · pub struct DebrisObject<T: ObjectPayload + ?Sized> {
pub class: ClassRef,
pub payload: T,
}
Expand description
Objects are a central type for the compiler.
Basically anything that can be assigned to a variable is an object.
This includes numbers, function, modules, and more.
It is possible to cast the ObjectPayload
to its original value.
Because DebrisObject
is unsized, it generally only accessed as ObjectRef
Fields§
§class: ClassRef
The class of the object
payload: T
The actual value
Implementations§
source§impl DebrisObject<dyn ObjectPayload>
impl DebrisObject<dyn ObjectPayload>
sourcepub fn get_property(
&self,
ctx: &TypeContext,
ident: &Ident
) -> Option<ObjectRef>
pub fn get_property( &self, ctx: &TypeContext, ident: &Ident ) -> Option<ObjectRef>
Tries to get a property that belongs to this object
First tries to retrieve the property from its payload. If that fails, tries to retrieve the property from its class.
sourcepub fn downcast_payload<T: ObjectPayload>(&self) -> Option<&T>
pub fn downcast_payload<T: ObjectPayload>(&self) -> Option<&T>
Converts the payload into its original type
Returns None if the downcast is not possible
sourcepub fn downcast_class(&self) -> Option<ClassRef>
pub fn downcast_class(&self) -> Option<ClassRef>
Helper function for downcasting the payload into a class
Trait Implementations§
source§impl Debug for DebrisObject<dyn ObjectPayload>
impl Debug for DebrisObject<dyn ObjectPayload>
source§impl<T: ObjectPayload> From<DebrisObject<T>> for ObjectRef
impl<T: ObjectPayload> From<DebrisObject<T>> for ObjectRef
source§fn from(object: DebrisObject<T>) -> Self
fn from(object: DebrisObject<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DebrisObject<T>
impl<T> !Send for DebrisObject<T>
impl<T> !Sync for DebrisObject<T>
impl<T: ?Sized> Unpin for DebrisObject<T>where T: Unpin,
impl<T> !UnwindSafe for DebrisObject<T>
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