Skip to content

Commit 7325ca4

Browse files
committed
unify apply_info names with upstream compiler
1 parent d433640 commit 7325ca4

29 files changed

+332
-332
lines changed

jscomp/core/lam.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ module Types = struct
7575
loc : Location.t;
7676
}
7777
and apply_info =
78-
{ fn : t ;
79-
args : t list ;
80-
loc : Location.t;
81-
status : apply_status
78+
{ ap_func : t ;
79+
ap_args : t list ;
80+
ap_loc : Location.t;
81+
ap_status : apply_status
8282
}
8383

8484
and t =
@@ -127,10 +127,10 @@ module X = struct
127127
and apply_info
128128
= Types.apply_info
129129
=
130-
{ fn : t ;
131-
args : t list ;
132-
loc : Location.t;
133-
status : apply_status
130+
{ ap_func : t ;
131+
ap_args : t list ;
132+
ap_loc : Location.t;
133+
ap_status : apply_status
134134
}
135135
and t
136136
= Types.t
@@ -171,10 +171,10 @@ let inner_map
171171
| Lvar (_ : ident)
172172
| Lconst (_ : Lam_constant.t) ->
173173
( (* Obj.magic *) l : X.t)
174-
| Lapply ({fn; args; loc; status} ) ->
175-
let fn = f fn in
176-
let args = Ext_list.map args f in
177-
Lapply { fn ; args; loc; status }
174+
| Lapply ({ap_func; ap_args; ap_loc; ap_status} ) ->
175+
let ap_func = f ap_func in
176+
let ap_args = Ext_list.map ap_args f in
177+
Lapply { ap_func ; ap_args; ap_loc; ap_status }
178178
| Lfunction({body; arity; params } ) ->
179179
let body = f body in
180180
Lfunction {body; arity; params}
@@ -294,7 +294,7 @@ let apply fn args loc status : t =
294294
->
295295
Lprim {primitive = wrap ; args = [Lprim { primitive_call with args ; loc = loc }] ; loc }
296296
| exception Not_simple_form ->
297-
Lapply { fn; args; loc; status }
297+
Lapply { ap_func = fn; ap_args = args; ap_loc = loc; ap_status = status }
298298
end
299299
| Lfunction {
300300
params;
@@ -305,7 +305,7 @@ let apply fn args loc status : t =
305305
->
306306
Lprim { primitive_call with args ; loc = loc }
307307
| exception _ ->
308-
Lapply { fn; args; loc; status }
308+
Lapply { ap_func = fn; ap_args = args; ap_loc = loc; ap_status = status }
309309
end
310310
| Lfunction {
311311
params;
@@ -316,14 +316,14 @@ let apply fn args loc status : t =
316316
->
317317
Lsequence(Lprim { primitive_call with args ; loc = loc }, const)
318318
| exception _ ->
319-
Lapply { fn; args; loc; status }
319+
Lapply { ap_func = fn; ap_args = args; ap_loc = loc; ap_status = status }
320320
end
321321
(* | Lfunction {params;body} when Ext_list.same_length params args ->
322322
Ext_list.fold_right2 (fun p arg acc ->
323323
Llet(Strict,p,arg,acc)
324324
) params args body *) (* TODO: more rigirous analysis on [let_kind] *)
325325
| _ ->
326-
Lapply { fn; args; loc ; status }
326+
Lapply { ap_func = fn; ap_args = args; ap_loc = loc ; ap_status = status }
327327

328328

329329
let rec
@@ -337,7 +337,7 @@ let rec
337337
(match l2 with Lconst c2 -> Lam_constant.eq_approx c1 c2 | _ -> false)
338338
| Lapply app1 ->
339339
(match l2 with Lapply app2 ->
340-
eq_approx app1.fn app2.fn && eq_approx_list app1.args app2.args
340+
eq_approx app1.ap_func app2.ap_func && eq_approx_list app1.ap_args app2.ap_args
341341
|_ -> false)
342342
| Lifthenelse (a,b,c) ->
343343
(match l2 with

jscomp/core/lam.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ and apply_status =
4040
| App_ml_full
4141
| App_js_full
4242
and apply_info = private
43-
{ fn : t ;
44-
args : t list ;
45-
loc : Location.t;
46-
status : apply_status
43+
{ ap_func : t ;
44+
ap_args : t list ;
45+
ap_loc : Location.t;
46+
ap_status : apply_status
4747
}
4848

4949
and prim_info = private

jscomp/core/lam_analysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ let rec size (lam : Lam.t) =
297297
{var $$let=Make(funarg);
298298
return [0, $$let[5],... $$let[16]]}
299299
*)
300-
| Lapply{ fn;
301-
args; _} -> size_lams (size fn) args
300+
| Lapply{ ap_func;
301+
ap_args; _} -> size_lams (size ap_func) ap_args
302302
(* | Lfunction(_, params, l) -> really_big () *)
303303
| Lfunction {body} -> size body
304304
| Lswitch _ -> really_big ()

jscomp/core/lam_arity_analysis.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ let rec get_arity (meta : Lam_stats.t) (lam : Lam.t) : Lam_arity.t =
8080
*)
8181
| Lletrec(_, body) -> get_arity meta body
8282

83-
| Lapply{fn = app; args; _ } -> (* detect functor application *)
83+
| Lapply{ap_func = app; ap_args = args ; _ } -> (* detect functor application *)
8484
let fn = get_arity meta app in
8585
begin match fn with
8686
| Arity_na -> Lam_arity.na

jscomp/core/lam_beta_reduce_util.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let simple_beta_reduce params body args =
8787
Hash_ident.clear param_hash ;
8888
None
8989
end
90-
| Lapply { fn = Lvar fn_name as f ; args = args'; loc; status}
90+
| Lapply { ap_func = Lvar fn_name as f ; ap_args = args'; ap_loc = loc ; ap_status = status}
9191
->
9292
let () =
9393
List.iter2 (fun p a -> Hash_ident.add param_hash p {lambda = a; used = false }) params args

jscomp/core/lam_bounded_vars.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ let rewrite (map : _ Hash_ident.t)
111111
(* here it makes sure that global vars are not rebound *)
112112
Lam.prim ~primitive ~args:(Ext_list.map args aux) loc
113113
| Lglobal_module _ -> lam
114-
| Lapply {fn; args; loc; status } ->
115-
let fn = aux fn in
116-
let args = Ext_list.map args aux in
117-
Lam.apply fn args loc status
114+
| Lapply {ap_func; ap_args; ap_loc; ap_status } ->
115+
let fn = aux ap_func in
116+
let args = Ext_list.map ap_args aux in
117+
Lam.apply fn args ap_loc ap_status
118118
| Lswitch(l, {sw_failaction;
119119
sw_consts;
120120
sw_blocks;

jscomp/core/lam_check.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ let check file lam =
5858
| Lglobal_module _ -> ()
5959
| Lprim {args; _} ->
6060
check_list args cxt
61-
| Lapply{fn; args; _} ->
62-
check_list (fn::args) cxt
61+
| Lapply{ap_func; ap_args; _} ->
62+
check_list (ap_func::ap_args) cxt
6363
(* check invariant that staticfaill does not cross function/while/for loop*)
6464
| Lfunction{body;params} ->
6565
check_staticfails body Set_int.empty
@@ -113,8 +113,8 @@ let check file lam =
113113
| Lprim {args; _} ->
114114
iter_list args
115115
| Lconst _ -> ()
116-
| Lapply{fn; args; _} ->
117-
iter fn; iter_list args
116+
| Lapply{ap_func; ap_args; _} ->
117+
iter ap_func; iter_list ap_args
118118
| Lfunction{body;params} ->
119119
List.iter def params;
120120
iter body

jscomp/core/lam_closure.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ let free_variables
7878
match lam with
7979
| Lvar v -> used top v
8080
| Lconst _ -> ()
81-
| Lapply {fn; args; _} ->
82-
iter top fn;
83-
let top = Lam_var_stats.new_position_after_lam fn top in
84-
Ext_list.iter args (fun lam -> iter top lam )
81+
| Lapply {ap_func; ap_args; _} ->
82+
iter top ap_func;
83+
let top = Lam_var_stats.new_position_after_lam ap_func top in
84+
Ext_list.iter ap_args (fun lam -> iter top lam )
8585
| Lprim {args ; _} ->
8686
(* Check: can top be propoaged for all primitives *)
8787
Ext_list.iter args (iter top)

jscomp/core/lam_compile.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,20 +1316,20 @@ and compile_apply
13161316
(lambda_cxt : Lam_compile_context.t) =
13171317
match appinfo with
13181318
| {
1319-
fn = Lapply{ fn; args = fn_args; status = App_na ; };
1320-
args;
1321-
status = App_na; loc }
1319+
ap_func = Lapply{ ap_func=fn; ap_args = fn_args; ap_status = App_na ; };
1320+
ap_args = args;
1321+
ap_status = App_na; ap_loc = loc}
13221322
->
13231323
(* After inlining we can generate such code,
13241324
see {!Ari_regress_test}
13251325
*)
13261326
compile_lambda lambda_cxt (Lam.apply fn (Ext_list.append fn_args args) loc App_na )
13271327
(* External function calll *)
1328-
| { fn =
1328+
| { ap_func =
13291329
Lprim{primitive = Pfield (_, fld_info);
13301330
args = [ Lglobal_module id];_};
1331-
args ;
1332-
status = App_na | App_ml_full} ->
1331+
ap_args = args ;
1332+
ap_status = App_na | App_ml_full} ->
13331333
(* Note we skip [App_js_full] since [get_exp_with_args] dont carry
13341334
this information, we should fix [get_exp_with_args]
13351335
*)
@@ -1338,7 +1338,7 @@ and compile_apply
13381338
compile_external_field_apply args id fld_name lambda_cxt
13391339
| _ -> assert false
13401340
end
1341-
| { fn; args = args_lambda; status} ->
1341+
| { ap_func = fn; ap_args = args_lambda; ap_status = status} ->
13421342
(* TODO: ---
13431343
1. check arity, can be simplified for pure expression
13441344
2. no need create names

jscomp/core/lam_convert.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ let exception_id_destructed (l : Lam.t) (fv : Ident.t): bool =
9292
| Lfor(v, e1, e2, dir, e3) ->
9393
hit e1 || hit e2 || hit e3
9494
| Lconst _ -> false
95-
| Lapply{fn; args; _} ->
96-
hit fn || hit_list args
95+
| Lapply{ap_func; ap_args; _} ->
96+
hit ap_func || hit_list ap_args
9797
| Lglobal_module _ (* global persistent module, play safe *)
9898
-> false
9999
| Lswitch(arg, sw) ->
@@ -712,13 +712,13 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
712712
| Lfunction {params = [param]; body = Lprim{primitive; args = [Lvar inner_arg]; loc }}
713713
when Ident.same param inner_arg ->
714714
Lam.prim ~primitive ~args:[x] outer_loc
715-
| Lapply {fn = Lfunction{params; body = Lprim{primitive; args = inner_args}}; args}
715+
| Lapply {ap_func = Lfunction{params; body = Lprim{primitive; args = inner_args}}; ap_args=args}
716716
when Ext_list.for_all2_no_exn inner_args params lam_is_var &&
717717
Ext_list.length_larger_than_n inner_args args 1
718718
->
719719
Lam.prim ~primitive ~args:(Ext_list.append_one args x) outer_loc
720-
| Lapply{fn;args} ->
721-
Lam.apply fn (Ext_list.append_one args x) outer_loc App_na
720+
| Lapply{ap_func;ap_args} ->
721+
Lam.apply ap_func (Ext_list.append_one ap_args x) outer_loc App_na
722722
| _ ->
723723
Lam.apply f [x] outer_loc App_na
724724
and convert_switch (e : Lambda.lambda) (s : Lambda.lambda_switch) =

0 commit comments

Comments
 (0)