Skip to content

Commit f79e613

Browse files
committed
Support inline records
1 parent d9f2a38 commit f79e613

8 files changed

+88
-88
lines changed

jscomp/core/js_dump.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
774774
if p.num_nonconst = 1 then tails
775775
else
776776
( Js_op.Lit L.tag,
777-
if !Js_config.debug then tag else { tag with comment = Some p.name }
777+
E.str p.name
778778
)
779779
:: tails
780780
in

jscomp/test/inline_record_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ function eq(loc, x, y) {
1717
}
1818

1919
var v = {
20-
TAG: /* A0 */0,
20+
TAG: "A0",
2121
lbl: 3,
2222
more: /* [] */0
2323
};
2424

2525
var v1 = {
26-
TAG: /* A1 */1,
26+
TAG: "A1",
2727
more: {
2828
hd: 1,
2929
tl: {
@@ -88,14 +88,14 @@ function ff(x) {
8888
}
8989

9090
var v4 = {
91-
TAG: /* A0 */0,
91+
TAG: "A0",
9292
x: 0,
9393
y: 0,
9494
z: 0
9595
};
9696

9797
var v5 = {
98-
TAG: /* A1 */1,
98+
TAG: "A1",
9999
z: 0
100100
};
101101

jscomp/test/large_record_duplication_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function f1(x) {
102102
eq("File \"large_record_duplication_test.ml\", line 140, characters 6-13", get_x0(f1(v1)), 1);
103103

104104
var v2 = {
105-
TAG: /* A0 */0,
105+
TAG: "A0",
106106
x0: 9,
107107
x1: 9,
108108
x2: 9,

jscomp/test/rec_value_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ function ptl(l) {
297297
var y00 = {};
298298

299299
Caml_obj.update_dummy(y00, {
300-
TAG: /* C1 */1,
300+
TAG: "C1",
301301
hd: 1,
302302
tail: y00
303303
});

jscomp/test/record_extension_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function f2_with(x) {
4848
return x;
4949
} else {
5050
return {
51-
TAG: /* C */0,
51+
TAG: "C",
5252
x: 0,
5353
y: x.y
5454
};

jscomp/test/record_regression.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,28 @@ function setAA(ao) {
6161
}
6262

6363
var ir0 = {
64-
TAG: /* V0 */0,
64+
TAG: "V0",
6565
x0: "v0",
6666
x3: 3
6767
};
6868

6969
var ir1 = {
70-
TAG: /* V0 */0,
70+
TAG: "V0",
7171
x0: "v0",
7272
x1: "v1",
7373
x3: 3
7474
};
7575

7676
var ir2 = {
77-
TAG: /* V0 */0,
77+
TAG: "V0",
7878
x0: "v0",
7979
x1: "v1",
8080
x2: 2,
8181
x3: 3
8282
};
8383

8484
var ir3 = {
85-
TAG: /* V1 */1,
85+
TAG: "V1",
8686
y0: "v0",
8787
y1: 1
8888
};

lib/es6/arg.js

+38-38
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function help_action(param) {
6262
throw {
6363
RE_EXN_ID: Stop,
6464
_1: {
65-
TAG: /* Unknown */0,
65+
TAG: "Unknown",
6666
_0: "-help"
6767
},
6868
Error: new Error()
@@ -82,7 +82,7 @@ function add_help(speclist) {
8282
hd: [
8383
"-help",
8484
{
85-
TAG: /* Unit */0,
85+
TAG: "Unit",
8686
_0: help_action
8787
},
8888
" Display this list of options"
@@ -105,7 +105,7 @@ function add_help(speclist) {
105105
hd: [
106106
"--help",
107107
{
108-
TAG: /* Unit */0,
108+
TAG: "Unit",
109109
_0: help_action
110110
},
111111
" Display this list of options"
@@ -128,7 +128,7 @@ function usage_b(buf, speclist, errmsg) {
128128
}
129129
var spec = param[1];
130130
var key = param[0];
131-
if (spec.TAG !== /* Symbol */11) {
131+
if (spec.TAG !== "Symbol") {
132132
return $$Buffer.add_string(buf, " " + key + " " + doc + "\n");
133133
}
134134
var sym = make_symlist("{", "|", "}", spec._0);
@@ -194,8 +194,8 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
194194
var convert_error = function (error) {
195195
var b = $$Buffer.create(200);
196196
var progname = initpos < argv.contents.length ? Caml_array.get(argv.contents, initpos) : "(?)";
197-
switch (error.TAG | 0) {
198-
case /* Unknown */0 :
197+
switch (error.TAG) {
198+
case "Unknown" :
199199
var s = error._0;
200200
switch (s) {
201201
case "--help" :
@@ -205,23 +205,23 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
205205
$$Buffer.add_string(b, progname + ": unknown option '" + s + "'.\n");
206206
}
207207
break;
208-
case /* Wrong */1 :
208+
case "Wrong" :
209209
$$Buffer.add_string(b, progname + ": wrong argument '" + error._1 + "'; option '" + error._0 + "' expects " + error._2 + ".\n");
210210
break;
211-
case /* Missing */2 :
211+
case "Missing" :
212212
$$Buffer.add_string(b, progname + ": option '" + error._0 + "' needs an argument.\n");
213213
break;
214-
case /* Message */3 :
214+
case "Message" :
215215
$$Buffer.add_string(b, progname + ": " + error._0 + ".\n");
216216
break;
217217

218218
}
219219
usage_b(b, speclist.contents, errmsg);
220220
if (Caml_obj.equal(error, {
221-
TAG: /* Unknown */0,
221+
TAG: "Unknown",
222222
_0: "-help"
223223
}) || Caml_obj.equal(error, {
224-
TAG: /* Unknown */0,
224+
TAG: "Unknown",
225225
_0: "--help"
226226
})) {
227227
return {
@@ -263,7 +263,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
263263
throw {
264264
RE_EXN_ID: Stop,
265265
_1: {
266-
TAG: /* Unknown */0,
266+
TAG: "Unknown",
267267
_0: s
268268
},
269269
Error: new Error()
@@ -284,7 +284,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
284284
throw {
285285
RE_EXN_ID: Stop,
286286
_1: {
287-
TAG: /* Wrong */1,
287+
TAG: "Wrong",
288288
_0: s,
289289
_1: follow,
290290
_2: "no argument"
@@ -304,7 +304,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
304304
throw {
305305
RE_EXN_ID: Stop,
306306
_1: {
307-
TAG: /* Missing */2,
307+
TAG: "Missing",
308308
_0: s
309309
},
310310
Error: new Error()
@@ -323,10 +323,10 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
323323
}(follow));
324324
var treat_action = (function(s){
325325
return function treat_action(f) {
326-
switch (f.TAG | 0) {
327-
case /* Unit */0 :
326+
switch (f.TAG) {
327+
case "Unit" :
328328
return Curry._1(f._0, undefined);
329-
case /* Bool */1 :
329+
case "Bool" :
330330
var arg = get_arg(undefined);
331331
var s$1 = bool_of_string_opt(arg);
332332
if (s$1 !== undefined) {
@@ -335,7 +335,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
335335
throw {
336336
RE_EXN_ID: Stop,
337337
_1: {
338-
TAG: /* Wrong */1,
338+
TAG: "Wrong",
339339
_0: s,
340340
_1: arg,
341341
_2: "a boolean"
@@ -344,22 +344,22 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
344344
};
345345
}
346346
return consume_arg(undefined);
347-
case /* Set */2 :
347+
case "Set" :
348348
no_arg(undefined);
349349
f._0.contents = true;
350350
return ;
351-
case /* Clear */3 :
351+
case "Clear" :
352352
no_arg(undefined);
353353
f._0.contents = false;
354354
return ;
355-
case /* String */4 :
355+
case "String" :
356356
var arg$1 = get_arg(undefined);
357357
Curry._1(f._0, arg$1);
358358
return consume_arg(undefined);
359-
case /* Set_string */5 :
359+
case "Set_string" :
360360
f._0.contents = get_arg(undefined);
361361
return consume_arg(undefined);
362-
case /* Int */6 :
362+
case "Int" :
363363
var arg$2 = get_arg(undefined);
364364
var x = int_of_string_opt(arg$2);
365365
if (x !== undefined) {
@@ -368,7 +368,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
368368
throw {
369369
RE_EXN_ID: Stop,
370370
_1: {
371-
TAG: /* Wrong */1,
371+
TAG: "Wrong",
372372
_0: s,
373373
_1: arg$2,
374374
_2: "an integer"
@@ -377,7 +377,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
377377
};
378378
}
379379
return consume_arg(undefined);
380-
case /* Set_int */7 :
380+
case "Set_int" :
381381
var arg$3 = get_arg(undefined);
382382
var x$1 = int_of_string_opt(arg$3);
383383
if (x$1 !== undefined) {
@@ -386,7 +386,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
386386
throw {
387387
RE_EXN_ID: Stop,
388388
_1: {
389-
TAG: /* Wrong */1,
389+
TAG: "Wrong",
390390
_0: s,
391391
_1: arg$3,
392392
_2: "an integer"
@@ -395,7 +395,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
395395
};
396396
}
397397
return consume_arg(undefined);
398-
case /* Float */8 :
398+
case "Float" :
399399
var arg$4 = get_arg(undefined);
400400
var x$2 = float_of_string_opt(arg$4);
401401
if (x$2 !== undefined) {
@@ -404,7 +404,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
404404
throw {
405405
RE_EXN_ID: Stop,
406406
_1: {
407-
TAG: /* Wrong */1,
407+
TAG: "Wrong",
408408
_0: s,
409409
_1: arg$4,
410410
_2: "a float"
@@ -413,7 +413,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
413413
};
414414
}
415415
return consume_arg(undefined);
416-
case /* Set_float */9 :
416+
case "Set_float" :
417417
var arg$5 = get_arg(undefined);
418418
var x$3 = float_of_string_opt(arg$5);
419419
if (x$3 !== undefined) {
@@ -422,7 +422,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
422422
throw {
423423
RE_EXN_ID: Stop,
424424
_1: {
425-
TAG: /* Wrong */1,
425+
TAG: "Wrong",
426426
_0: s,
427427
_1: arg$5,
428428
_2: "a float"
@@ -431,9 +431,9 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
431431
};
432432
}
433433
return consume_arg(undefined);
434-
case /* Tuple */10 :
434+
case "Tuple" :
435435
return List.iter(treat_action, f._0);
436-
case /* Symbol */11 :
436+
case "Symbol" :
437437
var symb = f._0;
438438
var arg$6 = get_arg(undefined);
439439
if (List.mem(arg$6, symb)) {
@@ -443,21 +443,21 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
443443
throw {
444444
RE_EXN_ID: Stop,
445445
_1: {
446-
TAG: /* Wrong */1,
446+
TAG: "Wrong",
447447
_0: s,
448448
_1: arg$6,
449449
_2: "one of: " + make_symlist("", " ", "", symb)
450450
},
451451
Error: new Error()
452452
};
453-
case /* Rest */12 :
453+
case "Rest" :
454454
var f$1 = f._0;
455455
while(current.contents < (argv.contents.length - 1 | 0)) {
456456
Curry._1(f$1, Caml_array.get(argv.contents, current.contents + 1 | 0));
457457
consume_arg(undefined);
458458
};
459459
return ;
460-
case /* Expand */13 :
460+
case "Expand" :
461461
if (!allow_expand) {
462462
throw {
463463
RE_EXN_ID: "Invalid_argument",
@@ -494,7 +494,7 @@ function parse_and_expand_argv_dynamic_aux(allow_expand, current, argv, speclist
494494
var m = Caml_js_exceptions.internalToOCamlException(raw_m);
495495
if (m.RE_EXN_ID === Bad) {
496496
throw convert_error({
497-
TAG: /* Message */3,
497+
TAG: "Message",
498498
_0: m._1
499499
});
500500
}
@@ -636,7 +636,7 @@ function second_word(s) {
636636

637637
function max_arg_len(cur, param) {
638638
var kwd = param[0];
639-
if (param[1].TAG === /* Symbol */11) {
639+
if (param[1].TAG === "Symbol") {
640640
return Caml.int_max(cur, kwd.length);
641641
} else {
642642
return Caml.int_max(cur, kwd.length + second_word(param[2]) | 0);
@@ -668,7 +668,7 @@ function align(limitOpt, speclist) {
668668
if (param[2] === "") {
669669
return param;
670670
}
671-
if (spec.TAG === /* Symbol */11) {
671+
if (spec.TAG === "Symbol") {
672672
var msg = param[2];
673673
var cutcol = second_word(msg);
674674
var spaces = " ".repeat(Caml.int_max(0, len$1 - cutcol | 0) + 3 | 0);

0 commit comments

Comments
 (0)