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