From eb4b8816902ff023c051a865863d5607a2cacab7 Mon Sep 17 00:00:00 2001 From: David Mak <chmakac@connect.ust.hk> Date: Thu, 12 Dec 2024 11:30:14 +0800 Subject: [PATCH] [core] Expose {types,values}::ndarray modules Allows better encapsulation of members in these modules rather than allowing them to leak into types/values mod. --- nac3artiq/src/codegen.rs | 6 +++--- nac3artiq/src/symbol_resolver.rs | 2 +- nac3core/src/codegen/builtin_fns.rs | 2 +- nac3core/src/codegen/expr.rs | 2 +- nac3core/src/codegen/irrt/ndarray.rs | 4 ++-- nac3core/src/codegen/mod.rs | 2 +- nac3core/src/codegen/numpy.rs | 4 ++-- nac3core/src/codegen/test.rs | 2 +- nac3core/src/codegen/types/mod.rs | 3 +-- nac3core/src/codegen/types/ndarray/mod.rs | 2 +- nac3core/src/codegen/values/mod.rs | 3 +-- nac3core/src/codegen/values/ndarray/mod.rs | 2 +- 12 files changed, 16 insertions(+), 18 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 6340eb90..c01933d6 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -18,10 +18,10 @@ use nac3core::{ irrt::ndarray::call_ndarray_calc_size, llvm_intrinsics::{call_int_smax, call_memcpy_generic, call_stackrestore, call_stacksave}, stmt::{gen_block, gen_for_callback_incrementing, gen_if_callback, gen_with}, - types::NDArrayType, + types::ndarray::NDArrayType, values::{ - ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, ListValue, NDArrayValue, ProxyValue, - RangeValue, UntypedArrayLikeAccessor, + ndarray::NDArrayValue, ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, ListValue, + ProxyValue, RangeValue, UntypedArrayLikeAccessor, }, CodeGenContext, CodeGenerator, }, diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index f4509fe1..d3d3d08d 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -15,7 +15,7 @@ use pyo3::{ use nac3core::{ codegen::{ - types::{NDArrayType, ProxyType}, + types::{ndarray::NDArrayType, ProxyType}, CodeGenContext, CodeGenerator, }, inkwell::{ diff --git a/nac3core/src/codegen/builtin_fns.rs b/nac3core/src/codegen/builtin_fns.rs index f29a49ea..70a057c2 100644 --- a/nac3core/src/codegen/builtin_fns.rs +++ b/nac3core/src/codegen/builtin_fns.rs @@ -15,7 +15,7 @@ use super::{ numpy::ndarray_elementwise_unaryop_impl, stmt::gen_for_callback_incrementing, values::{ - ArrayLikeValue, NDArrayValue, ProxyValue, RangeValue, TypedArrayLikeAccessor, + ndarray::NDArrayValue, ArrayLikeValue, ProxyValue, RangeValue, TypedArrayLikeAccessor, UntypedArrayLikeAccessor, UntypedArrayLikeMutator, }, CodeGenContext, CodeGenerator, diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 7e69e4d8..618a139f 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -34,7 +34,7 @@ use super::{ }, types::ListType, values::{ - ArrayLikeIndexer, ArrayLikeValue, ListValue, NDArrayValue, ProxyValue, RangeValue, + ndarray::NDArrayValue, ArrayLikeIndexer, ArrayLikeValue, ListValue, ProxyValue, RangeValue, TypedArrayLikeAccessor, UntypedArrayLikeAccessor, }, CodeGenContext, CodeGenTask, CodeGenerator, diff --git a/nac3core/src/codegen/irrt/ndarray.rs b/nac3core/src/codegen/irrt/ndarray.rs index 541c1175..cc3a5ffd 100644 --- a/nac3core/src/codegen/irrt/ndarray.rs +++ b/nac3core/src/codegen/irrt/ndarray.rs @@ -10,8 +10,8 @@ use crate::codegen::{ macros::codegen_unreachable, stmt::gen_for_callback_incrementing, values::{ - ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, NDArrayValue, TypedArrayLikeAccessor, - TypedArrayLikeAdapter, UntypedArrayLikeAccessor, + ndarray::NDArrayValue, ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, + TypedArrayLikeAccessor, TypedArrayLikeAdapter, UntypedArrayLikeAccessor, }, CodeGenContext, CodeGenerator, }; diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index b2bb5ad5..82514841 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -38,7 +38,7 @@ use crate::{ }; use concrete_type::{ConcreteType, ConcreteTypeEnum, ConcreteTypeStore}; pub use generator::{CodeGenerator, DefaultCodeGenerator}; -use types::{ListType, NDArrayType, ProxyType, RangeType}; +use types::{ndarray::NDArrayType, ListType, ProxyType, RangeType}; pub mod builtin_fns; pub mod concrete_type; diff --git a/nac3core/src/codegen/numpy.rs b/nac3core/src/codegen/numpy.rs index ddaa5154..94a49e51 100644 --- a/nac3core/src/codegen/numpy.rs +++ b/nac3core/src/codegen/numpy.rs @@ -18,9 +18,9 @@ use super::{ llvm_intrinsics::{self, call_memcpy_generic}, macros::codegen_unreachable, stmt::{gen_for_callback_incrementing, gen_for_range_callback, gen_if_else_expr_callback}, - types::{ListType, NDArrayType, ProxyType}, + types::{ndarray::NDArrayType, ListType, ProxyType}, values::{ - ArrayLikeIndexer, ArrayLikeValue, ListValue, NDArrayValue, ProxyValue, + ndarray::NDArrayValue, ArrayLikeIndexer, ArrayLikeValue, ListValue, ProxyValue, TypedArrayLikeAccessor, TypedArrayLikeAdapter, TypedArrayLikeMutator, UntypedArrayLikeAccessor, UntypedArrayLikeMutator, }, diff --git a/nac3core/src/codegen/test.rs b/nac3core/src/codegen/test.rs index a1c391a7..aeb0616e 100644 --- a/nac3core/src/codegen/test.rs +++ b/nac3core/src/codegen/test.rs @@ -17,7 +17,7 @@ use parking_lot::RwLock; use super::{ concrete_type::ConcreteTypeStore, - types::{ListType, NDArrayType, ProxyType, RangeType}, + types::{ndarray::NDArrayType, ListType, ProxyType, RangeType}, CodeGenContext, CodeGenLLVMOptions, CodeGenTargetMachineOptions, CodeGenTask, CodeGenerator, DefaultCodeGenerator, WithCall, WorkerRegistry, }; diff --git a/nac3core/src/codegen/types/mod.rs b/nac3core/src/codegen/types/mod.rs index 517a682f..06baaa7b 100644 --- a/nac3core/src/codegen/types/mod.rs +++ b/nac3core/src/codegen/types/mod.rs @@ -23,11 +23,10 @@ use super::{ {CodeGenContext, CodeGenerator}, }; pub use list::*; -pub use ndarray::*; pub use range::*; mod list; -mod ndarray; +pub mod ndarray; mod range; pub mod structure; diff --git a/nac3core/src/codegen/types/ndarray/mod.rs b/nac3core/src/codegen/types/ndarray/mod.rs index 307e67c3..794cb6cf 100644 --- a/nac3core/src/codegen/types/ndarray/mod.rs +++ b/nac3core/src/codegen/types/ndarray/mod.rs @@ -13,7 +13,7 @@ use super::{ ProxyType, }; use crate::codegen::{ - values::{ArraySliceValue, NDArrayValue, ProxyValue}, + values::{ndarray::NDArrayValue, ArraySliceValue, ProxyValue}, {CodeGenContext, CodeGenerator}, }; diff --git a/nac3core/src/codegen/values/mod.rs b/nac3core/src/codegen/values/mod.rs index 29f534e4..b8bba4e6 100644 --- a/nac3core/src/codegen/values/mod.rs +++ b/nac3core/src/codegen/values/mod.rs @@ -4,12 +4,11 @@ use super::types::ProxyType; use crate::codegen::CodeGenerator; pub use array::*; pub use list::*; -pub use ndarray::*; pub use range::*; mod array; mod list; -mod ndarray; +pub mod ndarray; mod range; /// A LLVM type that is used to represent a non-primitive value in NAC3. diff --git a/nac3core/src/codegen/values/ndarray/mod.rs b/nac3core/src/codegen/values/ndarray/mod.rs index 2583d45f..617494e3 100644 --- a/nac3core/src/codegen/values/ndarray/mod.rs +++ b/nac3core/src/codegen/values/ndarray/mod.rs @@ -12,7 +12,7 @@ use crate::codegen::{ irrt, llvm_intrinsics::call_int_umin, stmt::gen_for_callback_incrementing, - types::{structure::StructField, NDArrayType}, + types::{ndarray::NDArrayType, structure::StructField}, CodeGenContext, CodeGenerator, };