[meta] Minor simplification for PrimStore extraction

This commit is contained in:
David Mak 2025-02-03 13:27:45 +08:00
parent c37c7e8975
commit a078481cd2
3 changed files with 7 additions and 12 deletions

View File

@ -41,7 +41,10 @@ use nac3core::{
numpy::unpack_ndarray_var_tys,
DefinitionId, GenCall,
},
typecheck::typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap},
typecheck::{
type_inferencer::PrimitiveStore,
typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap},
},
};
/// The parallelism mode within a block.
@ -389,12 +392,7 @@ fn gen_rpc_tag(
) -> Result<(), String> {
use nac3core::typecheck::typedef::TypeEnum::*;
let int32 = ctx.primitives.int32;
let int64 = ctx.primitives.int64;
let float = ctx.primitives.float;
let bool = ctx.primitives.bool;
let str = ctx.primitives.str;
let none = ctx.primitives.none;
let PrimitiveStore { int32, int64, float, bool, str, none, .. } = ctx.primitives;
if ctx.unifier.unioned(ty, int32) {
buffer.push(b'i');

View File

@ -36,9 +36,7 @@ pub fn get_exn_constructor(
unifier: &mut Unifier,
primitives: &PrimitiveStore,
) -> (TopLevelDef, TopLevelDef, Type, Type) {
let int32 = primitives.int32;
let int64 = primitives.int64;
let string = primitives.str;
let PrimitiveStore { int32, int64, str: string, .. } = *primitives;
let exception_fields = make_exception_fields(int32, int64, string);
let exn_cons_args = vec![
FuncArg {

View File

@ -1521,8 +1521,7 @@ impl TopLevelComposer {
.any(|ann| matches!(ann, TypeAnnotation::CustomClass { id, .. } if id.0 == 7))
{
// create constructor for these classes
let string = primitives_ty.str;
let int64 = primitives_ty.int64;
let PrimitiveStore { str: string, int64, .. } = *primitives_ty;
let signature = unifier.add_ty(TypeEnum::TFunc(FunSignature {
args: vec![
FuncArg {