forked from swgillespie/gccjit.rs
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
In gccjit, a lot of objects inherit (in the C++ meaning) from one or more parents, which is not reflected in this crate. For example, LValue should have access to all RValue methods since it inherits from it.
We could make the implementation as such:
impl RValueTrait {
fn get_type(&self) -> Type<'ctx> {
get_rvalue_type(self)
}
fn as_rvalue(&self) -> RValue<'tcx>; // la seule methode a implem
}
fn get_rvalue_type<T: RValueTrait>(t: &T) -> Type<'tcx> {
t.as_rvalue().get_type()
}
impl RValueTrait for LValue {
fn as_rvalue(&self) -> RValue<'ctx> {
gcc_jit_lvalue_as_rvalue(self.ptr)
}
}It has the advantage that the logic is only in one place and all objects inheriting from RValue can just implement the trait and the as_rvalue method to have access to all its methods.
Waiting for @antoyo approval before making the implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels