core: Add missing From implementations for LLVM wrapper classes

This commit is contained in:
David Mak 2024-02-20 11:57:20 +08:00
parent 49de81ef1e
commit 4efdd17513
1 changed files with 15 additions and 3 deletions

View File

@ -153,6 +153,12 @@ impl<'ctx> ListValue<'ctx> {
} }
} }
impl<'ctx> From<ListValue<'ctx>> for PointerValue<'ctx> {
fn from(value: ListValue<'ctx>) -> Self {
value.get_ptr()
}
}
/// Proxy type for accessing the `data` array of an `list` instance in LLVM. /// Proxy type for accessing the `data` array of an `list` instance in LLVM.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct ListDataProxy<'ctx>(ListValue<'ctx>); pub struct ListDataProxy<'ctx>(ListValue<'ctx>);
@ -408,6 +414,12 @@ impl<'ctx> RangeValue<'ctx> {
} }
} }
impl<'ctx> From<RangeValue<'ctx>> for PointerValue<'ctx> {
fn from(value: RangeValue<'ctx>) -> Self {
value.get_ptr()
}
}
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
pub fn assert_is_ndarray<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<'ctx>) {} pub fn assert_is_ndarray<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<'ctx>) {}
@ -595,9 +607,9 @@ impl<'ctx> NDArrayValue<'ctx> {
} }
} }
impl<'ctx> Into<PointerValue<'ctx>> for NDArrayValue<'ctx> { impl<'ctx> From<NDArrayValue<'ctx>> for PointerValue<'ctx> {
fn into(self) -> PointerValue<'ctx> { fn from(value: NDArrayValue<'ctx>) -> Self {
self.get_ptr() value.get_ptr()
} }
} }