Skip to content

Commit 749ea89

Browse files
committed
Do not special case variants with only 1 case with payload.
Also the comment is not emitted anymore, since there's always a tag. Not special casing means that the representation is uniform, and does not change when the type is extended. This is important with zero cost ffi, where the runtime representation is exposed to the user, to reduce possible surprises.
1 parent 98b17b0 commit 749ea89

Some content is hidden

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

48 files changed

+856
-428
lines changed

jscomp/test/bal_set_mini.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function height(param) {
1212
function create(l, v, r) {
1313
var hl = height(l);
1414
var hr = height(r);
15-
return /* Node */{
15+
return {
16+
TAG: "Node",
1617
_0: l,
1718
_1: v,
1819
_2: r,
@@ -39,7 +40,8 @@ function bal(l, v, r) {
3940
}
4041
}
4142
if (hr <= (hl + 2 | 0)) {
42-
return /* Node */{
43+
return {
44+
TAG: "Node",
4345
_0: l,
4446
_1: v,
4547
_2: r,
@@ -73,7 +75,8 @@ function compare_int(x, y) {
7375

7476
function add(x, t) {
7577
if (typeof t !== "object") {
76-
return /* Node */{
78+
return {
79+
TAG: "Node",
7780
_0: "Empty",
7881
_1: x,
7982
_2: "Empty",

jscomp/test/bdd.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ function mkNode(low, v, high) {
170170
}
171171
} else {
172172
var n_2 = (nodeC.contents = nodeC.contents + 1 | 0, nodeC.contents);
173-
var n$1 = /* Node */{
173+
var n$1 = {
174+
TAG: "Node",
174175
_0: low,
175176
_1: v,
176177
_2: n_2,

jscomp/test/defunctor_make_test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function height(param) {
2626
function create(l, x, d, r) {
2727
var hl = height(l);
2828
var hr = height(r);
29-
return /* Node */{
29+
return {
30+
TAG: "Node",
3031
_0: l,
3132
_1: x,
3233
_2: d,
@@ -65,7 +66,8 @@ function bal(l, x, d, r) {
6566
};
6667
}
6768
if (hr <= (hl + 2 | 0)) {
68-
return /* Node */{
69+
return {
70+
TAG: "Node",
6971
_0: l,
7072
_1: x,
7173
_2: d,
@@ -99,7 +101,8 @@ function bal(l, x, d, r) {
99101

100102
function add(x, data, compare, param) {
101103
if (typeof param !== "object") {
102-
return /* Node */{
104+
return {
105+
TAG: "Node",
103106
_0: "Empty",
104107
_1: x,
105108
_2: data,
@@ -113,7 +116,8 @@ function add(x, data, compare, param) {
113116
var l = param._0;
114117
var c = compare(x, v);
115118
if (c === 0) {
116-
return /* Node */{
119+
return {
120+
TAG: "Node",
117121
_0: l,
118122
_1: x,
119123
_2: data,

jscomp/test/demo_int_map.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function height(param) {
1212
function create(l, x, d, r) {
1313
var hl = height(l);
1414
var hr = height(r);
15-
return /* Node */{
15+
return {
16+
TAG: "Node",
1617
l: l,
1718
v: x,
1819
d: d,
@@ -51,7 +52,8 @@ function bal(l, x, d, r) {
5152
};
5253
}
5354
if (hr <= (hl + 2 | 0)) {
54-
return /* Node */{
55+
return {
56+
TAG: "Node",
5557
l: l,
5658
v: x,
5759
d: d,
@@ -85,7 +87,8 @@ function bal(l, x, d, r) {
8587

8688
function add(x, data, m) {
8789
if (typeof m !== "object") {
88-
return /* Node */{
90+
return {
91+
TAG: "Node",
8992
l: "Empty",
9093
v: x,
9194
d: data,
@@ -102,7 +105,8 @@ function add(x, data, m) {
102105
if (d === data) {
103106
return m;
104107
} else {
105-
return /* Node */{
108+
return {
109+
TAG: "Node",
106110
l: l,
107111
v: x,
108112
d: data,

jscomp/test/demo_page.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function map(f, param) {
2424
if (typeof param !== "object") {
2525
return "Nil";
2626
} else {
27-
return /* Cons */{
27+
return {
28+
TAG: "Cons",
2829
_0: Curry._1(f, param._0),
2930
_1: map(f, param._1)
3031
};

jscomp/test/flexible_array_test.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function sub(_tr, _k) {
3232
function update(tr, k, w) {
3333
if (typeof tr !== "object") {
3434
if (k === 1) {
35-
return /* Br */{
35+
return {
36+
TAG: "Br",
3637
_0: w,
3738
_1: "Lf",
3839
_2: "Lf"
@@ -46,21 +47,24 @@ function update(tr, k, w) {
4647
var r = tr._2;
4748
var l = tr._1;
4849
if (k === 1) {
49-
return /* Br */{
50+
return {
51+
TAG: "Br",
5052
_0: w,
5153
_1: l,
5254
_2: r
5355
};
5456
}
5557
var v = tr._0;
5658
if (k % 2 === 0) {
57-
return /* Br */{
59+
return {
60+
TAG: "Br",
5861
_0: v,
5962
_1: update(l, k / 2 | 0, w),
6063
_2: r
6164
};
6265
} else {
63-
return /* Br */{
66+
return {
67+
TAG: "Br",
6468
_0: v,
6569
_1: l,
6670
_2: update(r, k / 2 | 0, w)
@@ -82,13 +86,15 @@ function $$delete(tr, n) {
8286
var l = tr._1;
8387
var v = tr._0;
8488
if (n % 2 === 0) {
85-
return /* Br */{
89+
return {
90+
TAG: "Br",
8691
_0: v,
8792
_1: $$delete(l, n / 2 | 0),
8893
_2: r
8994
};
9095
} else {
91-
return /* Br */{
96+
return {
97+
TAG: "Br",
9298
_0: v,
9399
_1: l,
94100
_2: $$delete(r, n / 2 | 0)
@@ -98,13 +104,15 @@ function $$delete(tr, n) {
98104

99105
function loext(tr, w) {
100106
if (typeof tr !== "object") {
101-
return /* Br */{
107+
return {
108+
TAG: "Br",
102109
_0: w,
103110
_1: "Lf",
104111
_2: "Lf"
105112
};
106113
} else {
107-
return /* Br */{
114+
return {
115+
TAG: "Br",
108116
_0: w,
109117
_1: loext(tr._2, tr._0),
110118
_2: tr._1
@@ -121,7 +129,8 @@ function lorem(tr) {
121129
}
122130
var l = tr._1;
123131
if (typeof l === "object") {
124-
return /* Br */{
132+
return {
133+
TAG: "Br",
125134
_0: l._0,
126135
_1: tr._2,
127136
_2: lorem(l)

jscomp/test/flow_parser_reg_test.js

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5283,7 +5283,8 @@ function create(l, v, r) {
52835283
hl = typeof l !== "object" ? 0 : l.h;
52845284
var hr;
52855285
hr = typeof r !== "object" ? 0 : r.h;
5286-
return /* Node */{
5286+
return {
5287+
TAG: "Node",
52875288
l: l,
52885289
v: v,
52895290
r: r,
@@ -5320,7 +5321,8 @@ function bal(l, v, r) {
53205321
};
53215322
}
53225323
if (hr <= (hl + 2 | 0)) {
5323-
return /* Node */{
5324+
return {
5325+
TAG: "Node",
53245326
l: l,
53255327
v: v,
53265328
r: r,
@@ -5352,7 +5354,8 @@ function bal(l, v, r) {
53525354

53535355
function add(x, t) {
53545356
if (typeof t !== "object") {
5355-
return /* Node */{
5357+
return {
5358+
TAG: "Node",
53565359
l: "Empty",
53575360
v: x,
53585361
r: "Empty",
@@ -6131,7 +6134,8 @@ function to_parse(env, parse) {
61316134
try {
61326135
var result = Curry._1(parse, env);
61336136
reset_token_sink(true, env, saved_state.token_buffer);
6134-
return /* ParsedSuccessfully */{
6137+
return {
6138+
TAG: "ParsedSuccessfully",
61356139
_0: result
61366140
};
61376141
}
@@ -6183,7 +6187,8 @@ function create$2(l, v, r) {
61836187
hl = typeof l !== "object" ? 0 : l.h;
61846188
var hr;
61856189
hr = typeof r !== "object" ? 0 : r.h;
6186-
return /* Node */{
6190+
return {
6191+
TAG: "Node",
61876192
l: l,
61886193
v: v,
61896194
r: r,
@@ -6220,7 +6225,8 @@ function bal$1(l, v, r) {
62206225
};
62216226
}
62226227
if (hr <= (hl + 2 | 0)) {
6223-
return /* Node */{
6228+
return {
6229+
TAG: "Node",
62246230
l: l,
62256231
v: v,
62266232
r: r,
@@ -6252,7 +6258,8 @@ function bal$1(l, v, r) {
62526258

62536259
function add$1(x, t) {
62546260
if (typeof t !== "object") {
6255-
return /* Node */{
6261+
return {
6262+
TAG: "Node",
62566263
l: "Empty",
62576264
v: x,
62586265
r: "Empty",
@@ -6308,7 +6315,8 @@ function height$2(param) {
63086315
function create$3(l, x, d, r) {
63096316
var hl = height$2(l);
63106317
var hr = height$2(r);
6311-
return /* Node */{
6318+
return {
6319+
TAG: "Node",
63126320
l: l,
63136321
v: x,
63146322
d: d,
@@ -6347,7 +6355,8 @@ function bal$2(l, x, d, r) {
63476355
};
63486356
}
63496357
if (hr <= (hl + 2 | 0)) {
6350-
return /* Node */{
6358+
return {
6359+
TAG: "Node",
63516360
l: l,
63526361
v: x,
63536362
d: d,
@@ -6381,7 +6390,8 @@ function bal$2(l, x, d, r) {
63816390

63826391
function add$2(x, data, m) {
63836392
if (typeof m !== "object") {
6384-
return /* Node */{
6393+
return {
6394+
TAG: "Node",
63856395
l: "Empty",
63866396
v: x,
63876397
d: data,
@@ -6398,7 +6408,8 @@ function add$2(x, data, m) {
63986408
if (d === data) {
63996409
return m;
64006410
} else {
6401-
return /* Node */{
6411+
return {
6412+
TAG: "Node",
64026413
l: l,
64036414
v: x,
64046415
d: data,
@@ -6463,7 +6474,8 @@ function create$4(l, v, r) {
64636474
hl = typeof l !== "object" ? 0 : l.h;
64646475
var hr;
64656476
hr = typeof r !== "object" ? 0 : r.h;
6466-
return /* Node */{
6477+
return {
6478+
TAG: "Node",
64676479
l: l,
64686480
v: v,
64696481
r: r,
@@ -6500,7 +6512,8 @@ function bal$3(l, v, r) {
65006512
};
65016513
}
65026514
if (hr <= (hl + 2 | 0)) {
6503-
return /* Node */{
6515+
return {
6516+
TAG: "Node",
65046517
l: l,
65056518
v: v,
65066519
r: r,
@@ -6532,7 +6545,8 @@ function bal$3(l, v, r) {
65326545

65336546
function add$3(x, t) {
65346547
if (typeof t !== "object") {
6535-
return /* Node */{
6548+
return {
6549+
TAG: "Node",
65366550
l: "Empty",
65376551
v: x,
65386552
r: "Empty",
@@ -15060,7 +15074,8 @@ function predicate(env) {
1506015074
var loc = btwn(checks_loc, rparen_loc);
1506115075
return [
1506215076
loc,
15063-
/* Declared */{
15077+
{
15078+
TAG: "Declared",
1506415079
_0: exp
1506515080
}
1506615081
];

jscomp/test/gpr_5280_optimize_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33

4-
var a = /* Color */{
4+
var a = {
5+
TAG: "Color",
56
_0: "#ffff"
67
};
78

0 commit comments

Comments
 (0)