Skip to content

Commit 6b64d84

Browse files
committed
clean up and documentation
1 parent e9d937a commit 6b64d84

33 files changed

+758
-140
lines changed

Diff for: jscomp/all.depend

+4-3
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ core/lam_compile_util.cmi : core/js_op.cmx
276276
core/lam_stats.cmi : core/lam.cmi ext/int_hash_set.cmi ext/ident_set.cmi \
277277
ext/ident_hashtbl.cmi
278278
core/config_util.cmi : core/js_cmj_format.cmi
279-
core/lam_compile_defs.cmi : core/lam_stats.cmi core/j.cmx ext/ident_map.cmi
279+
core/lam_compile_defs.cmi : core/lam_stats.cmi core/lam.cmi core/j.cmx \
280+
ext/ident_map.cmi
280281
core/js_fold_basic.cmi : core/lam_module_ident.cmi core/j.cmx \
281282
ext/ident_set.cmi
282283
core/js_pass_scope.cmi : core/j.cmx ext/ident_set.cmi
@@ -388,8 +389,8 @@ core/lam_stats.cmx : core/lam.cmx ext/int_hash_set.cmx ext/ident_set.cmx \
388389
ext/ident_hashtbl.cmx core/lam_stats.cmi
389390
core/config_util.cmx : core/js_cmj_format.cmx depends/bs_exception.cmx \
390391
core/config_util.cmi
391-
core/lam_compile_defs.cmx : core/lam_stats.cmx core/j.cmx ext/ident_map.cmx \
392-
core/lam_compile_defs.cmi
392+
core/lam_compile_defs.cmx : core/lam_stats.cmx core/lam.cmx core/j.cmx \
393+
ext/ident_map.cmx core/lam_compile_defs.cmi
393394
core/js_map.cmx : core/j.cmx
394395
core/js_fold.cmx : core/j.cmx
395396
core/js_fold_basic.cmx : core/lam_module_ident.cmx core/js_fold.cmx \

Diff for: jscomp/bin/whole_compiler.ml

+50-32
Original file line numberDiff line numberDiff line change
@@ -65616,10 +65616,22 @@ type set_field_dbg_info = Lambda.set_field_dbg_info
6561665616

6561765617
type ident = Ident.t
6561865618

65619+
type let_kind = Lambda.let_kind
65620+
= Strict
65621+
| Alias
65622+
| StrictOpt
65623+
| Variable
65624+
65625+
type meth_kind = Lambda.meth_kind
65626+
= Self
65627+
| Public of string option
65628+
| Cached
65629+
6561965630
type function_kind
6562065631
= Curried
6562165632
(* | Tupled *)
6562265633

65634+
6562365635
type function_arities =
6562465636
| Determin of bool * (int * Ident.t list option) list * bool
6562565637
(** when the first argument is true, it is for sure
@@ -65810,7 +65822,7 @@ and t = private
6581065822
| Lconst of constant
6581165823
| Lapply of apply_info
6581265824
| Lfunction of function_info
65813-
| Llet of Lambda.let_kind * ident * t * t
65825+
| Llet of let_kind * ident * t * t
6581465826
| Lletrec of (ident * t) list * t
6581565827
| Lprim of prim_info
6581665828
| Lswitch of t * switch
@@ -65862,7 +65874,7 @@ val function_ :
6586265874
arity:int ->
6586365875
function_kind:function_kind -> params:ident list -> body:t -> t
6586465876

65865-
val let_ : Lambda.let_kind -> ident -> t -> t -> t
65877+
val let_ : let_kind -> ident -> t -> t -> t
6586665878
val letrec : (ident * t) list -> t -> t
6586765879
val if_ : triop
6586865880
val switch : t -> switch -> t
@@ -65877,7 +65889,7 @@ val sequand : binop
6587765889
val not_ : Location.t -> unop
6587865890
val seq : binop
6587965891
val while_ : binop
65880-
val event : t -> Lambda.lambda_event -> t
65892+
(* val event : t -> Lambda.lambda_event -> t *)
6588165893
val try_ : t -> ident -> t -> t
6588265894
val ifused : ident -> t -> t
6588365895
val assign : ident -> t -> t
@@ -65965,7 +65977,7 @@ type set_field_dbg_info = Lambda.set_field_dbg_info
6596565977

6596665978
type ident = Ident.t
6596765979

65968-
type function_kind (* = Lambda.function_kind *)
65980+
type function_kind
6596965981
= Curried
6597065982
(* | Tupled *)
6597165983

@@ -65974,6 +65986,16 @@ type function_arities =
6597465986
| Determin of bool * (int * Ident.t list option) list * bool
6597565987
| NA
6597665988

65989+
type let_kind = Lambda.let_kind
65990+
= Strict
65991+
| Alias
65992+
| StrictOpt
65993+
| Variable
65994+
65995+
type meth_kind = Lambda.meth_kind
65996+
= Self
65997+
| Public of string option
65998+
| Cached
6597765999

6597866000
type constant =
6597966001
| Const_int of int
@@ -66160,7 +66182,7 @@ module Types = struct
6616066182
| Lconst of constant
6616166183
| Lapply of apply_info
6616266184
| Lfunction of function_info
66163-
| Llet of Lambda.let_kind * ident * t * t
66185+
| Llet of let_kind * ident * t * t
6616466186
| Lletrec of (ident * t) list * t
6616566187
| Lprim of prim_info
6616666188
| Lswitch of t * switch
@@ -66173,12 +66195,8 @@ module Types = struct
6617366195
| Lwhile of t * t
6617466196
| Lfor of ident * t * t * Asttypes.direction_flag * t
6617566197
| Lassign of ident * t
66176-
| Lsend of Lambda.meth_kind * t * t * t list * Location.t
66198+
| Lsend of meth_kind * t * t * t list * Location.t
6617766199
| Lifused of ident * t
66178-
(* | Levent of t * Lambda.lambda_event
66179-
[Levent] in the branch hurt pattern match,
66180-
we should use record for trivial debugger info
66181-
*)
6618266200
end
6618366201

6618466202
module X = struct
@@ -66222,7 +66240,7 @@ module X = struct
6622266240
| Lconst of constant
6622366241
| Lapply of apply_info
6622466242
| Lfunction of function_info
66225-
| Llet of Lambda.let_kind * ident * t * t
66243+
| Llet of let_kind * ident * t * t
6622666244
| Lletrec of (ident * t) list * t
6622766245
| Lprim of prim_info
6622866246
| Lswitch of t * switch
@@ -66235,7 +66253,7 @@ module X = struct
6623566253
| Lwhile of t * t
6623666254
| Lfor of ident * t * t * Asttypes.direction_flag * t
6623766255
| Lassign of ident * t
66238-
| Lsend of Lambda.meth_kind * t * t * t list * Location.t
66256+
| Lsend of meth_kind * t * t * t list * Location.t
6623966257
| Lifused of ident * t
6624066258
end
6624166259
include Types
@@ -67040,7 +67058,7 @@ let try_ body id handler : t =
6704067058
let for_ v e1 e2 dir e3 : t =
6704167059
Lfor(v,e1,e2,dir,e3)
6704267060

67043-
let event l (_event : Lambda.lambda_event) = l
67061+
6704467062

6704567063
let ifused v l : t =
6704667064
Lifused (v,l)
@@ -67054,7 +67072,7 @@ let staticcatch a b c : t = Lstaticcatch(a,b,c)
6705467072

6705567073
let staticraise a b : t = Lstaticraise(a,b)
6705667074

67057-
let comparison (cmp : Lambda.comparison) a b : bool =
67075+
let comparison (cmp : comparison) a b : bool =
6705867076
match cmp with
6705967077
| Ceq -> a = b
6706067078
| Cneq -> a <> b
@@ -72202,7 +72220,7 @@ let kind = function
7220272220
| Variable -> "v"
7220372221
| Recursive -> "r"
7220472222

72205-
let to_print_kind (k : Lambda.let_kind) : print_kind =
72223+
let to_print_kind (k : Lam.let_kind) : print_kind =
7220672224
match k with
7220772225
| Alias -> Alias
7220872226
| Strict -> Strict
@@ -72901,11 +72919,11 @@ val field_flatten_get :
7290172919

7290272920

7290372921
val alias_ident_or_global : Lam_stats.meta ->
72904-
Ident.t -> Ident.t -> Lam_stats.kind -> Lambda.let_kind -> unit
72922+
Ident.t -> Ident.t -> Lam_stats.kind -> Lam.let_kind -> unit
7290572923

7290672924

7290772925
val refine_let :
72908-
kind:Lambda.let_kind ->
72926+
kind:Lam.let_kind ->
7290972927
Ident.t -> Lam.t -> Lam.t -> Lam.t
7291072928

7291172929

@@ -73054,7 +73072,7 @@ let refine_let
7305473072
~kind param
7305573073
(arg : Lam.t) (l : Lam.t) : Lam.t =
7305673074

73057-
match (kind : Lambda.let_kind ), arg, l with
73075+
match (kind : Lam.let_kind ), arg, l with
7305873076
| _, _, Lvar w when Ident.same w param (* let k = xx in k *)
7305973077
-> arg (* TODO: optimize here -- it's safe to do substitution here *)
7306073078
| _, _, Lprim {primitive ; args = [Lvar w]; loc ; _} when Ident.same w param
@@ -73116,7 +73134,7 @@ let refine_let
7311673134
Lam.let_ Strict param arg l *)
7311773135

7311873136
let alias_ident_or_global (meta : Lam_stats.meta) (k:Ident.t) (v:Ident.t)
73119-
(v_kind : Lam_stats.kind) (let_kind : Lambda.let_kind) =
73137+
(v_kind : Lam_stats.kind) (let_kind : Lam.let_kind) =
7312073138
(** treat rec as Strict, k is assigned to v
7312173139
{[ let k = v ]}
7312273140
*)
@@ -73309,7 +73327,7 @@ val throw : ?comment:string -> J.expression -> t
7330973327

7331073328
val if_ :
7331173329
?comment:string ->
73312-
?declaration: Lambda.let_kind * Ident.t ->
73330+
?declaration: Lam.let_kind * Ident.t ->
7331373331
(* when it's not None, we also need make a variable declaration in the
7331473332
begininnig, however, we can optmize such case
7331573333
*)
@@ -73321,20 +73339,20 @@ val if_ :
7332173339
val block : ?comment:string -> J.block -> t
7332273340

7332373341
val int_switch :
73324-
?comment:string -> ?declaration:Lambda.let_kind * Ident.t ->
73342+
?comment:string -> ?declaration:Lam.let_kind * Ident.t ->
7332573343
?default:J.block -> J.expression -> int J.case_clause list -> t
7332673344

73327-
val string_switch : ?comment:string -> ?declaration:Lambda.let_kind * Ident.t ->
73345+
val string_switch : ?comment:string -> ?declaration:Lam.let_kind * Ident.t ->
7332873346
?default:J.block -> J.expression -> string J.case_clause list -> t
7332973347

7333073348
val declare_variable : ?comment:string ->
7333173349
?ident_info:J.ident_info
73332-
-> kind:Lambda.let_kind -> Ident.t -> t
73350+
-> kind:Lam.let_kind -> Ident.t -> t
7333373351

7333473352
val define :
7333573353
?comment:string ->
7333673354
?ident_info:J.ident_info ->
73337-
kind:Lambda.let_kind -> Ident.t -> J.expression -> t
73355+
kind:Lam.let_kind -> Ident.t -> J.expression -> t
7333873356

7333973357
val alias_variable :
7334073358
?comment:string -> ?exp:J.expression -> Ident.t -> t
@@ -85923,7 +85941,7 @@ type value = {
8592385941
order_id : int
8592485942
}
8592585943

85926-
type let_kind = Lambda.let_kind
85944+
type let_kind = Lam.let_kind
8592785945

8592885946
type st =
8592985947
| EffectCall
@@ -86031,7 +86049,7 @@ type return_type =
8603186049
(* have a mutable field to notifiy it's actually triggered *)
8603286050
(* anonoymous function does not have identifier *)
8603386051

86034-
type let_kind = Lambda.let_kind
86052+
type let_kind = Lam.let_kind
8603586053

8603686054
type st =
8603786055
| EffectCall
@@ -88302,7 +88320,7 @@ module Lam_group : sig
8830288320

8830388321

8830488322
type t =
88305-
| Single of Lambda.let_kind * Ident.t * Lam.t
88323+
| Single of Lam.let_kind * Ident.t * Lam.t
8830688324
| Recursive of (Ident.t * Lam.t) list
8830788325
| Nop of Lam.t
8830888326

@@ -88346,14 +88364,14 @@ end = struct
8834688364

8834788365
(** This is not a recursive type definition *)
8834888366
type t =
88349-
| Single of Lambda.let_kind * Ident.t * Lam.t
88367+
| Single of Lam.let_kind * Ident.t * Lam.t
8835088368
| Recursive of (Ident.t * Lam.t) list
8835188369
| Nop of Lam.t
8835288370

8835388371

8835488372
let pp = Format.fprintf
8835588373

88356-
let str_of_kind (kind : Lambda.let_kind) =
88374+
let str_of_kind (kind : Lam.let_kind) =
8835788375
match kind with
8835888376
| Alias -> "a"
8835988377
| Strict -> ""
@@ -94441,7 +94459,7 @@ module Lam_compile : sig
9444194459
(** Compile single lambda IR to JS IR *)
9444294460

9444394461
val compile_let :
94444-
Lambda.let_kind ->
94462+
Lam.let_kind ->
9444594463
Lam_compile_defs.cxt ->
9444694464
J.ident ->
9444794465
Lam.t ->
@@ -94853,7 +94871,7 @@ and compile_general_cases :
9485394871
(J.expression -> J.expression -> J.expression) ->
9485494872
Lam_compile_defs.cxt ->
9485594873
(?default:J.block ->
94856-
?declaration:Lambda.let_kind * Ident.t ->
94874+
?declaration:Lam.let_kind * Ident.t ->
9485794875
_ -> 'a J.case_clause list -> J.statement) ->
9485894876
_ ->
9485994877
('a * Lam.t) list -> default_case -> J.block
@@ -96733,7 +96751,7 @@ let annotate (meta : Lam_stats.meta)
9673396751
*)
9673496752
let collect_helper (meta : Lam_stats.meta) (lam : Lam.t) =
9673596753
let rec collect_bind rec_flag
96736-
(kind : Lambda.let_kind)
96754+
(kind : Lam.let_kind)
9673796755
(ident : Ident.t)
9673896756
(lam : Lam.t) =
9673996757
match lam with

Diff for: jscomp/core/js_stmt_make.mli

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ val throw : ?comment:string -> J.expression -> t
4242

4343
val if_ :
4444
?comment:string ->
45-
?declaration: Lambda.let_kind * Ident.t ->
45+
?declaration: Lam.let_kind * Ident.t ->
4646
(* when it's not None, we also need make a variable declaration in the
4747
begininnig, however, we can optmize such case
4848
*)
@@ -54,20 +54,20 @@ val if_ :
5454
val block : ?comment:string -> J.block -> t
5555

5656
val int_switch :
57-
?comment:string -> ?declaration:Lambda.let_kind * Ident.t ->
57+
?comment:string -> ?declaration:Lam.let_kind * Ident.t ->
5858
?default:J.block -> J.expression -> int J.case_clause list -> t
5959

60-
val string_switch : ?comment:string -> ?declaration:Lambda.let_kind * Ident.t ->
60+
val string_switch : ?comment:string -> ?declaration:Lam.let_kind * Ident.t ->
6161
?default:J.block -> J.expression -> string J.case_clause list -> t
6262

6363
val declare_variable : ?comment:string ->
6464
?ident_info:J.ident_info
65-
-> kind:Lambda.let_kind -> Ident.t -> t
65+
-> kind:Lam.let_kind -> Ident.t -> t
6666

6767
val define :
6868
?comment:string ->
6969
?ident_info:J.ident_info ->
70-
kind:Lambda.let_kind -> Ident.t -> J.expression -> t
70+
kind:Lam.let_kind -> Ident.t -> J.expression -> t
7171

7272
val alias_variable :
7373
?comment:string -> ?exp:J.expression -> Ident.t -> t

0 commit comments

Comments
 (0)