forked from M-Labs/nac3
1
0
Fork 0

core: Simplify typed value assertions

This commit is contained in:
David Mak 2024-03-19 18:22:41 +08:00
parent cfbc37c1ed
commit e980f19c93
1 changed files with 3 additions and 9 deletions

View File

@ -16,9 +16,7 @@ pub fn assert_is_list<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<'ct
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
pub fn assert_is_list<'ctx>(value: PointerValue<'ctx>, llvm_usize: IntType<'ctx>) { pub fn assert_is_list<'ctx>(value: PointerValue<'ctx>, llvm_usize: IntType<'ctx>) {
if let Err(msg) = ListValue::is_instance(value, llvm_usize) { ListValue::is_instance(value, llvm_usize).unwrap();
panic!("{msg}")
}
} }
/// Proxy type for accessing a `list` value in LLVM. /// Proxy type for accessing a `list` value in LLVM.
@ -254,9 +252,7 @@ pub fn assert_is_range(_value: PointerValue) {}
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
pub fn assert_is_range(value: PointerValue) { pub fn assert_is_range(value: PointerValue) {
if let Err(msg) = RangeValue::is_instance(value) { RangeValue::is_instance(value).unwrap();
panic!("{msg}")
}
} }
/// Proxy type for accessing a `range` value in LLVM. /// Proxy type for accessing a `range` value in LLVM.
@ -425,9 +421,7 @@ pub fn assert_is_ndarray<'ctx>(_value: PointerValue<'ctx>, _llvm_usize: IntType<
#[cfg(debug_assertions)] #[cfg(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>) {
if let Err(msg) = NDArrayValue::is_instance(value, llvm_usize) { NDArrayValue::is_instance(value, llvm_usize).unwrap();
panic!("{msg}")
}
} }
/// Proxy type for accessing an `NDArray` value in LLVM. /// Proxy type for accessing an `NDArray` value in LLVM.