Skip to content

Commit 249adb0

Browse files
committed
improve print while(true)
1 parent 93b8105 commit 249adb0

Some content is hidden

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

62 files changed

+350
-339
lines changed

jscomp/js_dump.ml

+24-13
Original file line numberDiff line numberDiff line change
@@ -983,19 +983,30 @@ and statement_desc top cxt f (s : J.statement_desc) : Ext_pp_scope.t =
983983
block cxt f s2 )
984984

985985
| While (label, e, s, _env) -> (* FIXME: print scope as well *)
986-
(match label with
987-
| Some i ->
988-
P.string f i ;
989-
P.string f L.colon;
990-
P.newline f ;
991-
| None -> ());
992-
P.string f "while";
993-
let cxt = P.paren_group f 1 @@ fun _ -> expression 0 cxt f e in
994-
P.space f ;
995-
let cxt = block cxt f s in
996-
semi f;
997-
cxt
998-
986+
begin
987+
(match label with
988+
| Some i ->
989+
P.string f i ;
990+
P.string f L.colon;
991+
P.newline f ;
992+
| None -> ());
993+
let cxt =
994+
match e.expression_desc with
995+
| Number (Int {i = 1}) ->
996+
P.string f "while";
997+
P.string f "(true)";
998+
P.space f ;
999+
cxt
1000+
| _ ->
1001+
P.string f "while";
1002+
let cxt = P.paren_group f 1 @@ fun _ -> expression 0 cxt f e in
1003+
P.space f ;
1004+
cxt
1005+
in
1006+
let cxt = block cxt f s in
1007+
semi f;
1008+
cxt
1009+
end
9991010
| ForRange (for_ident_expression, finish, id, direction, s, env) ->
10001011
let action cxt =
10011012
P.vgroup f 0 @@ fun _ ->

jscomp/runtime/caml_array.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function caml_array_sub(x, offset, len) {
1414
}
1515

1616
function len(_acc, _l) {
17-
while(/* true */1) {
17+
while(true) {
1818
var l = _l;
1919
var acc = _acc;
2020
if (l) {
@@ -28,7 +28,7 @@ function len(_acc, _l) {
2828
}
2929

3030
function fill(arr, _i, _l) {
31-
while(/* true */1) {
31+
while(true) {
3232
var l = _l;
3333
var i = _i;
3434
if (l) {

jscomp/runtime/caml_oo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function caml_get_public_method(obj, tag, cacheid) {
1313
}
1414
else {
1515
var aux = function (_i) {
16-
while(/* true */1) {
16+
while(true) {
1717
var i = _i;
1818
if (i < 3) {
1919
throw [

jscomp/runtime/curry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Caml_array = require("./caml_array");
44

55
function curry(_f, _args) {
6-
while(/* true */1) {
6+
while(true) {
77
var args = _args;
88
var f = _f;
99
var arity = f.length;

jscomp/stdlib/arg.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var Stop = [
2929
];
3030

3131
function assoc3(x, _l) {
32-
while(/* true */1) {
32+
while(true) {
3333
var l = _l;
3434
if (l) {
3535
var match = l[1];
@@ -777,7 +777,7 @@ function second_word(s) {
777777
var len = s.length;
778778
try {
779779
var _n = $$String.index(s, /* " " */32);
780-
while(/* true */1) {
780+
while(true) {
781781
var n = _n;
782782
if (n >= len) {
783783
return len;

jscomp/stdlib/array.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function mapi(f, a) {
130130
function to_list(a) {
131131
var _i = a.length - 1;
132132
var _res = /* [] */0;
133-
while(/* true */1) {
133+
while(true) {
134134
var res = _res;
135135
var i = _i;
136136
if (i < 0) {
@@ -148,7 +148,7 @@ function to_list(a) {
148148
}
149149

150150
function list_length(_accu, _param) {
151-
while(/* true */1) {
151+
while(true) {
152152
var param = _param;
153153
var accu = _accu;
154154
if (param) {
@@ -166,7 +166,7 @@ function of_list(l) {
166166
var a = Caml_array.caml_make_vect(list_length(0, l), l[1]);
167167
var _i = 1;
168168
var _param = l[2];
169-
while(/* true */1) {
169+
while(true) {
170170
var param = _param;
171171
var i = _i;
172172
if (param) {
@@ -242,7 +242,7 @@ function sort(cmp, a) {
242242
var l$1 = l;
243243
var _i = i;
244244
var e$1 = e;
245-
while(/* true */1) {
245+
while(true) {
246246
var i$1 = _i;
247247
var j = maxson(l$1, i$1);
248248
if (cmp(a[j], e$1) > 0) {
@@ -269,7 +269,7 @@ function sort(cmp, a) {
269269
try {
270270
var l$1 = l;
271271
var _i = i;
272-
while(/* true */1) {
272+
while(true) {
273273
var i$1 = _i;
274274
var j = maxson(l$1, i$1);
275275
a[i$1] = a[j];
@@ -286,7 +286,7 @@ function sort(cmp, a) {
286286
}
287287
};
288288
var trickleup = function (_i, e) {
289-
while(/* true */1) {
289+
while(true) {
290290
var i = _i;
291291
var father = (i - 1) / 3 | 0;
292292
if (i === father) {
@@ -348,7 +348,7 @@ function stable_sort(cmp, a) {
348348
var _i2 = src2ofs;
349349
var _s2 = src2[src2ofs];
350350
var _d = dstofs;
351-
while(/* true */1) {
351+
while(true) {
352352
var d = _d;
353353
var s2 = _s2;
354354
var i2 = _i2;

jscomp/stdlib/buffer.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function advance_to_closing(opening, closing, k, s, start) {
181181
var _k = k;
182182
var _i = start;
183183
var lim = s.length;
184-
while(/* true */1) {
184+
while(true) {
185185
var i = _i;
186186
var k$1 = _k;
187187
if (i >= lim) {
@@ -213,7 +213,7 @@ function advance_to_closing(opening, closing, k, s, start) {
213213
function advance_to_non_alpha(s, start) {
214214
var _i = start;
215215
var lim = s.length;
216-
while(/* true */1) {
216+
while(true) {
217217
var i = _i;
218218
if (i >= lim) {
219219
return lim;
@@ -305,7 +305,7 @@ function add_substitute(b, f, s) {
305305
var lim = s.length;
306306
var _previous = /* " " */32;
307307
var _i = 0;
308-
while(/* true */1) {
308+
while(true) {
309309
var i = _i;
310310
var previous = _previous;
311311
if (i < lim) {

jscomp/stdlib/bytes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function uncapitalize(s) {
371371
}
372372

373373
function index_rec(s, lim, _i, c) {
374-
while(/* true */1) {
374+
while(true) {
375375
var i = _i;
376376
if (i >= lim) {
377377
throw Caml_exceptions.Not_found;
@@ -402,7 +402,7 @@ function index_from(s, i, c) {
402402
}
403403

404404
function rindex_rec(s, _i, c) {
405-
while(/* true */1) {
405+
while(true) {
406406
var i = _i;
407407
if (i < 0) {
408408
throw Caml_exceptions.Not_found;

jscomp/stdlib/camlinternalFormat.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ function bprint_char_set(buf, char_set) {
360360
}
361361
};
362362
var print_out = function (set, _i) {
363-
while(/* true */1) {
363+
while(true) {
364364
var i = _i;
365365
if (i < 256) {
366366
if (is_in_char_set(set, Pervasives.char_of_int(i))) {
@@ -625,7 +625,7 @@ function bprint_string_literal(buf, str) {
625625
}
626626

627627
function bprint_fmtty(buf, _fmtty) {
628-
while(/* true */1) {
628+
while(true) {
629629
var fmtty = _fmtty;
630630
if (typeof fmtty === "number") {
631631
return /* () */0;
@@ -714,7 +714,7 @@ function int_of_custom_arity(param) {
714714
function bprint_fmt(buf, fmt) {
715715
var _fmt = fmt;
716716
var _ign_flag = /* false */0;
717-
while(/* true */1) {
717+
while(true) {
718718
var ign_flag = _ign_flag;
719719
var fmt$1 = _fmt;
720720
if (typeof fmt$1 === "number") {
@@ -2055,7 +2055,7 @@ function fmtty_of_formatting_gen(formatting_gen) {
20552055
}
20562056

20572057
function fmtty_of_fmt(_fmtty) {
2058-
while(/* true */1) {
2058+
while(true) {
20592059
var fmtty = _fmtty;
20602060
if (typeof fmtty === "number") {
20612061
return /* End_of_fmtty */0;
@@ -3699,7 +3699,7 @@ function convert_float(fconv, prec, x) {
36993699
else {
37003700
var len = str.length;
37013701
var is_valid = function (_i) {
3702-
while(/* true */1) {
3702+
while(true) {
37033703
var i = _i;
37043704
if (i === len) {
37053705
return /* false */0;
@@ -3770,7 +3770,7 @@ function string_of_fmtty(fmtty) {
37703770
}
37713771

37723772
function make_printf(_k, o, _acc, _fmt) {
3773-
while(/* true */1) {
3773+
while(true) {
37743774
var fmt = _fmt;
37753775
var acc = _acc;
37763776
var k = _k;
@@ -4460,7 +4460,7 @@ function make_custom(k, o, acc, rest, arity, f) {
44604460
}
44614461

44624462
function output_acc(o, _acc) {
4463-
while(/* true */1) {
4463+
while(true) {
44644464
var acc = _acc;
44654465
var exit = 0;
44664466
if (typeof acc === "number") {
@@ -4518,7 +4518,7 @@ function output_acc(o, _acc) {
45184518
}
45194519

45204520
function bufput_acc(b, _acc) {
4521-
while(/* true */1) {
4521+
while(true) {
45224522
var acc = _acc;
45234523
var exit = 0;
45244524
if (typeof acc === "number") {
@@ -4576,7 +4576,7 @@ function bufput_acc(b, _acc) {
45764576
}
45774577

45784578
function strput_acc(b, _acc) {
4579-
while(/* true */1) {
4579+
while(true) {
45804580
var acc = _acc;
45814581
var exit = 0;
45824582
if (typeof acc === "number") {
@@ -4668,7 +4668,7 @@ function open_box_of_string(str) {
46684668
])(str);
46694669
};
46704670
var parse_spaces = function (_i) {
4671-
while(/* true */1) {
4671+
while(true) {
46724672
var i = _i;
46734673
if (i === len) {
46744674
return i;
@@ -4690,7 +4690,7 @@ function open_box_of_string(str) {
46904690
};
46914691
};
46924692
var parse_lword = function (_, _j) {
4693-
while(/* true */1) {
4693+
while(true) {
46944694
var j = _j;
46954695
if (j === len) {
46964696
return j;
@@ -4707,7 +4707,7 @@ function open_box_of_string(str) {
47074707
};
47084708
};
47094709
var parse_int = function (_, _j) {
4710-
while(/* true */1) {
4710+
while(true) {
47114711
var j = _j;
47124712
if (j === len) {
47134713
return j;
@@ -5019,7 +5019,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
50195019
var lit_start = beg_ind;
50205020
var _str_ind = beg_ind;
50215021
var end_ind$1 = end_ind;
5022-
while(/* true */1) {
5022+
while(true) {
50235023
var str_ind = _str_ind;
50245024
if (str_ind === end_ind$1) {
50255025
return add_literal(lit_start, str_ind, /* End_of_format */0);
@@ -5115,7 +5115,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
51155115
return /* () */0;
51165116
};
51175117
var _str_ind = str_ind;
5118-
while(/* true */1) {
5118+
while(true) {
51195119
var str_ind$1 = _str_ind;
51205120
if (str_ind$1 === end_ind) {
51215121
unexpected_end_of_format(end_ind);
@@ -7000,7 +7000,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
70007000
return parse_char_set_after_char(str_ind + 1, end_ind, c);
70017001
};
70027002
var parse_char_set_content = function (_str_ind, end_ind) {
7003-
while(/* true */1) {
7003+
while(true) {
70047004
var str_ind = _str_ind;
70057005
if (str_ind === end_ind) {
70067006
unexpected_end_of_format(end_ind);
@@ -7021,7 +7021,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
70217021
};
70227022
};
70237023
var parse_char_set_after_char = function (_str_ind, end_ind, _c) {
7024-
while(/* true */1) {
7024+
while(true) {
70257025
var c = _c;
70267026
var str_ind = _str_ind;
70277027
if (str_ind === end_ind) {
@@ -7140,7 +7140,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
71407140
];
71417141
};
71427142
var parse_spaces = function (_str_ind, end_ind) {
7143-
while(/* true */1) {
7143+
while(true) {
71447144
var str_ind = _str_ind;
71457145
if (str_ind === end_ind) {
71467146
unexpected_end_of_format(end_ind);
@@ -7154,7 +7154,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
71547154
};
71557155
};
71567156
var parse_positive = function (_str_ind, end_ind, _acc) {
7157-
while(/* true */1) {
7157+
while(true) {
71587158
var acc = _acc;
71597159
var str_ind = _str_ind;
71607160
if (str_ind === end_ind) {
@@ -7298,7 +7298,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
72987298
}
72997299
};
73007300
var search_subformat_end = function (_str_ind, end_ind, c) {
7301-
while(/* true */1) {
7301+
while(true) {
73027302
var str_ind = _str_ind;
73037303
if (str_ind === end_ind) {
73047304
failwith_message([
@@ -7505,7 +7505,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
75057505

75067506
};
75077507
var compute_int_conv = function (pct_ind, str_ind, _plus, _sharp, _space, symb) {
7508-
while(/* true */1) {
7508+
while(true) {
75097509
var space = _space;
75107510
var sharp = _sharp;
75117511
var plus = _plus;
@@ -7751,7 +7751,7 @@ function fmt_ebb_of_string(legacy_behavior, str) {
77517751
};
77527752
};
77537753
var compute_float_conv = function (pct_ind, str_ind, _plus, _space, symb) {
7754-
while(/* true */1) {
7754+
while(true) {
77557755
var space = _space;
77567756
var plus = _plus;
77577757
if (plus !== 0) {

0 commit comments

Comments
 (0)