Skip to content

Commit 6176f1e

Browse files
committed
support printing indexed operators
1 parent d8b1d58 commit 6176f1e

File tree

5 files changed

+120
-57
lines changed

5 files changed

+120
-57
lines changed

jscomp/ext/ext_ident.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ let name_mangle name =
138138
| ':' -> Buffer.add_string buffer "$colon"
139139
| '?' -> Buffer.add_string buffer "$question"
140140
| '&' -> Buffer.add_string buffer "$amp"
141+
| '(' -> Buffer.add_string buffer "$lpar"
142+
| ')' -> Buffer.add_string buffer "$rpar"
143+
| '{' -> Buffer.add_string buffer "$lbrace"
144+
| '}' -> Buffer.add_string buffer "$lbrace"
145+
| '[' -> Buffer.add_string buffer "$lbrack"
146+
| ']' -> Buffer.add_string buffer "$rbrack"
141147
| 'a'..'z' | 'A'..'Z'| '_'
142148
| '$'
143149
| '0'..'9'-> Buffer.add_char buffer c
@@ -170,6 +176,12 @@ let name_mangle name =
170176
| '?' -> Buffer.add_string buffer "$question"
171177
| '&' -> Buffer.add_string buffer "$amp"
172178
| '$' -> Buffer.add_string buffer "$dollar"
179+
| '(' -> Buffer.add_string buffer "$lpar"
180+
| ')' -> Buffer.add_string buffer "$rpar"
181+
| '{' -> Buffer.add_string buffer "$lbrace"
182+
| '}' -> Buffer.add_string buffer "$lbrace"
183+
| '[' -> Buffer.add_string buffer "$lbrack"
184+
| ']' -> Buffer.add_string buffer "$rbrack"
173185
| 'a'..'z' | 'A'..'Z'| '_'
174186
| '0'..'9'-> Buffer.add_char buffer c
175187
| _ -> Buffer.add_string buffer "$unknown"

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11300,6 +11300,12 @@ let name_mangle name =
1130011300
| ':' -> Buffer.add_string buffer "$colon"
1130111301
| '?' -> Buffer.add_string buffer "$question"
1130211302
| '&' -> Buffer.add_string buffer "$amp"
11303+
| '(' -> Buffer.add_string buffer "$lpar"
11304+
| ')' -> Buffer.add_string buffer "$rpar"
11305+
| '{' -> Buffer.add_string buffer "$lbrace"
11306+
| '}' -> Buffer.add_string buffer "$lbrace"
11307+
| '[' -> Buffer.add_string buffer "$lbrack"
11308+
| ']' -> Buffer.add_string buffer "$rbrack"
1130311309
| 'a'..'z' | 'A'..'Z'| '_'
1130411310
| '$'
1130511311
| '0'..'9'-> Buffer.add_char buffer c
@@ -11332,6 +11338,12 @@ let name_mangle name =
1133211338
| '?' -> Buffer.add_string buffer "$question"
1133311339
| '&' -> Buffer.add_string buffer "$amp"
1133411340
| '$' -> Buffer.add_string buffer "$dollar"
11341+
| '(' -> Buffer.add_string buffer "$lpar"
11342+
| ')' -> Buffer.add_string buffer "$rpar"
11343+
| '{' -> Buffer.add_string buffer "$lbrace"
11344+
| '}' -> Buffer.add_string buffer "$lbrace"
11345+
| '[' -> Buffer.add_string buffer "$lbrack"
11346+
| ']' -> Buffer.add_string buffer "$rbrack"
1133511347
| 'a'..'z' | 'A'..'Z'| '_'
1133611348
| '0'..'9'-> Buffer.add_char buffer c
1133711349
| _ -> Buffer.add_string buffer "$unknown"

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -371862,6 +371862,12 @@ let name_mangle name =
371862371862
| ':' -> Buffer.add_string buffer "$colon"
371863371863
| '?' -> Buffer.add_string buffer "$question"
371864371864
| '&' -> Buffer.add_string buffer "$amp"
371865+
| '(' -> Buffer.add_string buffer "$lpar"
371866+
| ')' -> Buffer.add_string buffer "$rpar"
371867+
| '{' -> Buffer.add_string buffer "$lbrace"
371868+
| '}' -> Buffer.add_string buffer "$lbrace"
371869+
| '[' -> Buffer.add_string buffer "$lbrack"
371870+
| ']' -> Buffer.add_string buffer "$rbrack"
371865371871
| 'a'..'z' | 'A'..'Z'| '_'
371866371872
| '$'
371867371873
| '0'..'9'-> Buffer.add_char buffer c
@@ -371894,6 +371900,12 @@ let name_mangle name =
371894371900
| '?' -> Buffer.add_string buffer "$question"
371895371901
| '&' -> Buffer.add_string buffer "$amp"
371896371902
| '$' -> Buffer.add_string buffer "$dollar"
371903+
| '(' -> Buffer.add_string buffer "$lpar"
371904+
| ')' -> Buffer.add_string buffer "$rpar"
371905+
| '{' -> Buffer.add_string buffer "$lbrace"
371906+
| '}' -> Buffer.add_string buffer "$lbrace"
371907+
| '[' -> Buffer.add_string buffer "$lbrack"
371908+
| ']' -> Buffer.add_string buffer "$rbrack"
371897371909
| 'a'..'z' | 'A'..'Z'| '_'
371898371910
| '0'..'9'-> Buffer.add_char buffer c
371899371911
| _ -> Buffer.add_string buffer "$unknown"
@@ -380757,9 +380769,9 @@ type t =
380757380769
(* size of the nth dimension of a big array *)
380758380770
| Pbigarraydim of int
380759380771
(* load/set 16,32,64 bits from a string: (unsafe)*)
380760-
| Pstring_load_16 of bool
380772+
(* | Pstring_load_16 of bool
380761380773
| Pstring_load_32 of bool
380762-
| Pstring_load_64 of bool
380774+
| Pstring_load_64 of bool *)
380763380775
(* | Pstring_set_16 of bool
380764380776
| Pstring_set_32 of bool
380765380777
| Pstring_set_64 of bool *)
@@ -380943,9 +380955,9 @@ type t =
380943380955
(* size of the nth dimension of a big array *)
380944380956
| Pbigarraydim of int
380945380957
(* load/set 16,32,64 bits from a string: (unsafe)*)
380946-
| Pstring_load_16 of bool
380958+
(* | Pstring_load_16 of bool
380947380959
| Pstring_load_32 of bool
380948-
| Pstring_load_64 of bool
380960+
| Pstring_load_64 of bool *)
380949380961
(* | Pstring_set_16 of bool
380950380962
| Pstring_set_32 of bool
380951380963
| Pstring_set_64 of bool *)
@@ -381142,9 +381154,9 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
381142381154
| Pcvtbint (boxed_integer, boxed_integer1) -> (match rhs with Pcvtbint (boxed_integer10, boxed_integer11) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer10 && Lam_compat.eq_boxed_integer boxed_integer1 boxed_integer11 | _ -> false )
381143381155
| Pbintcomp (boxed_integer , comparison) -> (match rhs with Pbintcomp(boxed_integer1, comparison1) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer1 && Lam_compat.eq_comparison comparison comparison1 | _ -> false)
381144381156
| Pbigarraydim dim -> (match rhs with Pbigarraydim dim1 -> dim = dim1 | _ -> false )
381145-
| Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
381157+
(* | Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
381146381158
| Pstring_load_32 b -> (match rhs with Pstring_load_32 b1 -> b = b1 | _ -> false )
381147-
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false )
381159+
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false ) *)
381148381160
(* | Pstring_set_16 b -> (match rhs with Pstring_set_16 b1 -> b = b1 | _ -> false )
381149381161
| Pstring_set_32 b -> (match rhs with Pstring_set_32 b1 -> b = b1 | _ -> false )
381150381162
| Pstring_set_64 b -> (match rhs with Pstring_set_64 b1 -> b = b1 | _ -> false ) *)
@@ -393450,9 +393462,9 @@ let rec no_side_effects (lam : Lam.t) : bool =
393450393462
(* size of the nth dimension of a big array *)
393451393463
| Pbigarraydim _
393452393464
(* load/set 16,32,64 bits from a string: (unsafe)*)
393453-
| Pstring_load_16 _
393465+
(* | Pstring_load_16 _
393454393466
| Pstring_load_32 _
393455-
| Pstring_load_64 _
393467+
| Pstring_load_64 _ *)
393456393468
(* | Pstring_set_16 _
393457393469
| Pstring_set_32 _
393458393470
| Pstring_set_64 _ *)
@@ -394443,7 +394455,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
394443394455
| Pbigarrayset(unsafe, n, kind, layout) ->
394444394456
print_bigarray "set" unsafe kind ppf layout
394445394457
| Pbigarraydim(n) -> fprintf ppf "Bigarray.dim_%i" n
394446-
| Pstring_load_16(unsafe) ->
394458+
(* | Pstring_load_16(unsafe) ->
394447394459
if unsafe then fprintf ppf "string.unsafe_get16"
394448394460
else fprintf ppf "string.get16"
394449394461
| Pstring_load_32(unsafe) ->
@@ -394452,7 +394464,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
394452394464
| Pstring_load_64(unsafe) ->
394453394465
if unsafe then fprintf ppf "string.unsafe_get64"
394454394466
else fprintf ppf "string.get64"
394455-
(* | Pstring_set_16(unsafe) ->
394467+
(* | Pstring_set_16(unsafe) -> *)
394456394468
if unsafe then fprintf ppf "string.unsafe_set16"
394457394469
else fprintf ppf "string.set16"
394458394470
| Pstring_set_32(unsafe) ->
@@ -397231,7 +397243,7 @@ val compare : int64_call
397231397243
(* val of_string : int64_call *)
397232397244
val float_of_bits : int64_call
397233397245
val bits_of_float : int64_call
397234-
val get64 : int64_call
397246+
(* val get64 : int64_call *)
397235397247

397236397248
end = struct
397237397249
#1 "js_long.ml"
@@ -397404,7 +397416,7 @@ let compare (args : J.expression list) =
397404397416

397405397417
(* let of_string (args : J.expression list) =
397406397418
int64_call "of_string" args *)
397407-
let get64 = int64_call "get64"
397419+
(* let get64 = int64_call "get64" *)
397408397420
let float_of_bits = int64_call "float_of_bits"
397409397421
let bits_of_float = int64_call "bits_of_float"
397410397422
let min args =
@@ -399727,7 +399739,7 @@ let translate loc (prim_name : string)
399727399739
call Js_runtime_modules.char
399728399740
| "caml_string_get"
399729399741
->
399730-
call Js_runtime_modules.string
399742+
E.runtime_call Js_runtime_modules.string "get" args
399731399743
| "bytes_to_string"
399732399744
| "bytes_of_string"
399733399745
| "caml_blit_string"
@@ -400794,12 +400806,12 @@ let translate loc
400794400806
E.runtime_call Js_runtime_modules.int32 "caml_int32_bswap" args
400795400807
| Pbbswap Lambda.Pint64
400796400808
-> Js_long.swap args
400797-
| Pstring_load_16 unsafe
400809+
(* | Pstring_load_16 unsafe
400798400810
-> E.runtime_call Js_runtime_modules.string "caml_string_get16" args
400799400811
| Pstring_load_32 unsafe
400800400812
-> E.runtime_call Js_runtime_modules.string "caml_string_get32" args
400801400813
| Pstring_load_64 unsafe
400802-
-> Js_long.get64 args
400814+
-> Js_long.get64 args *)
400803400815

400804400816
| Plazyforce
400805400817
(* let parm = Ident.create "prim" in
@@ -405793,12 +405805,13 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
405793405805
| Plsrbint x -> prim ~primitive:(Plsrbint x) ~args loc
405794405806
| Pasrbint x -> prim ~primitive:(Pasrbint x) ~args loc
405795405807
| Pbigarraydim x -> prim ~primitive:(Pbigarraydim x) ~args loc
405796-
| Pstring_load_16 x -> prim ~primitive:(Pstring_load_16 x) ~args loc
405797-
| Pstring_load_32 x -> prim ~primitive:(Pstring_load_32 x) ~args loc
405798-
| Pstring_load_64 x -> prim ~primitive:(Pstring_load_64 x) ~args loc
405808+
| Pstring_load_16 _
405809+
| Pstring_load_32 _
405810+
| Pstring_load_64 _
405799405811
| Pstring_set_16 _
405800405812
| Pstring_set_32 _
405801-
| Pstring_set_64 _ -> assert false
405813+
| Pstring_set_64 _ ->
405814+
Location.raise_errorf ~loc "unsupported primitive"
405802405815
| Pbigstring_load_16 x -> prim ~primitive:(Pbigstring_load_16 x) ~args loc
405803405816
| Pbigstring_load_32 x -> prim ~primitive:(Pbigstring_load_32 x) ~args loc
405804405817
| Pbigstring_load_64 x -> prim ~primitive:(Pbigstring_load_64 x) ~args loc

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -371862,6 +371862,12 @@ let name_mangle name =
371862371862
| ':' -> Buffer.add_string buffer "$colon"
371863371863
| '?' -> Buffer.add_string buffer "$question"
371864371864
| '&' -> Buffer.add_string buffer "$amp"
371865+
| '(' -> Buffer.add_string buffer "$lpar"
371866+
| ')' -> Buffer.add_string buffer "$rpar"
371867+
| '{' -> Buffer.add_string buffer "$lbrace"
371868+
| '}' -> Buffer.add_string buffer "$lbrace"
371869+
| '[' -> Buffer.add_string buffer "$lbrack"
371870+
| ']' -> Buffer.add_string buffer "$rbrack"
371865371871
| 'a'..'z' | 'A'..'Z'| '_'
371866371872
| '$'
371867371873
| '0'..'9'-> Buffer.add_char buffer c
@@ -371894,6 +371900,12 @@ let name_mangle name =
371894371900
| '?' -> Buffer.add_string buffer "$question"
371895371901
| '&' -> Buffer.add_string buffer "$amp"
371896371902
| '$' -> Buffer.add_string buffer "$dollar"
371903+
| '(' -> Buffer.add_string buffer "$lpar"
371904+
| ')' -> Buffer.add_string buffer "$rpar"
371905+
| '{' -> Buffer.add_string buffer "$lbrace"
371906+
| '}' -> Buffer.add_string buffer "$lbrace"
371907+
| '[' -> Buffer.add_string buffer "$lbrack"
371908+
| ']' -> Buffer.add_string buffer "$rbrack"
371897371909
| 'a'..'z' | 'A'..'Z'| '_'
371898371910
| '0'..'9'-> Buffer.add_char buffer c
371899371911
| _ -> Buffer.add_string buffer "$unknown"
@@ -380757,9 +380769,9 @@ type t =
380757380769
(* size of the nth dimension of a big array *)
380758380770
| Pbigarraydim of int
380759380771
(* load/set 16,32,64 bits from a string: (unsafe)*)
380760-
| Pstring_load_16 of bool
380772+
(* | Pstring_load_16 of bool
380761380773
| Pstring_load_32 of bool
380762-
| Pstring_load_64 of bool
380774+
| Pstring_load_64 of bool *)
380763380775
(* | Pstring_set_16 of bool
380764380776
| Pstring_set_32 of bool
380765380777
| Pstring_set_64 of bool *)
@@ -380943,9 +380955,9 @@ type t =
380943380955
(* size of the nth dimension of a big array *)
380944380956
| Pbigarraydim of int
380945380957
(* load/set 16,32,64 bits from a string: (unsafe)*)
380946-
| Pstring_load_16 of bool
380958+
(* | Pstring_load_16 of bool
380947380959
| Pstring_load_32 of bool
380948-
| Pstring_load_64 of bool
380960+
| Pstring_load_64 of bool *)
380949380961
(* | Pstring_set_16 of bool
380950380962
| Pstring_set_32 of bool
380951380963
| Pstring_set_64 of bool *)
@@ -381142,9 +381154,9 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
381142381154
| Pcvtbint (boxed_integer, boxed_integer1) -> (match rhs with Pcvtbint (boxed_integer10, boxed_integer11) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer10 && Lam_compat.eq_boxed_integer boxed_integer1 boxed_integer11 | _ -> false )
381143381155
| Pbintcomp (boxed_integer , comparison) -> (match rhs with Pbintcomp(boxed_integer1, comparison1) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer1 && Lam_compat.eq_comparison comparison comparison1 | _ -> false)
381144381156
| Pbigarraydim dim -> (match rhs with Pbigarraydim dim1 -> dim = dim1 | _ -> false )
381145-
| Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
381157+
(* | Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
381146381158
| Pstring_load_32 b -> (match rhs with Pstring_load_32 b1 -> b = b1 | _ -> false )
381147-
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false )
381159+
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false ) *)
381148381160
(* | Pstring_set_16 b -> (match rhs with Pstring_set_16 b1 -> b = b1 | _ -> false )
381149381161
| Pstring_set_32 b -> (match rhs with Pstring_set_32 b1 -> b = b1 | _ -> false )
381150381162
| Pstring_set_64 b -> (match rhs with Pstring_set_64 b1 -> b = b1 | _ -> false ) *)
@@ -393450,9 +393462,9 @@ let rec no_side_effects (lam : Lam.t) : bool =
393450393462
(* size of the nth dimension of a big array *)
393451393463
| Pbigarraydim _
393452393464
(* load/set 16,32,64 bits from a string: (unsafe)*)
393453-
| Pstring_load_16 _
393465+
(* | Pstring_load_16 _
393454393466
| Pstring_load_32 _
393455-
| Pstring_load_64 _
393467+
| Pstring_load_64 _ *)
393456393468
(* | Pstring_set_16 _
393457393469
| Pstring_set_32 _
393458393470
| Pstring_set_64 _ *)
@@ -394443,7 +394455,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
394443394455
| Pbigarrayset(unsafe, n, kind, layout) ->
394444394456
print_bigarray "set" unsafe kind ppf layout
394445394457
| Pbigarraydim(n) -> fprintf ppf "Bigarray.dim_%i" n
394446-
| Pstring_load_16(unsafe) ->
394458+
(* | Pstring_load_16(unsafe) ->
394447394459
if unsafe then fprintf ppf "string.unsafe_get16"
394448394460
else fprintf ppf "string.get16"
394449394461
| Pstring_load_32(unsafe) ->
@@ -394452,7 +394464,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
394452394464
| Pstring_load_64(unsafe) ->
394453394465
if unsafe then fprintf ppf "string.unsafe_get64"
394454394466
else fprintf ppf "string.get64"
394455-
(* | Pstring_set_16(unsafe) ->
394467+
(* | Pstring_set_16(unsafe) -> *)
394456394468
if unsafe then fprintf ppf "string.unsafe_set16"
394457394469
else fprintf ppf "string.set16"
394458394470
| Pstring_set_32(unsafe) ->
@@ -397231,7 +397243,7 @@ val compare : int64_call
397231397243
(* val of_string : int64_call *)
397232397244
val float_of_bits : int64_call
397233397245
val bits_of_float : int64_call
397234-
val get64 : int64_call
397246+
(* val get64 : int64_call *)
397235397247

397236397248
end = struct
397237397249
#1 "js_long.ml"
@@ -397404,7 +397416,7 @@ let compare (args : J.expression list) =
397404397416

397405397417
(* let of_string (args : J.expression list) =
397406397418
int64_call "of_string" args *)
397407-
let get64 = int64_call "get64"
397419+
(* let get64 = int64_call "get64" *)
397408397420
let float_of_bits = int64_call "float_of_bits"
397409397421
let bits_of_float = int64_call "bits_of_float"
397410397422
let min args =
@@ -399727,7 +399739,7 @@ let translate loc (prim_name : string)
399727399739
call Js_runtime_modules.char
399728399740
| "caml_string_get"
399729399741
->
399730-
call Js_runtime_modules.string
399742+
E.runtime_call Js_runtime_modules.string "get" args
399731399743
| "bytes_to_string"
399732399744
| "bytes_of_string"
399733399745
| "caml_blit_string"
@@ -400794,12 +400806,12 @@ let translate loc
400794400806
E.runtime_call Js_runtime_modules.int32 "caml_int32_bswap" args
400795400807
| Pbbswap Lambda.Pint64
400796400808
-> Js_long.swap args
400797-
| Pstring_load_16 unsafe
400809+
(* | Pstring_load_16 unsafe
400798400810
-> E.runtime_call Js_runtime_modules.string "caml_string_get16" args
400799400811
| Pstring_load_32 unsafe
400800400812
-> E.runtime_call Js_runtime_modules.string "caml_string_get32" args
400801400813
| Pstring_load_64 unsafe
400802-
-> Js_long.get64 args
400814+
-> Js_long.get64 args *)
400803400815

400804400816
| Plazyforce
400805400817
(* let parm = Ident.create "prim" in
@@ -405793,12 +405805,13 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
405793405805
| Plsrbint x -> prim ~primitive:(Plsrbint x) ~args loc
405794405806
| Pasrbint x -> prim ~primitive:(Pasrbint x) ~args loc
405795405807
| Pbigarraydim x -> prim ~primitive:(Pbigarraydim x) ~args loc
405796-
| Pstring_load_16 x -> prim ~primitive:(Pstring_load_16 x) ~args loc
405797-
| Pstring_load_32 x -> prim ~primitive:(Pstring_load_32 x) ~args loc
405798-
| Pstring_load_64 x -> prim ~primitive:(Pstring_load_64 x) ~args loc
405808+
| Pstring_load_16 _
405809+
| Pstring_load_32 _
405810+
| Pstring_load_64 _
405799405811
| Pstring_set_16 _
405800405812
| Pstring_set_32 _
405801-
| Pstring_set_64 _ -> assert false
405813+
| Pstring_set_64 _ ->
405814+
Location.raise_errorf ~loc "unsupported primitive"
405802405815
| Pbigstring_load_16 x -> prim ~primitive:(Pbigstring_load_16 x) ~args loc
405803405816
| Pbigstring_load_32 x -> prim ~primitive:(Pbigstring_load_32 x) ~args loc
405804405817
| Pbigstring_load_64 x -> prim ~primitive:(Pbigstring_load_64 x) ~args loc

0 commit comments

Comments
 (0)