Skip to content

Commit 0035dc6

Browse files
committed
always print string quote as \"
1 parent 158f7f5 commit 0035dc6

File tree

97 files changed

+700
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+700
-616
lines changed

jscomp/bin/whole_compiler.ml

+12-16
Original file line numberDiff line numberDiff line change
@@ -83351,6 +83351,7 @@ module L = struct
8335183351
let minus_minus = "--"
8335283352
let caml_block = "Block"
8335383353
let caml_block_create = "__"
83354+
let case = "case"
8335483355
end
8335583356
let return_indent = (String.length L.return / Ext_pp.indent_length)
8335683357

@@ -83486,7 +83487,7 @@ let property_string f s =
8348683487
if Ext_ident.property_no_need_convert s then
8348783488
P.string f s
8348883489
else
83489-
pp_string f ~quote:(best_string_quote s) s
83490+
pp_string f s
8349083491

8349183492
(** used in property access
8349283493
{[
@@ -83503,13 +83504,10 @@ let property_access f s =
8350383504
else
8350483505
begin
8350583506
P.bracket_group f 1 @@ fun _ ->
83506-
pp_string f ~quote:( best_string_quote s) s
83507+
pp_string f s
8350783508
end
8350883509

8350983510

83510-
(* TODO: check utf's correct semantics *)
83511-
let pp_quote_string f s =
83512-
pp_string f ~quote:(best_string_quote s ) s
8351383511

8351483512
let rec comma_idents cxt f (ls : Ident.t list) =
8351583513
match ls with
@@ -83800,8 +83798,9 @@ and output_one : 'a .
8380083798
let cxt =
8380183799
P.group f 1 @@ fun _ ->
8380283800
P.group f 1 @@ (fun _ ->
83803-
P.string f "case ";
83804-
pp_cond f e;
83801+
P.string f L.case;
83802+
P.space f ;
83803+
pp_cond f e; (* could be integer or string*)
8380583804
P.space f ;
8380683805
P.string f L.colon );
8380783806

@@ -84034,9 +84033,8 @@ and
8403484033
(*TODO --
8403584034
when utf8-> it will not escape '\\' which is definitely not we want
8403684035
*)
84037-
let quote = best_string_quote s in
84038-
pp_string f ~quote s;
84039-
cxt
84036+
pp_string f s;
84037+
cxt
8404084038

8404184039
| Raw_js_code (s,info) ->
8404284040
begin match info with
@@ -84822,7 +84820,7 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t =
8482284820
in
8482384821
P.space f;
8482484822
P.brace_vgroup f 1 @@ fun _ ->
84825-
let cxt = loop cxt f (fun f i -> pp_quote_string f i ) cc in
84823+
let cxt = loop cxt f (fun f i -> pp_string f i ) cc in
8482684824
(match def with
8482784825
| None -> cxt
8482884826
| Some def ->
@@ -84955,7 +84953,7 @@ let requires require_lit cxt f (modules : (Ident.t * string) list ) =
8495584953
P.space f;
8495684954
P.string f require_lit;
8495784955
P.paren_group f 0 @@ (fun _ ->
84958-
pp_string f ~quote:(best_string_quote s) file );
84956+
pp_string f file );
8495984957
semi f ;
8496084958
P.newline f ;
8496184959
) reversed_list;
@@ -84984,9 +84982,7 @@ let imports cxt f (modules : (Ident.t * string) list ) =
8498484982
P.nspace f (margin - String.length s + 1) ;
8498584983
P.string f L.from;
8498684984
P.space f;
84987-
84988-
pp_string f ~quote:(best_string_quote s) (file ^ ".js")
84989-
;
84985+
pp_string f (file ^ ".js") ;
8499084986
semi f ;
8499184987
P.newline f ;
8499284988
) reversed_list;
@@ -85051,7 +85047,7 @@ let amd_program ~output_prefix kind f ( x : J.deps_program) =
8505185047
let s = Js_program_loader.string_of_module_id ~output_prefix kind x in
8505285048
P.string f L.comma ;
8505385049
P.space f;
85054-
pp_string f ~quote:(best_string_quote s) s;
85050+
pp_string f s;
8505585051
) x.modules ;
8505685052
P.string f "]";
8505785053
P.string f L.comma;

jscomp/core/js_dump.ml

+12-16
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ module L = struct
118118
let minus_minus = "--"
119119
let caml_block = "Block"
120120
let caml_block_create = "__"
121+
let case = "case"
121122
end
122123
let return_indent = (String.length L.return / Ext_pp.indent_length)
123124

@@ -253,7 +254,7 @@ let property_string f s =
253254
if Ext_ident.property_no_need_convert s then
254255
P.string f s
255256
else
256-
pp_string f ~quote:(best_string_quote s) s
257+
pp_string f s
257258

258259
(** used in property access
259260
{[
@@ -270,13 +271,10 @@ let property_access f s =
270271
else
271272
begin
272273
P.bracket_group f 1 @@ fun _ ->
273-
pp_string f ~quote:( best_string_quote s) s
274+
pp_string f s
274275
end
275276

276277

277-
(* TODO: check utf's correct semantics *)
278-
let pp_quote_string f s =
279-
pp_string f ~quote:(best_string_quote s ) s
280278

281279
let rec comma_idents cxt f (ls : Ident.t list) =
282280
match ls with
@@ -567,8 +565,9 @@ and output_one : 'a .
567565
let cxt =
568566
P.group f 1 @@ fun _ ->
569567
P.group f 1 @@ (fun _ ->
570-
P.string f "case ";
571-
pp_cond f e;
568+
P.string f L.case;
569+
P.space f ;
570+
pp_cond f e; (* could be integer or string*)
572571
P.space f ;
573572
P.string f L.colon );
574573

@@ -801,9 +800,8 @@ and
801800
(*TODO --
802801
when utf8-> it will not escape '\\' which is definitely not we want
803802
*)
804-
let quote = best_string_quote s in
805-
pp_string f ~quote s;
806-
cxt
803+
pp_string f s;
804+
cxt
807805

808806
| Raw_js_code (s,info) ->
809807
begin match info with
@@ -1589,7 +1587,7 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t =
15891587
in
15901588
P.space f;
15911589
P.brace_vgroup f 1 @@ fun _ ->
1592-
let cxt = loop cxt f (fun f i -> pp_quote_string f i ) cc in
1590+
let cxt = loop cxt f (fun f i -> pp_string f i ) cc in
15931591
(match def with
15941592
| None -> cxt
15951593
| Some def ->
@@ -1722,7 +1720,7 @@ let requires require_lit cxt f (modules : (Ident.t * string) list ) =
17221720
P.space f;
17231721
P.string f require_lit;
17241722
P.paren_group f 0 @@ (fun _ ->
1725-
pp_string f ~quote:(best_string_quote s) file );
1723+
pp_string f file );
17261724
semi f ;
17271725
P.newline f ;
17281726
) reversed_list;
@@ -1751,9 +1749,7 @@ let imports cxt f (modules : (Ident.t * string) list ) =
17511749
P.nspace f (margin - String.length s + 1) ;
17521750
P.string f L.from;
17531751
P.space f;
1754-
1755-
pp_string f ~quote:(best_string_quote s) (file ^ ".js")
1756-
;
1752+
pp_string f (file ^ ".js") ;
17571753
semi f ;
17581754
P.newline f ;
17591755
) reversed_list;
@@ -1818,7 +1814,7 @@ let amd_program ~output_prefix kind f ( x : J.deps_program) =
18181814
let s = Js_program_loader.string_of_module_id ~output_prefix kind x in
18191815
P.string f L.comma ;
18201816
P.space f;
1821-
pp_string f ~quote:(best_string_quote s) s;
1817+
pp_string f s;
18221818
) x.modules ;
18231819
P.string f "]";
18241820
P.string f L.comma;

jscomp/test/.depend

+1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ submodule_call.cmj : submodule.cmj
419419
swap_test.cmj : ../stdlib/printf.cmj mt.cmj ../stdlib/list.cmj \
420420
../stdlib/int64.cmj ../stdlib/int32.cmj ../stdlib/format.cmj \
421421
../stdlib/array.cmj
422+
switch_case_test.cmj : mt.cmj
422423
tailcall_inline_test.cmj : mt.cmj ../stdlib/array.cmj
423424
test.cmj :
424425
test_alias.cmj : test_global_print.cmj

jscomp/test/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ OTHERS := literals a test_ari test_export2 test_internalOO test_obj_simple_ffi t
127127
gpr_1438\
128128
unicode_type_error\
129129
arity_deopt\
130+
switch_case_test\
130131
bb
131132

132133
# bs_uncurry_test

jscomp/test/a_filename_test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function test(param, param$1) {
3030
return Ext_filename.node_relative_path(/* true */1, param, param$1);
3131
}
3232

33-
eq('File "a_filename_test.ml", line 10, characters 5-12', /* tuple */[
33+
eq("File \"a_filename_test.ml\", line 10, characters 5-12", /* tuple */[
3434
Ext_filename.combine("/tmp", "subdir/file.txt"),
3535
Ext_filename.combine("/tmp", "/a/tmp.txt"),
3636
Ext_filename.combine("/a/tmp.txt", "subdir/file.txt")
@@ -40,69 +40,69 @@ eq('File "a_filename_test.ml", line 10, characters 5-12', /* tuple */[
4040
"/a/tmp.txt/subdir/file.txt"
4141
]);
4242

43-
eq('File "a_filename_test.ml", line 22, characters 5-12', test(/* `File */[
43+
eq("File \"a_filename_test.ml\", line 22, characters 5-12", test(/* `File */[
4444
781515420,
4545
"./a/b.c"
4646
], /* `File */[
4747
781515420,
4848
"./a/u/g.c"
4949
]), "./u/g");
5050

51-
eq('File "a_filename_test.ml", line 27, characters 5-12', test(/* `File */[
51+
eq("File \"a_filename_test.ml\", line 27, characters 5-12", test(/* `File */[
5252
781515420,
5353
"./a/b.c"
5454
], /* `File */[
5555
781515420,
5656
"xxxghsoghos/ghsoghso/node_modules/buckle-stdlib/list.js"
5757
]), "buckle-stdlib/list.js");
5858

59-
eq('File "a_filename_test.ml", line 33, characters 5-12', test(/* `File */[
59+
eq("File \"a_filename_test.ml\", line 33, characters 5-12", test(/* `File */[
6060
781515420,
6161
"./a/b.c"
6262
], /* `File */[
6363
781515420,
6464
"xxxghsoghos/ghsoghso/node_modules//buckle-stdlib/list.js"
6565
]), "buckle-stdlib/list.js");
6666

67-
eq('File "a_filename_test.ml", line 39, characters 5-12', test(/* `File */[
67+
eq("File \"a_filename_test.ml\", line 39, characters 5-12", test(/* `File */[
6868
781515420,
6969
"./a/b.c"
7070
], /* `File */[
7171
781515420,
7272
"xxxghsoghos/ghsoghso/node_modules/./buckle-stdlib/list.js"
7373
]), "buckle-stdlib/list.js");
7474

75-
eq('File "a_filename_test.ml", line 45, characters 5-12', test(/* `File */[
75+
eq("File \"a_filename_test.ml\", line 45, characters 5-12", test(/* `File */[
7676
781515420,
7777
"./a/c.js"
7878
], /* `File */[
7979
781515420,
8080
"./a/b"
8181
]), "./b");
8282

83-
eq('File "a_filename_test.ml", line 50, characters 5-12', test(/* `File */[
83+
eq("File \"a_filename_test.ml\", line 50, characters 5-12", test(/* `File */[
8484
781515420,
8585
"./a/c"
8686
], /* `File */[
8787
781515420,
8888
"./a/b.js"
8989
]), "./b");
9090

91-
eq('File "a_filename_test.ml", line 55, characters 5-12', test(/* `Dir */[
91+
eq("File \"a_filename_test.ml\", line 55, characters 5-12", test(/* `Dir */[
9292
3405101,
9393
"./a/"
9494
], /* `File */[
9595
781515420,
9696
"./a/b.js"
9797
]), "./b");
9898

99-
eq('File "a_filename_test.ml", line 60, characters 5-12', Ext_filename.get_extension("a.txt"), ".txt");
99+
eq("File \"a_filename_test.ml\", line 60, characters 5-12", Ext_filename.get_extension("a.txt"), ".txt");
100100

101-
eq('File "a_filename_test.ml", line 64, characters 5-12', Ext_filename.get_extension("a"), "");
101+
eq("File \"a_filename_test.ml\", line 64, characters 5-12", Ext_filename.get_extension("a"), "");
102102

103-
eq('File "a_filename_test.ml", line 68, characters 5-12', Ext_filename.get_extension(".txt"), ".txt");
103+
eq("File \"a_filename_test.ml\", line 68, characters 5-12", Ext_filename.get_extension(".txt"), ".txt");
104104

105-
eq('File "a_filename_test.ml", line 73, characters 5-12', $$Array.map(Ext_filename.normalize_absolute_path, /* array */[
105+
eq("File \"a_filename_test.ml\", line 73, characters 5-12", $$Array.map(Ext_filename.normalize_absolute_path, /* array */[
106106
"/gsho/./..",
107107
"/a/b/../c../d/e/f",
108108
"/a/b/../c/../d/e/f",

jscomp/test/ari_regress_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var suites_001 = /* :: */[
6060
],
6161
/* :: */[
6262
/* tuple */[
63-
'File "ari_regress_test.ml", line 20, characters 4-11',
63+
"File \"ari_regress_test.ml\", line 20, characters 4-11",
6464
function () {
6565
return /* Eq */Block.__(0, [
6666
h[0],

jscomp/test/arity_deopt.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ function f3(x) {
4747
};
4848
}
4949

50-
eq('File "arity_deopt.ml", line 45, characters 7-14', 6, f0(1, 2, 3));
50+
eq("File \"arity_deopt.ml\", line 45, characters 7-14", 6, f0(1, 2, 3));
5151

52-
eq('File "arity_deopt.ml", line 46, characters 11-18', 6, function (y, z) {
52+
eq("File \"arity_deopt.ml\", line 46, characters 11-18", 6, function (y, z) {
5353
return (1 + y | 0) + z | 0;
5454
}(2, 3));
5555

56-
eq('File "arity_deopt.ml", line 47, characters 15-22', 6, Curry._1(f2(1, 2), 3));
56+
eq("File \"arity_deopt.ml\", line 47, characters 15-22", 6, Curry._1(f2(1, 2), 3));
5757

58-
eq('File "arity_deopt.ml", line 48, characters 15-22', 6, function (y, z) {
58+
eq("File \"arity_deopt.ml\", line 48, characters 15-22", 6, function (y, z) {
5959
return (1 + y | 0) + z | 0;
6060
}(2, 3));
6161

jscomp/test/array_subtle_test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,34 @@ var v = /* int array */[
3535
3
3636
];
3737

38-
eq('File "array_subtle_test.ml", line 12, characters 5-12', /* tuple */[
38+
eq("File \"array_subtle_test.ml\", line 12, characters 5-12", /* tuple */[
3939
4,
4040
v.length
4141
]);
4242

43-
eq('File "array_subtle_test.ml", line 15, characters 5-12', /* tuple */[
43+
eq("File \"array_subtle_test.ml\", line 15, characters 5-12", /* tuple */[
4444
5,
4545
v.push(3)
4646
]);
4747

48-
eq('File "array_subtle_test.ml", line 16, characters 5-12', /* tuple */[
48+
eq("File \"array_subtle_test.ml\", line 16, characters 5-12", /* tuple */[
4949
5,
5050
v.length
5151
]);
5252

53-
eq('File "array_subtle_test.ml", line 17, characters 5-12', /* tuple */[
53+
eq("File \"array_subtle_test.ml\", line 17, characters 5-12", /* tuple */[
5454
5,
5555
v.length
5656
]);
5757

58-
eq('File "array_subtle_test.ml", line 21, characters 5-12', /* tuple */[
58+
eq("File \"array_subtle_test.ml\", line 21, characters 5-12", /* tuple */[
5959
3,
6060
Caml_array.caml_array_get(v, 2)
6161
]);
6262

6363
Caml_array.caml_array_set(v, 2, 4);
6464

65-
eq('File "array_subtle_test.ml", line 23, characters 5-12', /* tuple */[
65+
eq("File \"array_subtle_test.ml\", line 23, characters 5-12", /* tuple */[
6666
4,
6767
Caml_array.caml_array_get(v, 2)
6868
]);
@@ -71,7 +71,7 @@ while(v.length > 0) {
7171
Js_primitive.undefined_to_opt(v.pop());
7272
};
7373

74-
eq('File "array_subtle_test.ml", line 29, characters 5-12', /* tuple */[
74+
eq("File \"array_subtle_test.ml\", line 29, characters 5-12", /* tuple */[
7575
0,
7676
v.length
7777
]);

jscomp/test/basic_module_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function eq(f, a, b) {
2525
return Mt_global.collect_eq(test_id, suites, f, a, b);
2626
}
2727

28-
eq('File "basic_module_test.ml", line 39, characters 12-19', count[0], 1);
28+
eq("File \"basic_module_test.ml\", line 39, characters 12-19", count[0], 1);
2929

3030
Mt.from_pair_suites("basic_module_test.ml", suites[0]);
3131

0 commit comments

Comments
 (0)