Skip to content

Commit 16dcecc

Browse files
committed
format
1 parent 05e08f7 commit 16dcecc

File tree

4 files changed

+44
-76
lines changed

4 files changed

+44
-76
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ let var ?comment id : t = { expression_desc = Var (Id id); comment }
6060
Invariant: it should not call an external module .. *)
6161

6262
let js_global ?comment (v : string) = var ?comment (Ext_ident.create_js v)
63-
6463
let undefined : t = { expression_desc = Undefined; comment = None }
65-
6664
let nil : t = { expression_desc = Null; comment = None }
6765

6866
let call ?comment ~info e0 args : t =
@@ -126,7 +124,7 @@ let pure_runtime_call module_name fn_name args =
126124
let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
127125

128126
let str ?(delim = None) ?comment txt : t =
129-
{ expression_desc = Str {txt; delim}; comment }
127+
{ expression_desc = Str { txt; delim }; comment }
130128

131129
let raw_js_code ?comment info s : t =
132130
{
@@ -135,7 +133,6 @@ let raw_js_code ?comment info s : t =
135133
}
136134

137135
let array ?comment mt es : t = { expression_desc = Array (es, mt); comment }
138-
139136
let some_comment = None
140137

141138
let optional_block e : J.expression =
@@ -396,7 +393,7 @@ let extension_access (e : t) name (pos : int32) : t =
396393

397394
let string_index ?comment (e0 : t) (e1 : t) : t =
398395
match (e0.expression_desc, e1.expression_desc) with
399-
| Str {txt}, Number (Int { i; _ }) ->
396+
| Str { txt }, Number (Int { i; _ }) ->
400397
(* Don't optimize {j||j} *)
401398
let i = Int32.to_int i in
402399
if i >= 0 && i < String.length txt then
@@ -475,7 +472,7 @@ let array_length ?comment (e : t) : t =
475472

476473
let string_length ?comment (e : t) : t =
477474
match e.expression_desc with
478-
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
475+
| Str { txt; delim = None } -> int ?comment (Int32.of_int (String.length txt))
479476
(* No optimization for {j||j}*)
480477
| _ -> { expression_desc = Length (e, String); comment }
481478

@@ -500,14 +497,14 @@ let function_length ?comment (e : t) : t =
500497

501498
let rec string_append ?comment (e : t) (el : t) : t =
502499
match (e.expression_desc, el.expression_desc) with
503-
| Str {txt=a}, String_append ({ expression_desc = Str {txt=b} }, c) ->
500+
| Str { txt = a }, String_append ({ expression_desc = Str { txt = b } }, c) ->
504501
string_append ?comment (str (a ^ b)) c
505-
| String_append (c, { expression_desc = Str {txt=b} }), Str {txt=a} ->
502+
| String_append (c, { expression_desc = Str { txt = b } }), Str { txt = a } ->
506503
string_append ?comment c (str (b ^ a))
507-
| ( String_append (a, { expression_desc = Str {txt=b} }),
508-
String_append ({ expression_desc = Str {txt=c} }, d) ) ->
504+
| ( String_append (a, { expression_desc = Str { txt = b } }),
505+
String_append ({ expression_desc = Str { txt = c } }, d) ) ->
509506
string_append ?comment (string_append a (str (b ^ c))) d
510-
| Str {txt=a}, Str {txt=b} -> str ?comment (a ^ b)
507+
| Str { txt = a }, Str { txt = b } -> str ?comment (a ^ b)
511508
| _, _ -> { comment; expression_desc = String_append (e, el) }
512509

513510
let obj ?comment properties : t =
@@ -520,9 +517,7 @@ let obj ?comment properties : t =
520517

521518
(* var (Jident.create_js "true") *)
522519
let true_ : t = { comment = None; expression_desc = Bool true }
523-
524520
let false_ : t = { comment = None; expression_desc = Bool false }
525-
526521
let bool v = if v then true_ else false_
527522

528523
(** Arith operators *)
@@ -546,7 +541,7 @@ let rec triple_equal ?comment (e0 : t) (e1 : t) : t =
546541
(Null | Undefined) )
547542
when no_side_effect e0 ->
548543
false_
549-
| Str {txt=x}, Str {txt=y} ->
544+
| Str { txt = x }, Str { txt = y } ->
550545
(* CF*)
551546
bool (Ext_string.equal x y)
552547
| Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1)
@@ -724,7 +719,7 @@ let int_equal = float_equal
724719

725720
let string_equal ?comment (e0 : t) (e1 : t) : t =
726721
match (e0.expression_desc, e1.expression_desc) with
727-
| Str {txt=a0}, Str {txt=b0} -> bool (Ext_string.equal a0 b0)
722+
| Str { txt = a0 }, Str { txt = b0 } -> bool (Ext_string.equal a0 b0)
728723
| _, _ -> { expression_desc = Bin (EqEqEq, e0, e1); comment }
729724

730725
let is_type_number ?comment (e : t) : t =
@@ -807,7 +802,7 @@ let uint32 ?comment n : J.expression =
807802

808803
let string_comp (cmp : J.binop) ?comment (e0 : t) (e1 : t) =
809804
match (e0.expression_desc, e1.expression_desc) with
810-
| Str {txt=a0}, Str {txt=b0} -> (
805+
| Str { txt = a0 }, Str { txt = b0 } -> (
811806
match cmp with
812807
| EqEqEq -> bool (a0 = b0)
813808
| NotEqEq -> bool (a0 <> b0)
@@ -1035,7 +1030,6 @@ and float_minus ?comment (e1 : t) (e2 : t) : t =
10351030
(* bin ?comment Minus e1 e2 *)
10361031

10371032
let unchecked_int32_add ?comment e1 e2 = float_add ?comment e1 e2
1038-
10391033
let int32_add ?comment e1 e2 = to_int32 (float_add ?comment e1 e2)
10401034

10411035
let offset e1 (offset : int) =
@@ -1048,7 +1042,6 @@ let unchecked_int32_minus ?comment e1 e2 : J.expression =
10481042
float_minus ?comment e1 e2
10491043

10501044
let float_div ?comment e1 e2 = bin ?comment Div e1 e2
1051-
10521045
let float_notequal ?comment e1 e2 = bin ?comment NotEqEq e1 e2
10531046

10541047
let int32_asr ?comment e1 e2 : J.expression =
@@ -1170,7 +1163,6 @@ let of_block ?comment ?e block : t =
11701163
[]
11711164

11721165
let is_null ?comment (x : t) = triple_equal ?comment x nil
1173-
11741166
let is_undef ?comment x = triple_equal ?comment x undefined
11751167

11761168
let for_sure_js_null_undefined (x : t) =

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67316,9 +67316,7 @@ let var ?comment id : t = { expression_desc = Var (Id id); comment }
6731667316
Invariant: it should not call an external module .. *)
6731767317

6731867318
let js_global ?comment (v : string) = var ?comment (Ext_ident.create_js v)
67319-
6732067319
let undefined : t = { expression_desc = Undefined; comment = None }
67321-
6732267320
let nil : t = { expression_desc = Null; comment = None }
6732367321

6732467322
let call ?comment ~info e0 args : t =
@@ -67382,7 +67380,7 @@ let pure_runtime_call module_name fn_name args =
6738267380
let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
6738367381

6738467382
let str ?(delim = None) ?comment txt : t =
67385-
{ expression_desc = Str {txt; delim}; comment }
67383+
{ expression_desc = Str { txt; delim }; comment }
6738667384

6738767385
let raw_js_code ?comment info s : t =
6738867386
{
@@ -67391,7 +67389,6 @@ let raw_js_code ?comment info s : t =
6739167389
}
6739267390

6739367391
let array ?comment mt es : t = { expression_desc = Array (es, mt); comment }
67394-
6739567392
let some_comment = None
6739667393

6739767394
let optional_block e : J.expression =
@@ -67652,7 +67649,7 @@ let extension_access (e : t) name (pos : int32) : t =
6765267649

6765367650
let string_index ?comment (e0 : t) (e1 : t) : t =
6765467651
match (e0.expression_desc, e1.expression_desc) with
67655-
| Str {txt}, Number (Int { i; _ }) ->
67652+
| Str { txt }, Number (Int { i; _ }) ->
6765667653
(* Don't optimize {j||j} *)
6765767654
let i = Int32.to_int i in
6765867655
if i >= 0 && i < String.length txt then
@@ -67731,7 +67728,7 @@ let array_length ?comment (e : t) : t =
6773167728

6773267729
let string_length ?comment (e : t) : t =
6773367730
match e.expression_desc with
67734-
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
67731+
| Str { txt; delim = None } -> int ?comment (Int32.of_int (String.length txt))
6773567732
(* No optimization for {j||j}*)
6773667733
| _ -> { expression_desc = Length (e, String); comment }
6773767734

@@ -67756,14 +67753,14 @@ let function_length ?comment (e : t) : t =
6775667753

6775767754
let rec string_append ?comment (e : t) (el : t) : t =
6775867755
match (e.expression_desc, el.expression_desc) with
67759-
| Str {txt=a}, String_append ({ expression_desc = Str {txt=b} }, c) ->
67756+
| Str { txt = a }, String_append ({ expression_desc = Str { txt = b } }, c) ->
6776067757
string_append ?comment (str (a ^ b)) c
67761-
| String_append (c, { expression_desc = Str {txt=b} }), Str {txt=a} ->
67758+
| String_append (c, { expression_desc = Str { txt = b } }), Str { txt = a } ->
6776267759
string_append ?comment c (str (b ^ a))
67763-
| ( String_append (a, { expression_desc = Str {txt=b} }),
67764-
String_append ({ expression_desc = Str {txt=c} }, d) ) ->
67760+
| ( String_append (a, { expression_desc = Str { txt = b } }),
67761+
String_append ({ expression_desc = Str { txt = c } }, d) ) ->
6776567762
string_append ?comment (string_append a (str (b ^ c))) d
67766-
| Str {txt=a}, Str {txt=b} -> str ?comment (a ^ b)
67763+
| Str { txt = a }, Str { txt = b } -> str ?comment (a ^ b)
6776767764
| _, _ -> { comment; expression_desc = String_append (e, el) }
6776867765

6776967766
let obj ?comment properties : t =
@@ -67776,9 +67773,7 @@ let obj ?comment properties : t =
6777667773

6777767774
(* var (Jident.create_js "true") *)
6777867775
let true_ : t = { comment = None; expression_desc = Bool true }
67779-
6778067776
let false_ : t = { comment = None; expression_desc = Bool false }
67781-
6778267777
let bool v = if v then true_ else false_
6778367778

6778467779
(** Arith operators *)
@@ -67802,7 +67797,7 @@ let rec triple_equal ?comment (e0 : t) (e1 : t) : t =
6780267797
(Null | Undefined) )
6780367798
when no_side_effect e0 ->
6780467799
false_
67805-
| Str {txt=x}, Str {txt=y} ->
67800+
| Str { txt = x }, Str { txt = y } ->
6780667801
(* CF*)
6780767802
bool (Ext_string.equal x y)
6780867803
| Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1)
@@ -67980,7 +67975,7 @@ let int_equal = float_equal
6798067975

6798167976
let string_equal ?comment (e0 : t) (e1 : t) : t =
6798267977
match (e0.expression_desc, e1.expression_desc) with
67983-
| Str {txt=a0}, Str {txt=b0} -> bool (Ext_string.equal a0 b0)
67978+
| Str { txt = a0 }, Str { txt = b0 } -> bool (Ext_string.equal a0 b0)
6798467979
| _, _ -> { expression_desc = Bin (EqEqEq, e0, e1); comment }
6798567980

6798667981
let is_type_number ?comment (e : t) : t =
@@ -68063,7 +68058,7 @@ let uint32 ?comment n : J.expression =
6806368058

6806468059
let string_comp (cmp : J.binop) ?comment (e0 : t) (e1 : t) =
6806568060
match (e0.expression_desc, e1.expression_desc) with
68066-
| Str {txt=a0}, Str {txt=b0} -> (
68061+
| Str { txt = a0 }, Str { txt = b0 } -> (
6806768062
match cmp with
6806868063
| EqEqEq -> bool (a0 = b0)
6806968064
| NotEqEq -> bool (a0 <> b0)
@@ -68291,7 +68286,6 @@ and float_minus ?comment (e1 : t) (e2 : t) : t =
6829168286
(* bin ?comment Minus e1 e2 *)
6829268287

6829368288
let unchecked_int32_add ?comment e1 e2 = float_add ?comment e1 e2
68294-
6829568289
let int32_add ?comment e1 e2 = to_int32 (float_add ?comment e1 e2)
6829668290

6829768291
let offset e1 (offset : int) =
@@ -68304,7 +68298,6 @@ let unchecked_int32_minus ?comment e1 e2 : J.expression =
6830468298
float_minus ?comment e1 e2
6830568299

6830668300
let float_div ?comment e1 e2 = bin ?comment Div e1 e2
68307-
6830868301
let float_notequal ?comment e1 e2 = bin ?comment NotEqEq e1 e2
6830968302

6831068303
let int32_asr ?comment e1 e2 : J.expression =
@@ -68426,7 +68419,6 @@ let of_block ?comment ?e block : t =
6842668419
[]
6842768420

6842868421
let is_null ?comment (x : t) = triple_equal ?comment x nil
68429-
6843068422
let is_undef ?comment x = triple_equal ?comment x undefined
6843168423

6843268424
let for_sure_js_null_undefined (x : t) =

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67316,9 +67316,7 @@ let var ?comment id : t = { expression_desc = Var (Id id); comment }
6731667316
Invariant: it should not call an external module .. *)
6731767317

6731867318
let js_global ?comment (v : string) = var ?comment (Ext_ident.create_js v)
67319-
6732067319
let undefined : t = { expression_desc = Undefined; comment = None }
67321-
6732267320
let nil : t = { expression_desc = Null; comment = None }
6732367321

6732467322
let call ?comment ~info e0 args : t =
@@ -67382,7 +67380,7 @@ let pure_runtime_call module_name fn_name args =
6738267380
let runtime_ref module_name fn_name = runtime_var_dot module_name fn_name
6738367381

6738467382
let str ?(delim = None) ?comment txt : t =
67385-
{ expression_desc = Str {txt; delim}; comment }
67383+
{ expression_desc = Str { txt; delim }; comment }
6738667384

6738767385
let raw_js_code ?comment info s : t =
6738867386
{
@@ -67391,7 +67389,6 @@ let raw_js_code ?comment info s : t =
6739167389
}
6739267390

6739367391
let array ?comment mt es : t = { expression_desc = Array (es, mt); comment }
67394-
6739567392
let some_comment = None
6739667393

6739767394
let optional_block e : J.expression =
@@ -67652,7 +67649,7 @@ let extension_access (e : t) name (pos : int32) : t =
6765267649

6765367650
let string_index ?comment (e0 : t) (e1 : t) : t =
6765467651
match (e0.expression_desc, e1.expression_desc) with
67655-
| Str {txt}, Number (Int { i; _ }) ->
67652+
| Str { txt }, Number (Int { i; _ }) ->
6765667653
(* Don't optimize {j||j} *)
6765767654
let i = Int32.to_int i in
6765867655
if i >= 0 && i < String.length txt then
@@ -67731,7 +67728,7 @@ let array_length ?comment (e : t) : t =
6773167728

6773267729
let string_length ?comment (e : t) : t =
6773367730
match e.expression_desc with
67734-
| Str {txt; delim=None} -> int ?comment (Int32.of_int (String.length txt))
67731+
| Str { txt; delim = None } -> int ?comment (Int32.of_int (String.length txt))
6773567732
(* No optimization for {j||j}*)
6773667733
| _ -> { expression_desc = Length (e, String); comment }
6773767734

@@ -67756,14 +67753,14 @@ let function_length ?comment (e : t) : t =
6775667753

6775767754
let rec string_append ?comment (e : t) (el : t) : t =
6775867755
match (e.expression_desc, el.expression_desc) with
67759-
| Str {txt=a}, String_append ({ expression_desc = Str {txt=b} }, c) ->
67756+
| Str { txt = a }, String_append ({ expression_desc = Str { txt = b } }, c) ->
6776067757
string_append ?comment (str (a ^ b)) c
67761-
| String_append (c, { expression_desc = Str {txt=b} }), Str {txt=a} ->
67758+
| String_append (c, { expression_desc = Str { txt = b } }), Str { txt = a } ->
6776267759
string_append ?comment c (str (b ^ a))
67763-
| ( String_append (a, { expression_desc = Str {txt=b} }),
67764-
String_append ({ expression_desc = Str {txt=c} }, d) ) ->
67760+
| ( String_append (a, { expression_desc = Str { txt = b } }),
67761+
String_append ({ expression_desc = Str { txt = c } }, d) ) ->
6776567762
string_append ?comment (string_append a (str (b ^ c))) d
67766-
| Str {txt=a}, Str {txt=b} -> str ?comment (a ^ b)
67763+
| Str { txt = a }, Str { txt = b } -> str ?comment (a ^ b)
6776767764
| _, _ -> { comment; expression_desc = String_append (e, el) }
6776867765

6776967766
let obj ?comment properties : t =
@@ -67776,9 +67773,7 @@ let obj ?comment properties : t =
6777667773

6777767774
(* var (Jident.create_js "true") *)
6777867775
let true_ : t = { comment = None; expression_desc = Bool true }
67779-
6778067776
let false_ : t = { comment = None; expression_desc = Bool false }
67781-
6778267777
let bool v = if v then true_ else false_
6778367778

6778467779
(** Arith operators *)
@@ -67802,7 +67797,7 @@ let rec triple_equal ?comment (e0 : t) (e1 : t) : t =
6780267797
(Null | Undefined) )
6780367798
when no_side_effect e0 ->
6780467799
false_
67805-
| Str {txt=x}, Str {txt=y} ->
67800+
| Str { txt = x }, Str { txt = y } ->
6780667801
(* CF*)
6780767802
bool (Ext_string.equal x y)
6780867803
| Number (Int { i = i0; _ }), Number (Int { i = i1; _ }) -> bool (i0 = i1)
@@ -67980,7 +67975,7 @@ let int_equal = float_equal
6798067975

6798167976
let string_equal ?comment (e0 : t) (e1 : t) : t =
6798267977
match (e0.expression_desc, e1.expression_desc) with
67983-
| Str {txt=a0}, Str {txt=b0} -> bool (Ext_string.equal a0 b0)
67978+
| Str { txt = a0 }, Str { txt = b0 } -> bool (Ext_string.equal a0 b0)
6798467979
| _, _ -> { expression_desc = Bin (EqEqEq, e0, e1); comment }
6798567980

6798667981
let is_type_number ?comment (e : t) : t =
@@ -68063,7 +68058,7 @@ let uint32 ?comment n : J.expression =
6806368058

6806468059
let string_comp (cmp : J.binop) ?comment (e0 : t) (e1 : t) =
6806568060
match (e0.expression_desc, e1.expression_desc) with
68066-
| Str {txt=a0}, Str {txt=b0} -> (
68061+
| Str { txt = a0 }, Str { txt = b0 } -> (
6806768062
match cmp with
6806868063
| EqEqEq -> bool (a0 = b0)
6806968064
| NotEqEq -> bool (a0 <> b0)
@@ -68291,7 +68286,6 @@ and float_minus ?comment (e1 : t) (e2 : t) : t =
6829168286
(* bin ?comment Minus e1 e2 *)
6829268287

6829368288
let unchecked_int32_add ?comment e1 e2 = float_add ?comment e1 e2
68294-
6829568289
let int32_add ?comment e1 e2 = to_int32 (float_add ?comment e1 e2)
6829668290

6829768291
let offset e1 (offset : int) =
@@ -68304,7 +68298,6 @@ let unchecked_int32_minus ?comment e1 e2 : J.expression =
6830468298
float_minus ?comment e1 e2
6830568299

6830668300
let float_div ?comment e1 e2 = bin ?comment Div e1 e2
68307-
6830868301
let float_notequal ?comment e1 e2 = bin ?comment NotEqEq e1 e2
6830968302

6831068303
let int32_asr ?comment e1 e2 : J.expression =
@@ -68426,7 +68419,6 @@ let of_block ?comment ?e block : t =
6842668419
[]
6842768420

6842868421
let is_null ?comment (x : t) = triple_equal ?comment x nil
68429-
6843068422
let is_undef ?comment x = triple_equal ?comment x undefined
6843168423

6843268424
let for_sure_js_null_undefined (x : t) =

0 commit comments

Comments
 (0)