From 02e3ddfce6113bd8d171464fee4b0c3efe21f7a6 Mon Sep 17 00:00:00 2001 From: lyken Date: Fri, 26 Jul 2024 15:45:26 +0800 Subject: [PATCH] core: make get_llvm_type return new NDArray with strides NOTE: All old numpy functions are now impossible to run, until NDArray with strides is fully implemented. --- nac3core/src/codegen/mod.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index c78710a8..432073ae 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -1,7 +1,7 @@ use crate::{ - codegen::classes::{ListType, NDArrayType, ProxyType, RangeType}, + codegen::classes::{ListType, ProxyType, RangeType}, symbol_resolver::{StaticValue, SymbolResolver}, - toplevel::{helper::PrimDef, numpy::unpack_ndarray_var_tys, TopLevelContext, TopLevelDef}, + toplevel::{helper::PrimDef, TopLevelContext, TopLevelDef}, typecheck::{ type_inferencer::{CodeLocation, PrimitiveStore}, typedef::{CallId, FuncArg, Type, TypeEnum, Unifier}, @@ -33,7 +33,7 @@ use std::sync::{ Arc, }; use std::thread; -use structure::{cslice::CSlice, exception::Exception}; +use structure::{cslice::CSlice, exception::Exception, ndarray::NpArray}; pub mod builtin_fns; pub mod classes; @@ -494,12 +494,9 @@ fn get_llvm_type<'ctx, G: CodeGenerator + ?Sized>( } TObj { obj_id, .. } if *obj_id == PrimDef::NDArray.id() => { - let (dtype, _) = unpack_ndarray_var_tys(unifier, ty); - let element_type = get_llvm_type( - ctx, module, generator, unifier, top_level, type_cache, dtype, - ); - - NDArrayType::new(generator, ctx, element_type).as_base_type().into() + let tyctx = generator.type_context(ctx); + let pndarray_model = PtrModel(StructModel(NpArray)); + pndarray_model.get_type(tyctx, ctx).into() } _ => unreachable!(