Skip to content

Commit

Permalink
give spawn_monomorph the full context back
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Dec 17, 2024
1 parent a1b1ace commit 7e7a969
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/context/abstractCast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ and cast_or_unify ctx tleft eright p =
eright

let prepare_array_access_field ctx a pl cf p =
let monos = List.map (fun _ -> spawn_monomorph ctx.e p) cf.cf_params in
let monos = List.map (fun _ -> spawn_monomorph ctx p) cf.cf_params in
let map t = apply_params a.a_params pl (apply_params cf.cf_params monos t) in
let check_constraints () =
List.iter2 (fun m ttp -> match get_constraints ttp with
Expand Down
2 changes: 1 addition & 1 deletion src/context/display/displayFields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let collect_static_extensions ctx items e p =
let rec dup t = Type.map dup t in
let handle_field c f acc =
let f = { f with cf_type = opt_type f.cf_type } in
let monos = List.map (fun _ -> spawn_monomorph ctx.e p) f.cf_params in
let monos = List.map (fun _ -> spawn_monomorph ctx p) f.cf_params in
let map = apply_params f.cf_params monos in
match follow (map f.cf_type) with
| TFun((_,_,TType({t_path=["haxe";"macro"], "ExprOf"}, [t])) :: args, ret)
Expand Down
2 changes: 1 addition & 1 deletion src/context/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,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.monomorphs.perfunction <- (mono,p) :: ctx.monomorphs.perfunction;
ctx.e.monomorphs.perfunction <- (mono,p) :: ctx.e.monomorphs.perfunction;
mono

let spawn_monomorph ctx p =
Expand Down
2 changes: 1 addition & 1 deletion src/typing/calls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ let array_access ctx e1 e2 mode p =
let skip_abstract = fast_eq et at in
loop ~skip_abstract at
| _, _ ->
let pt = spawn_monomorph ctx.e p in
let pt = spawn_monomorph ctx p in
let t = ctx.t.tarray pt in
begin try
unify_raise et t p
Expand Down
2 changes: 1 addition & 1 deletion src/typing/fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ let type_field cfg ctx e i p mode (with_type : WithType.t) =
with Exit ->
display_error ctx.com (StringError.string_error i (string_source tthis) (s_type (print_context()) tthis ^ " has no field " ^ i)) pfield
end;
AKExpr (mk (TField (e,FDynamic i)) (spawn_monomorph ctx.e p) p)
AKExpr (mk (TField (e,FDynamic i)) (spawn_monomorph ctx p) p)

let type_field_default_cfg = type_field TypeFieldConfig.default

Expand Down
2 changes: 1 addition & 1 deletion src/typing/forLoop.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module IterationKind = struct
(mk (TArray (arr,iexpr)) pt p)

let check_iterator ?(resume=false) ?last_resort ctx s e p =
let pt = spawn_monomorph ctx.e p in
let pt = spawn_monomorph ctx p in
let t = ctx.t.titerator pt in
let dynamic_iterator = ref None in
let e1 = try
Expand Down
2 changes: 1 addition & 1 deletion src/typing/generic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ let build_generic_class ctx c p tl =
if gctx.generic_debug then print_endline (Printf.sprintf "[GENERIC] %s" (Printer.s_tclass_field " " cf_new));
t
in
let t = spawn_monomorph ctx.e p in
let t = spawn_monomorph ctx p in
let r = make_lazy ctx.g t (fun () ->
let t0 = f() in
unify_raise t0 t p;
Expand Down
6 changes: 3 additions & 3 deletions src/typing/instanceBuilder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let build_macro_type ctx pl p =
) in
let old = ctx.e.ret in
let t = (match ctx.g.do_macro ctx MMacroType path field args p with
| MError | MMacroInMacro -> spawn_monomorph ctx.e p
| MError | MMacroInMacro -> spawn_monomorph ctx p
| MSuccess _ -> ctx.e.ret
) in
ctx.e.ret <- old;
Expand All @@ -58,7 +58,7 @@ let build_macro_build ctx c pl cfl p =
let old = ctx.e.ret,ctx.c.get_build_infos in
ctx.c.get_build_infos <- (fun() -> Some (TClassDecl c, pl, cfl));
let t = (match ctx.g.do_macro ctx MMacroType path field args p with
| MError | MMacroInMacro -> spawn_monomorph ctx.e p
| MError | MMacroInMacro -> spawn_monomorph ctx p
| MSuccess _ -> ctx.e.ret
) in
ctx.e.ret <- fst old;
Expand All @@ -73,7 +73,7 @@ let get_build_info ctx mtype p =
| TClassDecl c ->
if ctx.pass > PBuildClass then ignore(c.cl_build());
let build f s tl =
let t = spawn_monomorph ctx.e p in
let t = spawn_monomorph ctx p in
let r = make_lazy ctx.g t (fun () ->
let tf = f tl in
unify_raise tf t p;
Expand Down
2 changes: 1 addition & 1 deletion src/typing/macroContext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
| MMacroType ->
"ComplexType",(fun () ->
let t = if v = Interp.vnull then
spawn_monomorph ctx.e p
spawn_monomorph ctx p
else try
let ct = Interp.decode_ctype v in
Typeload.load_complex_type ctx false LoadNormal ct;
Expand Down
2 changes: 1 addition & 1 deletion src/typing/matcher/exprToPattern.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let get_general_module_type ctx mt p =
let unify_type_pattern ctx mt t p =
let tcl = get_general_module_type ctx mt p in
match tcl with
| TAbstract(a,_) -> unify ctx (TAbstract(a,[spawn_monomorph ctx.e p])) t p
| TAbstract(a,_) -> unify ctx (TAbstract(a,[spawn_monomorph ctx p])) t p
| _ -> die "" __LOC__

let rec make pctx toplevel t e =
Expand Down
6 changes: 3 additions & 3 deletions src/typing/typeload.ml
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ and load_instance ctx ?(allow_display=false) ptp get_params mode =
and load_complex_type' ctx allow_display mode (t,p) =
match t with
| CTParent t -> load_complex_type ctx allow_display mode t
| CTPath { path = {tpackage = ["$"]; tname = "_hx_mono" }} -> spawn_monomorph ctx.e p
| CTPath { path = {tpackage = ["$"]; tname = "_hx_mono" }} -> spawn_monomorph ctx p
| CTPath ptp -> load_instance ~allow_display ctx ptp ParamNormal mode
| CTOptional _ -> raise_typing_error "Optional type not allowed here" p
| CTNamed _ -> raise_typing_error "Named type not allowed here" p
Expand Down Expand Up @@ -689,7 +689,7 @@ let t_iterator ctx p =
match load_qualified_type_def ctx [] "StdTypes" "Iterator" p with
| TTypeDecl t ->
add_dependency ctx.m.curmod t.t_module MDepFromTyping;
let pt = spawn_monomorph ctx.e p in
let pt = spawn_monomorph ctx p in
apply_typedef t [pt], pt
| _ ->
die "" __LOC__
Expand All @@ -699,7 +699,7 @@ let t_iterator ctx p =
*)
let load_type_hint ?(opt=false) ctx pcur mode t =
let t = match t with
| None -> spawn_monomorph ctx.e pcur
| None -> spawn_monomorph ctx pcur
| Some (t,p) -> load_complex_type ctx true mode (t,p)
in
if opt then ctx.t.tnull t else t
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typeloadFunction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let add_constructor ctx_c c force_constructor p =
cf.cf_kind <- cfsup.cf_kind;
cf.cf_params <- cfsup.cf_params;
cf.cf_meta <- List.filter (fun (m,_,_) -> m = Meta.CompilerGenerated) cfsup.cf_meta;
let t = spawn_monomorph ctx_c.e p in
let t = spawn_monomorph ctx_c p in
let r = make_lazy ctx_c.g t (fun () ->
let ctx = TyperManager.clone_for_field ctx_c cf cf.cf_params in
ignore (follow cfsup.cf_type); (* make sure it's typed *)
Expand Down
16 changes: 8 additions & 8 deletions src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let mono_or_dynamic ctx with_type p = match with_type with
| WithType.NoValue ->
t_dynamic
| Value _ | WithType _ ->
spawn_monomorph ctx.e p
spawn_monomorph ctx p

let get_iterator_param t =
match follow t with
Expand Down Expand Up @@ -144,7 +144,7 @@ let maybe_type_against_enum ctx f with_type iscall p =
let rec unify_min_raise ctx (el:texpr list) : t =
let basic = ctx.com.basic in
match el with
| [] -> spawn_monomorph ctx.e null_pos
| [] -> spawn_monomorph ctx null_pos
| [e] -> e.etype
| _ ->
let rec chk_null e = is_null e.etype || is_explicit_null e.etype ||
Expand Down Expand Up @@ -172,7 +172,7 @@ let rec unify_min_raise ctx (el:texpr list) : t =
with Unify_error _ ->
true, t
in
let has_error, t = loop (spawn_monomorph ctx.e null_pos) el in
let has_error, t = loop (spawn_monomorph ctx null_pos) el in
if not has_error then
t
else try
Expand Down Expand Up @@ -394,7 +394,7 @@ let rec type_ident_raise ctx i p mode with_type =
AKExpr (mk (TConst TSuper) t p)
| "null" ->
let acc =
let tnull () = ctx.t.tnull (spawn_monomorph ctx.e p) in
let tnull () = ctx.t.tnull (spawn_monomorph ctx p) in
let t = match with_type with
| WithType.WithType(t,_) ->
begin match follow t with
Expand Down Expand Up @@ -1140,11 +1140,11 @@ and type_map_declaration ctx e1 el with_type p =
| TInst({cl_path=["haxe";"ds"],"IntMap"},[tv]) -> ctx.t.tint,tv,true
| TInst({cl_path=["haxe";"ds"],"StringMap"},[tv]) -> ctx.t.tstring,tv,true
| TInst({cl_path=["haxe";"ds"],("ObjectMap" | "EnumValueMap")},[tk;tv]) -> tk,tv,true
| _ -> spawn_monomorph ctx.e p,spawn_monomorph ctx.e p,false
| _ -> spawn_monomorph ctx p,spawn_monomorph ctx p,false
in
match with_type with
| WithType.WithType(t,_) -> get_map_params t
| _ -> (spawn_monomorph ctx.e p,spawn_monomorph ctx.e p,false)
| _ -> (spawn_monomorph ctx p,spawn_monomorph ctx p,false)
in
let keys = Hashtbl.create 0 in
let check_key e_key =
Expand Down Expand Up @@ -1435,7 +1435,7 @@ and type_array_decl ctx el with_type p =
mk (TArrayDecl el) (ctx.t.tarray t) p)

and type_array_comprehension ctx e with_type p =
let v = gen_local ctx (spawn_monomorph ctx.e p) p in
let v = gen_local ctx (spawn_monomorph ctx p) p in
let ev = mk (TLocal v) v.v_type p in
let e_ref = snd (store_typed_expr ctx.com ev p) in
let et = ref (EConst(Ident "null"),p) in
Expand Down Expand Up @@ -1997,7 +1997,7 @@ and type_expr ?(mode=MGet) ctx (e,p) (with_type:WithType.t) =
}
| ECast (e,None) ->
let e = type_expr ctx e WithType.value in
mk (TCast (e,None)) (spawn_monomorph ctx.e p) p
mk (TCast (e,None)) (spawn_monomorph ctx p) p
| ECast (e, Some t) ->
type_cast ctx e t p
| EDisplay (e,dk) ->
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typerBase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ let type_module_type ctx t p =
| TEnumDecl e ->
mk (TTypeExpr (TEnumDecl e)) e.e_type p
| TTypeDecl s ->
let t = apply_typedef s (List.map (fun _ -> spawn_monomorph ctx.e p) s.t_params) in
let t = apply_typedef s (List.map (fun _ -> spawn_monomorph ctx p) s.t_params) in
DeprecationCheck.check_typedef (create_deprecation_context ctx) s p;
(match follow t with
| TEnum (e,params) ->
Expand Down
2 changes: 1 addition & 1 deletion src/typing/typerDisplay.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ let raise_toplevel ctx dk with_type (subject,psubject) =
DisplayToplevel.collect_and_raise ctx (match dk with DKPattern _ -> TKPattern psubject | _ -> TKExpr psubject) with_type (CRToplevel expected_type) (subject,psubject) psubject

let display_dollar_type ctx p make_type =
let mono = spawn_monomorph ctx.e p in
let mono = spawn_monomorph ctx p in
let doc = doc_from_string "Outputs type of argument as a warning and uses argument as value" in
let arg = ["expression",false,mono] in
begin match ctx.com.display.dms_kind with
Expand Down

0 comments on commit 7e7a969

Please sign in to comment.