Skip to content

Commit

Permalink
remove perfunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Dec 18, 2024
1 parent d3c6891 commit 5829dda
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
12 changes: 3 additions & 9 deletions src/context/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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 =
Expand Down
8 changes: 4 additions & 4 deletions src/typing/callUnification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/typing/fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
| _ ->
Expand Down
6 changes: 3 additions & 3 deletions src/typing/typeloadFunction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 5829dda

Please sign in to comment.