forked from M-Labs/nac3
[meta] Reorganize order of use declarations - Phase 2
Some more rules: - For module-level imports, prefer no prefix > super > crate. - Use crate instead of super if super refers to the crate-level module
This commit is contained in:
parent
5839badadd
commit
a98f33e6d1
@ -37,7 +37,7 @@ use nac3core::{
|
|||||||
typecheck::typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap},
|
typecheck::typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{symbol_resolver::InnerResolver, timeline::TimeFns};
|
use super::{symbol_resolver::InnerResolver, timeline::TimeFns};
|
||||||
|
|
||||||
/// The parallelism mode within a block.
|
/// The parallelism mode within a block.
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
|
@ -37,7 +37,7 @@ use nac3core::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::PrimitivePythonId;
|
use super::PrimitivePythonId;
|
||||||
|
|
||||||
pub enum PrimitiveValue {
|
pub enum PrimitiveValue {
|
||||||
I32(i32),
|
I32(i32),
|
||||||
|
@ -5,8 +5,7 @@ use inkwell::{
|
|||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{
|
use super::{
|
||||||
codegen::{
|
|
||||||
classes::{
|
classes::{
|
||||||
ArrayLikeValue, NDArrayValue, ProxyValue, RangeValue, TypedArrayLikeAccessor,
|
ArrayLikeValue, NDArrayValue, ProxyValue, RangeValue, TypedArrayLikeAccessor,
|
||||||
UntypedArrayLikeAccessor, UntypedArrayLikeMutator,
|
UntypedArrayLikeAccessor, UntypedArrayLikeMutator,
|
||||||
@ -20,9 +19,9 @@ use crate::{
|
|||||||
numpy::ndarray_elementwise_unaryop_impl,
|
numpy::ndarray_elementwise_unaryop_impl,
|
||||||
stmt::gen_for_callback_incrementing,
|
stmt::gen_for_callback_incrementing,
|
||||||
CodeGenContext, CodeGenerator,
|
CodeGenContext, CodeGenerator,
|
||||||
},
|
};
|
||||||
toplevel::helper::PrimDef,
|
use crate::{
|
||||||
toplevel::numpy::unpack_ndarray_var_tys,
|
toplevel::{helper::PrimDef, numpy::unpack_ndarray_var_tys},
|
||||||
typecheck::typedef::{Type, TypeEnum},
|
typecheck::typedef::{Type, TypeEnum},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use inkwell::{
|
|||||||
AddressSpace, IntPredicate,
|
AddressSpace, IntPredicate,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::codegen::{
|
use super::{
|
||||||
irrt::{call_ndarray_calc_size, call_ndarray_flatten_index},
|
irrt::{call_ndarray_calc_size, call_ndarray_flatten_index},
|
||||||
llvm_intrinsics::call_int_umin,
|
llvm_intrinsics::call_int_umin,
|
||||||
stmt::gen_for_callback_incrementing,
|
stmt::gen_for_callback_incrementing,
|
||||||
|
@ -18,11 +18,10 @@ use nac3parser::ast::{
|
|||||||
Unaryop,
|
Unaryop,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use super::{
|
||||||
codegen::{
|
|
||||||
classes::{
|
classes::{
|
||||||
ArrayLikeIndexer, ArrayLikeValue, ListType, ListValue, NDArrayValue, ProxyType,
|
ArrayLikeIndexer, ArrayLikeValue, ListType, ListValue, NDArrayValue, ProxyType, ProxyValue,
|
||||||
ProxyValue, RangeValue, TypedArrayLikeAccessor, UntypedArrayLikeAccessor,
|
RangeValue, TypedArrayLikeAccessor, UntypedArrayLikeAccessor,
|
||||||
},
|
},
|
||||||
concrete_type::{ConcreteFuncArg, ConcreteTypeEnum, ConcreteTypeStore},
|
concrete_type::{ConcreteFuncArg, ConcreteTypeEnum, ConcreteTypeStore},
|
||||||
gen_in_range_check, get_llvm_abi_type, get_llvm_type, get_va_count_arg_name,
|
gen_in_range_check, get_llvm_abi_type, get_llvm_type, get_va_count_arg_name,
|
||||||
@ -38,7 +37,8 @@ use crate::{
|
|||||||
gen_var,
|
gen_var,
|
||||||
},
|
},
|
||||||
CodeGenContext, CodeGenTask, CodeGenerator,
|
CodeGenContext, CodeGenTask, CodeGenerator,
|
||||||
},
|
};
|
||||||
|
use crate::{
|
||||||
symbol_resolver::{SymbolValue, ValueEnum},
|
symbol_resolver::{SymbolValue, ValueEnum},
|
||||||
toplevel::{
|
toplevel::{
|
||||||
helper::PrimDef,
|
helper::PrimDef,
|
||||||
|
@ -4,7 +4,7 @@ use inkwell::{
|
|||||||
};
|
};
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
|
|
||||||
use crate::codegen::CodeGenContext;
|
use super::CodeGenContext;
|
||||||
|
|
||||||
/// Macro to generate extern function
|
/// Macro to generate extern function
|
||||||
/// Both function return type and function parameter type are `FloatValue`
|
/// Both function return type and function parameter type are `FloatValue`
|
||||||
|
@ -6,8 +6,8 @@ use inkwell::{
|
|||||||
|
|
||||||
use nac3parser::ast::{Expr, Stmt, StrRef};
|
use nac3parser::ast::{Expr, Stmt, StrRef};
|
||||||
|
|
||||||
|
use super::{bool_to_i1, bool_to_i8, classes::ArraySliceValue, expr::*, stmt::*, CodeGenContext};
|
||||||
use crate::{
|
use crate::{
|
||||||
codegen::{bool_to_i1, bool_to_i8, classes::ArraySliceValue, expr::*, stmt::*, CodeGenContext},
|
|
||||||
symbol_resolver::ValueEnum,
|
symbol_resolver::ValueEnum,
|
||||||
toplevel::{DefinitionId, TopLevelDef},
|
toplevel::{DefinitionId, TopLevelDef},
|
||||||
typecheck::typedef::{FunSignature, Type},
|
typecheck::typedef::{FunSignature, Type},
|
||||||
|
@ -7,7 +7,7 @@ use inkwell::{
|
|||||||
};
|
};
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
|
|
||||||
use crate::codegen::CodeGenContext;
|
use super::CodeGenContext;
|
||||||
|
|
||||||
/// Returns the string representation for the floating-point type `ft` when used in intrinsic
|
/// Returns the string representation for the floating-point type `ft` when used in intrinsic
|
||||||
/// functions.
|
/// functions.
|
||||||
|
@ -37,6 +37,8 @@ use crate::{
|
|||||||
typedef::{CallId, FuncArg, Type, TypeEnum, Unifier},
|
typedef::{CallId, FuncArg, Type, TypeEnum, Unifier},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use concrete_type::{ConcreteType, ConcreteTypeEnum, ConcreteTypeStore};
|
||||||
|
pub use generator::{CodeGenerator, DefaultCodeGenerator};
|
||||||
|
|
||||||
pub mod builtin_fns;
|
pub mod builtin_fns;
|
||||||
pub mod classes;
|
pub mod classes;
|
||||||
@ -52,9 +54,6 @@ pub mod stmt;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
use concrete_type::{ConcreteType, ConcreteTypeEnum, ConcreteTypeStore};
|
|
||||||
pub use generator::{CodeGenerator, DefaultCodeGenerator};
|
|
||||||
|
|
||||||
mod macros {
|
mod macros {
|
||||||
/// Codegen-variant of [`std::unreachable`] which accepts an instance of [`CodeGenContext`] as
|
/// Codegen-variant of [`std::unreachable`] which accepts an instance of [`CodeGenContext`] as
|
||||||
/// its first argument to provide Python source information to indicate the codegen location
|
/// its first argument to provide Python source information to indicate the codegen location
|
||||||
|
@ -6,8 +6,7 @@ use inkwell::{
|
|||||||
|
|
||||||
use nac3parser::ast::{Operator, StrRef};
|
use nac3parser::ast::{Operator, StrRef};
|
||||||
|
|
||||||
use crate::{
|
use super::{
|
||||||
codegen::{
|
|
||||||
classes::{
|
classes::{
|
||||||
ArrayLikeIndexer, ArrayLikeValue, ListType, ListValue, NDArrayType, NDArrayValue,
|
ArrayLikeIndexer, ArrayLikeValue, ListType, ListValue, NDArrayType, NDArrayValue,
|
||||||
ProxyType, ProxyValue, TypedArrayLikeAccessor, TypedArrayLikeAdapter,
|
ProxyType, ProxyValue, TypedArrayLikeAccessor, TypedArrayLikeAdapter,
|
||||||
@ -16,14 +15,14 @@ use crate::{
|
|||||||
expr::gen_binop_expr_with_values,
|
expr::gen_binop_expr_with_values,
|
||||||
irrt::{
|
irrt::{
|
||||||
calculate_len_for_slice_range, call_ndarray_calc_broadcast,
|
calculate_len_for_slice_range, call_ndarray_calc_broadcast,
|
||||||
call_ndarray_calc_broadcast_index, call_ndarray_calc_nd_indices,
|
call_ndarray_calc_broadcast_index, call_ndarray_calc_nd_indices, call_ndarray_calc_size,
|
||||||
call_ndarray_calc_size,
|
|
||||||
},
|
},
|
||||||
llvm_intrinsics::{self, call_memcpy_generic},
|
llvm_intrinsics::{self, call_memcpy_generic},
|
||||||
macros::codegen_unreachable,
|
macros::codegen_unreachable,
|
||||||
stmt::{gen_for_callback_incrementing, gen_for_range_callback, gen_if_else_expr_callback},
|
stmt::{gen_for_callback_incrementing, gen_for_range_callback, gen_if_else_expr_callback},
|
||||||
CodeGenContext, CodeGenerator,
|
CodeGenContext, CodeGenerator,
|
||||||
},
|
};
|
||||||
|
use crate::{
|
||||||
symbol_resolver::ValueEnum,
|
symbol_resolver::ValueEnum,
|
||||||
toplevel::{
|
toplevel::{
|
||||||
helper::PrimDef,
|
helper::PrimDef,
|
||||||
|
@ -15,13 +15,13 @@ use nac3parser::{
|
|||||||
};
|
};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
|
||||||
use crate::{
|
use super::{
|
||||||
codegen::{
|
|
||||||
classes::{ListType, NDArrayType, ProxyType, RangeType},
|
classes::{ListType, NDArrayType, ProxyType, RangeType},
|
||||||
concrete_type::ConcreteTypeStore,
|
concrete_type::ConcreteTypeStore,
|
||||||
CodeGenContext, CodeGenLLVMOptions, CodeGenTargetMachineOptions, CodeGenTask,
|
CodeGenContext, CodeGenLLVMOptions, CodeGenTargetMachineOptions, CodeGenTask, CodeGenerator,
|
||||||
CodeGenerator, DefaultCodeGenerator, WithCall, WorkerRegistry,
|
DefaultCodeGenerator, WithCall, WorkerRegistry,
|
||||||
},
|
};
|
||||||
|
use crate::{
|
||||||
symbol_resolver::{SymbolResolver, ValueEnum},
|
symbol_resolver::{SymbolResolver, ValueEnum},
|
||||||
toplevel::{
|
toplevel::{
|
||||||
composer::{ComposerConfig, TopLevelComposer},
|
composer::{ComposerConfig, TopLevelComposer},
|
||||||
|
@ -11,7 +11,8 @@ use itertools::Either;
|
|||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
helper::{debug_assert_prim_is_allowed, make_exception_fields, PrimDefDetails},
|
helper::{debug_assert_prim_is_allowed, make_exception_fields, PrimDef, PrimDefDetails},
|
||||||
|
numpy::make_ndarray_ty,
|
||||||
*,
|
*,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -22,7 +23,6 @@ use crate::{
|
|||||||
stmt::exn_constructor,
|
stmt::exn_constructor,
|
||||||
},
|
},
|
||||||
symbol_resolver::SymbolValue,
|
symbol_resolver::SymbolValue,
|
||||||
toplevel::{helper::PrimDef, numpy::make_ndarray_ty},
|
|
||||||
typecheck::typedef::{into_var_map, iter_type_vars, TypeVar, VarMap},
|
typecheck::typedef::{into_var_map, iter_type_vars, TypeVar, VarMap},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,13 +3,11 @@ use std::convert::TryInto;
|
|||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
use strum_macros::EnumIter;
|
use strum_macros::EnumIter;
|
||||||
|
|
||||||
use ast::ExprKind;
|
use nac3parser::ast::{Constant, ExprKind, Location};
|
||||||
use nac3parser::ast::{Constant, Location};
|
|
||||||
|
|
||||||
use super::*;
|
use super::{numpy::unpack_ndarray_var_tys, *};
|
||||||
use crate::{
|
use crate::{
|
||||||
symbol_resolver::SymbolValue,
|
symbol_resolver::SymbolValue,
|
||||||
toplevel::numpy::unpack_ndarray_var_tys,
|
|
||||||
typecheck::typedef::{into_var_map, iter_type_vars, Mapping, TypeVarId, VarMap},
|
typecheck::typedef::{into_var_map, iter_type_vars, Mapping, TypeVarId, VarMap},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,19 +23,19 @@ use crate::{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use composer::*;
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug)]
|
use type_annotation::*;
|
||||||
pub struct DefinitionId(pub usize);
|
|
||||||
|
|
||||||
pub mod builtins;
|
pub mod builtins;
|
||||||
pub mod composer;
|
pub mod composer;
|
||||||
pub mod helper;
|
pub mod helper;
|
||||||
pub mod numpy;
|
pub mod numpy;
|
||||||
pub mod type_annotation;
|
|
||||||
use composer::*;
|
|
||||||
use type_annotation::*;
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
pub mod type_annotation;
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug)]
|
||||||
|
pub struct DefinitionId(pub usize);
|
||||||
|
|
||||||
type GenCallCallback = dyn for<'ctx, 'a> Fn(
|
type GenCallCallback = dyn for<'ctx, 'a> Fn(
|
||||||
&mut CodeGenContext<'ctx, 'a>,
|
&mut CodeGenContext<'ctx, 'a>,
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{
|
use super::helper::PrimDef;
|
||||||
toplevel::helper::PrimDef,
|
use crate::typecheck::{
|
||||||
typecheck::{
|
|
||||||
type_inferencer::PrimitiveStore,
|
type_inferencer::PrimitiveStore,
|
||||||
typedef::{Type, TypeEnum, TypeVarId, Unifier, VarMap},
|
typedef::{Type, TypeEnum, TypeVarId, Unifier, VarMap},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Creates a `ndarray` [`Type`] with the given type arguments.
|
/// Creates a `ndarray` [`Type`] with the given type arguments.
|
||||||
|
@ -9,11 +9,10 @@ use nac3parser::{
|
|||||||
parser::parse_program,
|
parser::parse_program,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::{helper::PrimDef, DefinitionId, *};
|
||||||
use crate::{
|
use crate::{
|
||||||
codegen::CodeGenContext,
|
codegen::CodeGenContext,
|
||||||
symbol_resolver::{SymbolResolver, ValueEnum},
|
symbol_resolver::{SymbolResolver, ValueEnum},
|
||||||
toplevel::{helper::PrimDef, DefinitionId},
|
|
||||||
typecheck::{
|
typecheck::{
|
||||||
type_inferencer::PrimitiveStore,
|
type_inferencer::PrimitiveStore,
|
||||||
typedef::{into_var_map, Type, Unifier},
|
typedef::{into_var_map, Type, Unifier},
|
||||||
|
@ -2,12 +2,11 @@ use strum::IntoEnumIterator;
|
|||||||
|
|
||||||
use nac3parser::ast::Constant;
|
use nac3parser::ast::Constant;
|
||||||
|
|
||||||
use super::*;
|
use super::{
|
||||||
use crate::{
|
helper::{PrimDef, PrimDefDetails},
|
||||||
symbol_resolver::SymbolValue,
|
*,
|
||||||
toplevel::helper::{PrimDef, PrimDefDetails},
|
|
||||||
typecheck::typedef::VarMap,
|
|
||||||
};
|
};
|
||||||
|
use crate::{symbol_resolver::SymbolValue, typecheck::typedef::VarMap};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum TypeAnnotation {
|
pub enum TypeAnnotation {
|
||||||
|
@ -5,16 +5,16 @@ use strum::IntoEnumIterator;
|
|||||||
|
|
||||||
use nac3parser::ast::{Cmpop, Operator, StrRef, Unaryop};
|
use nac3parser::ast::{Cmpop, Operator, StrRef, Unaryop};
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
type_inferencer::*,
|
||||||
|
typedef::{FunSignature, FuncArg, Type, TypeEnum, Unifier, VarMap},
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
symbol_resolver::SymbolValue,
|
symbol_resolver::SymbolValue,
|
||||||
toplevel::{
|
toplevel::{
|
||||||
helper::PrimDef,
|
helper::PrimDef,
|
||||||
numpy::{make_ndarray_ty, unpack_ndarray_var_tys},
|
numpy::{make_ndarray_ty, unpack_ndarray_var_tys},
|
||||||
},
|
},
|
||||||
typecheck::{
|
|
||||||
type_inferencer::*,
|
|
||||||
typedef::{FunSignature, FuncArg, Type, TypeEnum, Unifier, VarMap},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The variant of a binary operator.
|
/// The variant of a binary operator.
|
||||||
|
@ -5,10 +5,9 @@ use itertools::Itertools;
|
|||||||
use nac3parser::ast::{Cmpop, Location, StrRef};
|
use nac3parser::ast::{Cmpop, Location, StrRef};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
magic_methods::Binop,
|
magic_methods::{Binop, HasOpInfo},
|
||||||
typedef::{RecordKey, Type, Unifier},
|
typedef::{RecordKey, Type, TypeEnum, Unifier},
|
||||||
};
|
};
|
||||||
use crate::typecheck::{magic_methods::HasOpInfo, typedef::TypeEnum};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TypeErrorKind {
|
pub enum TypeErrorKind {
|
||||||
|
@ -14,14 +14,14 @@ use itertools::{repeat_n, Itertools};
|
|||||||
use nac3parser::ast::{Cmpop, Location, StrRef, Unaryop};
|
use nac3parser::ast::{Cmpop, Location, StrRef, Unaryop};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
magic_methods::{Binop, HasOpInfo},
|
magic_methods::{Binop, HasOpInfo, OpInfo},
|
||||||
type_error::{TypeError, TypeErrorKind},
|
type_error::{TypeError, TypeErrorKind},
|
||||||
|
type_inferencer::PrimitiveStore,
|
||||||
unification_table::{UnificationKey, UnificationTable},
|
unification_table::{UnificationKey, UnificationTable},
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
symbol_resolver::SymbolValue,
|
symbol_resolver::SymbolValue,
|
||||||
toplevel::{helper::PrimDef, DefinitionId, TopLevelContext, TopLevelDef},
|
toplevel::{helper::PrimDef, DefinitionId, TopLevelContext, TopLevelDef},
|
||||||
typecheck::{magic_methods::OpInfo, type_inferencer::PrimitiveStore},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -45,9 +45,10 @@ use nac3core::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod basic_symbol_resolver;
|
|
||||||
use basic_symbol_resolver::*;
|
use basic_symbol_resolver::*;
|
||||||
|
|
||||||
|
mod basic_symbol_resolver;
|
||||||
|
|
||||||
/// Command-line argument parser definition.
|
/// Command-line argument parser definition.
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
|
Loading…
Reference in New Issue
Block a user