From 5829dda1aca32a4803de15af723773f8805115b9 Mon Sep 17 00:00:00 2001 From: Simon Krajewski Date: Wed, 18 Dec 2024 06:44:48 +0100 Subject: [PATCH] remove perfunction --- src/context/typecore.ml | 12 +++--------- src/typing/callUnification.ml | 8 ++++---- src/typing/fields.ml | 10 +++++----- src/typing/typeloadFunction.ml | 6 +++--- 4 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/context/typecore.ml b/src/context/typecore.ml index 211169bd449..c2b86c37b1b 100644 --- a/src/context/typecore.ml +++ b/src/context/typecore.ml @@ -141,7 +141,7 @@ and typer_expr = { in_function : bool; mutable ret : t; mutable opened : anon_status ref list; - mutable monomorphs : monomorphs; + mutable monomorphs : (tmono * pos) list; mutable in_loop : bool; mutable bypass_accessor : int; mutable with_type_stack : WithType.t list; @@ -177,10 +177,6 @@ and typer = { memory_marker : float array; } -and monomorphs = { - mutable perfunction : (tmono * pos) list; -} - let pass_name = function | PBuildModule -> "build-module" | PBuildClass -> "build-class" @@ -241,9 +237,7 @@ module TyperManager = struct in_function; ret = t_dynamic; opened = []; - monomorphs = { - perfunction = []; - }; + monomorphs = []; in_loop = false; bypass_accessor = 0; with_type_stack = []; @@ -374,7 +368,7 @@ let unify_min_for_type_source ctx el src = (!unify_min_for_type_source_ref) ctx let spawn_monomorph' ctx p = let mono = Monomorph.create () in - ctx.e.monomorphs.perfunction <- (mono,p) :: ctx.e.monomorphs.perfunction; + ctx.e.monomorphs <- (mono,p) :: ctx.e.monomorphs; mono let spawn_monomorph ctx p = diff --git a/src/typing/callUnification.ml b/src/typing/callUnification.ml index fb7282c14ad..f0b08ee2b44 100644 --- a/src/typing/callUnification.ml +++ b/src/typing/callUnification.ml @@ -327,11 +327,11 @@ let unify_field_call ctx fa el_typed el p inline = | cf :: candidates -> let known_monos = List.map (fun (m,_) -> m,m.tm_type,m.tm_down_constraints - ) ctx.e.monomorphs.perfunction in - let current_monos = ctx.e.monomorphs.perfunction in + ) ctx.e.monomorphs in + let current_monos = ctx.e.monomorphs in begin try let candidate = attempt_call cf true in - ctx.e.monomorphs.perfunction <- current_monos; + ctx.e.monomorphs <- current_monos; if overload_kind = OverloadProper then begin let candidates,failures = loop candidates in candidate :: candidates,failures @@ -342,7 +342,7 @@ let unify_field_call ctx fa el_typed el p inline = if t != m.tm_type then m.tm_type <- t; if constr != m.tm_down_constraints then m.tm_down_constraints <- constr; ) known_monos; - ctx.e.monomorphs.perfunction <- current_monos; + ctx.e.monomorphs <- current_monos; check_unknown_ident err; let candidates,failures = loop candidates in candidates,(cf,err,extract_delayed_display()) :: failures diff --git a/src/typing/fields.ml b/src/typing/fields.ml index 8bfad9d0326..3b119afcaa7 100644 --- a/src/typing/fields.ml +++ b/src/typing/fields.ml @@ -382,8 +382,8 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = | CTypes tl -> type_field_by_list (fun (t,_) -> type_field_by_et type_field_by_type e t) tl | CUnknown -> - if not (List.exists (fun (m,_) -> m == r) ctx.e.monomorphs.perfunction) && not (ctx.f.untyped && ctx.com.platform = Neko) then - ctx.e.monomorphs.perfunction <- (r,p) :: ctx.e.monomorphs.perfunction; + if not (List.exists (fun (m,_) -> m == r) ctx.e.monomorphs) && not (ctx.f.untyped && ctx.com.platform = Neko) then + ctx.e.monomorphs <- (r,p) :: ctx.e.monomorphs; let f = mk_field() in Monomorph.add_down_constraint r (MField f); Monomorph.add_modifier r MOpenStructure; @@ -427,9 +427,9 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = check cfl | cf :: cfl -> (* We always want to reset monomorphs here because they will be handled again when making the actual call. *) - let current_monos = ctx.e.monomorphs.perfunction in + let current_monos = ctx.e.monomorphs in let check () = - ctx.e.monomorphs.perfunction <- current_monos; + ctx.e.monomorphs <- current_monos; check cfl in try @@ -442,7 +442,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) = else begin let e = unify_static_extension ctx e t0 p in ImportHandling.mark_import_position ctx pc; - ctx.e.monomorphs.perfunction <- current_monos; + ctx.e.monomorphs <- current_monos; AKUsingField (make_static_extension_access c cf e false p) end | _ -> diff --git a/src/typing/typeloadFunction.ml b/src/typing/typeloadFunction.ml index 42f5b6ea952..ddf7596b7bb 100644 --- a/src/typing/typeloadFunction.ml +++ b/src/typing/typeloadFunction.ml @@ -39,7 +39,7 @@ let type_function_params ctx fd host fname = let type_function ctx (args : function_arguments) ret e do_display p = ctx.e.ret <- ret; ctx.e.opened <- []; - ctx.e.monomorphs.perfunction <- []; + ctx.e.monomorphs <- []; enter_field_typing_pass ctx.g ("type_function",fst ctx.c.curclass.cl_path @ [snd ctx.c.curclass.cl_path;ctx.f.curfield.cf_name]); args#bring_into_context ctx; let e = match e with @@ -175,7 +175,7 @@ let type_function ctx (args : function_arguments) ret e do_display p = print_endline (Printf.sprintf "%s (%s)" s spos); safe_mono_close ctx m p; (i,m,p,s) - ) ctx.e.monomorphs.perfunction in + ) ctx.e.monomorphs in print_endline "CHANGED:"; List.iter (fun (i,m,p,s) -> let s' = print_mono i m in @@ -184,7 +184,7 @@ let type_function ctx (args : function_arguments) ret e do_display p = end ) monos end else - List.iter (fun (m,p) -> safe_mono_close ctx m p) ctx.e.monomorphs.perfunction; + List.iter (fun (m,p) -> safe_mono_close ctx m p) ctx.e.monomorphs; if is_position_debug then print_endline ("typing:\n" ^ (Texpr.dump_with_pos "" e)); e