From 4efdd17513011f4242f901aeaf39e9ea364450f9 Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 20 Feb 2024 11:57:20 +0800 Subject: [PATCH] core: Add missing From implementations for LLVM wrapper classes --- nac3core/src/codegen/classes.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nac3core/src/codegen/classes.rs b/nac3core/src/codegen/classes.rs index 347f84c41..4394ce027 100644 --- a/nac3core/src/codegen/classes.rs +++ b/nac3core/src/codegen/classes.rs @@ -153,6 +153,12 @@ impl<'ctx> ListValue<'ctx> { } } +impl<'ctx> From> 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. #[derive(Copy, Clone)] pub struct ListDataProxy<'ctx>(ListValue<'ctx>); @@ -408,6 +414,12 @@ impl<'ctx> RangeValue<'ctx> { } } +impl<'ctx> From> for PointerValue<'ctx> { + fn from(value: RangeValue<'ctx>) -> Self { + value.get_ptr() + } +} + #[cfg(not(debug_assertions))] pub fn assert_is_ndarray<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<'ctx>) {} @@ -595,9 +607,9 @@ impl<'ctx> NDArrayValue<'ctx> { } } -impl<'ctx> Into> for NDArrayValue<'ctx> { - fn into(self) -> PointerValue<'ctx> { - self.get_ptr() +impl<'ctx> From> for PointerValue<'ctx> { + fn from(value: NDArrayValue<'ctx>) -> Self { + value.get_ptr() } }