forked from M-Labs/nac3
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
use crate::codegen::{
|
|
CodeGenContext, CodeGenerator,
|
|
expr::infer_and_call_function,
|
|
irrt::get_usize_dependent_function_name,
|
|
values::{ArrayLikeValue, ArraySliceValue, ProxyValue, ndarray::NDArrayValue},
|
|
};
|
|
|
|
/// Generates a call to `__nac3_ndarray_index`.
|
|
///
|
|
/// Performs [basic indexing](https://numpy.org/doc/stable/user/basics.indexing.html#basic-indexing)
|
|
/// on `src_ndarray` using `indices`, writing the result to `dst_ndarray`, corresponding to the
|
|
/// operation `dst_ndarray = src_ndarray[indices]`.
|
|
pub fn call_nac3_ndarray_index<'ctx, G: CodeGenerator + ?Sized>(
|
|
generator: &G,
|
|
ctx: &CodeGenContext<'ctx, '_>,
|
|
indices: ArraySliceValue<'ctx>,
|
|
src_ndarray: NDArrayValue<'ctx>,
|
|
dst_ndarray: NDArrayValue<'ctx>,
|
|
) {
|
|
let name = get_usize_dependent_function_name(ctx, "__nac3_ndarray_index");
|
|
infer_and_call_function(
|
|
ctx,
|
|
&name,
|
|
None,
|
|
&[
|
|
indices.size(ctx, generator).into(),
|
|
indices.base_ptr(ctx, generator).into(),
|
|
src_ndarray.as_abi_value(ctx).into(),
|
|
dst_ndarray.as_abi_value(ctx).into(),
|
|
],
|
|
None,
|
|
None,
|
|
);
|
|
}
|