flow-parser 0.320.0 → 0.322.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +14 -26
  2. package/{oxidized/oxidized-src → dist}/FlowParser.js +3 -53
  3. package/{oxidized/oxidized-src → dist}/FlowParserDeserializer.js +3 -41
  4. package/{oxidized → dist}/FlowParserNodeDeserializers.js +0 -7
  5. package/{oxidized → dist}/FlowParserWASM.js +1 -1
  6. package/{oxidized/oxidized-src → dist}/HermesParserDecodeUTF8String.js +0 -9
  7. package/dist/ParserOptions.js +7 -0
  8. package/{oxidized → dist}/babel/TransformESTreeToBabel.js +9 -157
  9. package/{oxidized → dist}/estree/StripFlowTypes.js +0 -26
  10. package/{oxidized/oxidized-src → dist}/estree/StripFlowTypesForBabel.js +0 -24
  11. package/{oxidized/oxidized-src → dist}/estree/TransformComponentSyntax.js +0 -87
  12. package/{oxidized/oxidized-src → dist}/estree/TransformEnumSyntax.js +0 -12
  13. package/{oxidized/oxidized-src → dist}/estree/TransformMatchSyntax.js +3 -99
  14. package/{oxidized → dist}/estree/TransformRecordSyntax.js +3 -31
  15. package/{oxidized → dist}/getModuleDocblock.js +0 -21
  16. package/{oxidized → dist}/index.js +25 -99
  17. package/{oxidized → dist}/transform/SimpleTransform.js +0 -21
  18. package/{oxidized → dist}/transform/astArrayMutationHelpers.js +0 -9
  19. package/{oxidized/oxidized-src → dist}/transform/astNodeMutationHelpers.js +4 -26
  20. package/{oxidized/oxidized-src → dist}/transform/print/comments/comments.js +2 -51
  21. package/{oxidized → dist}/transform/print/comments/prettier/common/util.js +0 -49
  22. package/{oxidized → dist}/transform/print/comments/prettier/language-js/comments.js +0 -111
  23. package/{oxidized/oxidized-src → dist}/transform/print/comments/prettier/language-js/loc.js +0 -6
  24. package/{oxidized/oxidized-src → dist}/transform/print/comments/prettier/language-js/printer-estree.js +0 -3
  25. package/{oxidized/oxidized-src → dist}/transform/print/comments/prettier/language-js/utils.js +0 -20
  26. package/{oxidized/oxidized-src → dist}/transform/print/comments/prettier/main/comments.js +2 -63
  27. package/{oxidized/oxidized-src → dist}/transform/print/comments/prettier/utils/get-last.js +0 -1
  28. package/{oxidized → dist}/transform/print/print.js +6 -22
  29. package/{oxidized/oxidized-src → dist}/traverse/SimpleTraverser.js +2 -22
  30. package/{oxidized/oxidized-src → dist}/traverse/getVisitorKeys.js +3 -9
  31. package/{oxidized/oxidized-src → dist}/utils/Builders.js +1 -17
  32. package/{oxidized → dist}/utils/GenID.js +0 -7
  33. package/{oxidized/oxidized-src → dist}/utils/createSyntaxError.js +0 -1
  34. package/{oxidized → dist}/utils/isReservedWord.js +0 -2
  35. package/{oxidized → dist}/utils/mutateESTreeASTForPrettier.js +6 -21
  36. package/package.json +6 -7
  37. package/flow_parser.js +0 -14585
  38. package/oxidized/FlowParser.js +0 -249
  39. package/oxidized/FlowParserDeserializer.js +0 -209
  40. package/oxidized/HermesParserDecodeUTF8String.js +0 -45
  41. package/oxidized/ParserOptions.js +0 -8
  42. package/oxidized/estree/StripFlowTypesForBabel.js +0 -191
  43. package/oxidized/estree/TransformComponentSyntax.js +0 -764
  44. package/oxidized/estree/TransformEnumSyntax.js +0 -92
  45. package/oxidized/estree/TransformMatchSyntax.js +0 -990
  46. package/oxidized/oxidized-src/FlowParserNodeDeserializers.js +0 -1781
  47. package/oxidized/oxidized-src/ParserOptions.js +0 -8
  48. package/oxidized/oxidized-src/babel/TransformESTreeToBabel.js +0 -1063
  49. package/oxidized/oxidized-src/estree/StripFlowTypes.js +0 -158
  50. package/oxidized/oxidized-src/estree/TransformRecordSyntax.js +0 -283
  51. package/oxidized/oxidized-src/generated/ESTreeVisitorKeys.js +0 -234
  52. package/oxidized/oxidized-src/getModuleDocblock.js +0 -87
  53. package/oxidized/oxidized-src/index.js +0 -220
  54. package/oxidized/oxidized-src/transform/SimpleTransform.js +0 -95
  55. package/oxidized/oxidized-src/transform/astArrayMutationHelpers.js +0 -52
  56. package/oxidized/oxidized-src/transform/print/comments/prettier/common/util.js +0 -235
  57. package/oxidized/oxidized-src/transform/print/comments/prettier/language-js/comments.js +0 -663
  58. package/oxidized/oxidized-src/transform/print/print.js +0 -68
  59. package/oxidized/oxidized-src/utils/GenID.js +0 -37
  60. package/oxidized/oxidized-src/utils/isReservedWord.js +0 -53
  61. package/oxidized/oxidized-src/utils/mutateESTreeASTForPrettier.js +0 -85
  62. package/oxidized/transform/astNodeMutationHelpers.js +0 -142
  63. package/oxidized/transform/print/comments/comments.js +0 -245
  64. package/oxidized/transform/print/comments/prettier/language-js/loc.js +0 -30
  65. package/oxidized/transform/print/comments/prettier/language-js/printer-estree.js +0 -23
  66. package/oxidized/transform/print/comments/prettier/language-js/utils.js +0 -89
  67. package/oxidized/transform/print/comments/prettier/main/comments.js +0 -374
  68. package/oxidized/transform/print/comments/prettier/utils/get-last.js +0 -5
  69. package/oxidized/transform/print/detachedNodeTypes.js +0 -1
  70. package/oxidized/traverse/SimpleTraverser.js +0 -90
  71. package/oxidized/traverse/getVisitorKeys.js +0 -29
  72. package/oxidized/utils/Builders.js +0 -181
  73. package/oxidized/utils/createSyntaxError.js +0 -15
  74. /package/{oxidized → dist}/FlowParser.js.flow +0 -0
  75. /package/{oxidized → dist}/FlowParserDeserializer.js.flow +0 -0
  76. /package/{oxidized → dist}/FlowParserNodeDeserializers.js.flow +0 -0
  77. /package/{oxidized → dist}/FlowParserWASM.js.flow +0 -0
  78. /package/{oxidized → dist}/HermesAST.js.flow +0 -0
  79. /package/{oxidized → dist}/HermesParserDecodeUTF8String.js.flow +0 -0
  80. /package/{oxidized → dist}/ParserOptions.js.flow +0 -0
  81. /package/{oxidized → dist}/babel/TransformESTreeToBabel.js.flow +0 -0
  82. /package/{oxidized → dist}/estree/StripFlowTypes.js.flow +0 -0
  83. /package/{oxidized → dist}/estree/StripFlowTypesForBabel.js.flow +0 -0
  84. /package/{oxidized → dist}/estree/TransformComponentSyntax.js.flow +0 -0
  85. /package/{oxidized → dist}/estree/TransformEnumSyntax.js.flow +0 -0
  86. /package/{oxidized → dist}/estree/TransformMatchSyntax.js.flow +0 -0
  87. /package/{oxidized → dist}/estree/TransformRecordSyntax.js.flow +0 -0
  88. /package/{oxidized → dist}/generated/ESTreeVisitorKeys.js +0 -0
  89. /package/{oxidized → dist}/generated/ESTreeVisitorKeys.js.flow +0 -0
  90. /package/{oxidized → dist}/getModuleDocblock.js.flow +0 -0
  91. /package/{oxidized → dist}/index.js.flow +0 -0
  92. /package/{oxidized → dist}/transform/SimpleTransform.js.flow +0 -0
  93. /package/{oxidized → dist}/transform/astArrayMutationHelpers.js.flow +0 -0
  94. /package/{oxidized → dist}/transform/astNodeMutationHelpers.js.flow +0 -0
  95. /package/{oxidized → dist}/transform/print/comments/comments.js.flow +0 -0
  96. /package/{oxidized/oxidized-src → dist}/transform/print/detachedNodeTypes.js +0 -0
  97. /package/{oxidized → dist}/transform/print/detachedNodeTypes.js.flow +0 -0
  98. /package/{oxidized → dist}/transform/print/print.js.flow +0 -0
  99. /package/{oxidized → dist}/traverse/SimpleTraverser.js.flow +0 -0
  100. /package/{oxidized → dist}/traverse/getVisitorKeys.js.flow +0 -0
  101. /package/{oxidized → dist}/utils/Builders.js.flow +0 -0
  102. /package/{oxidized → dist}/utils/GenID.js.flow +0 -0
  103. /package/{oxidized → dist}/utils/createSyntaxError.js.flow +0 -0
  104. /package/{oxidized → dist}/utils/isReservedWord.js.flow +0 -0
  105. /package/{oxidized → dist}/utils/mutateESTreeASTForPrettier.js.flow +0 -0
@@ -4,44 +4,32 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.transformProgram = transformProgram;
7
-
8
7
  var _SimpleTransform = require("../transform/SimpleTransform");
9
-
10
8
  var _astNodeMutationHelpers = require("../transform/astNodeMutationHelpers");
11
-
12
9
  var _createSyntaxError = require("../utils/createSyntaxError");
13
-
14
10
  var _Builders = require("../utils/Builders");
15
-
16
11
  var _GenID = _interopRequireDefault(require("../utils/GenID"));
17
-
18
- function _interopRequireDefault(obj) {
19
- return obj && obj.__esModule ? obj : {
20
- default: obj
12
+ function _interopRequireDefault(e) {
13
+ return e && e.__esModule ? e : {
14
+ default: e
21
15
  };
22
16
  }
23
-
24
17
  let genID = null;
25
-
26
18
  function genIdent() {
27
19
  if (genID == null) {
28
20
  throw Error('GenID must be initialized at the start of the transform.');
29
21
  }
30
-
31
22
  return (0, _Builders.ident)(genID.id());
32
23
  }
33
-
34
24
  function objKeyToString(node) {
35
25
  switch (node.type) {
36
26
  case 'Identifier':
37
27
  return node.name;
38
-
39
28
  case 'Literal':
40
29
  {
41
30
  const {
42
31
  value
43
32
  } = node;
44
-
45
33
  if (typeof value === 'number') {
46
34
  return String(value);
47
35
  } else if (typeof value === 'string') {
@@ -52,7 +40,6 @@ function objKeyToString(node) {
52
40
  }
53
41
  }
54
42
  }
55
-
56
43
  function convertMemberPattern(pattern) {
57
44
  const {
58
45
  base,
@@ -61,7 +48,6 @@ function convertMemberPattern(pattern) {
61
48
  range
62
49
  } = pattern;
63
50
  const object = base.type === 'MatchIdentifierPattern' ? base.id : convertMemberPattern(base);
64
-
65
51
  if (property.type === 'Identifier') {
66
52
  return {
67
53
  type: 'MemberExpression',
@@ -88,21 +74,17 @@ function convertMemberPattern(pattern) {
88
74
  };
89
75
  }
90
76
  }
91
-
92
77
  function checkDuplicateBindingName(seenBindingNames, node, name) {
93
78
  if (seenBindingNames.has(name)) {
94
79
  throw (0, _createSyntaxError.createSyntaxError)(node, `Duplicate variable name '${name}' in match case pattern.`);
95
80
  }
96
-
97
81
  seenBindingNames.add(name);
98
82
  }
99
-
100
83
  function checkBindingKind(node, kind) {
101
84
  if (kind === 'var') {
102
85
  throw (0, _createSyntaxError.createSyntaxError)(node, `'var' bindings are not allowed. Use 'const' or 'let'.`);
103
86
  }
104
87
  }
105
-
106
88
  function needsPropExistsCond(pattern) {
107
89
  switch (pattern.type) {
108
90
  case 'MatchWildcardPattern':
@@ -110,14 +92,12 @@ function needsPropExistsCond(pattern) {
110
92
  case 'MatchIdentifierPattern':
111
93
  case 'MatchMemberPattern':
112
94
  return true;
113
-
114
95
  case 'MatchLiteralPattern':
115
96
  case 'MatchUnaryPattern':
116
97
  case 'MatchObjectPattern':
117
98
  case 'MatchInstancePattern':
118
99
  case 'MatchArrayPattern':
119
100
  return false;
120
-
121
101
  case 'MatchAsPattern':
122
102
  {
123
103
  const {
@@ -125,7 +105,6 @@ function needsPropExistsCond(pattern) {
125
105
  } = pattern;
126
106
  return needsPropExistsCond(asPattern);
127
107
  }
128
-
129
108
  case 'MatchOrPattern':
130
109
  {
131
110
  const {
@@ -135,7 +114,6 @@ function needsPropExistsCond(pattern) {
135
114
  }
136
115
  }
137
116
  }
138
-
139
117
  function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
140
118
  const conditions = [];
141
119
  const bindings = [];
@@ -148,14 +126,11 @@ function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
148
126
  } = prop;
149
127
  objKeys.push(objKey);
150
128
  const name = objKeyToString(objKey);
151
-
152
129
  if (seenNames.has(name)) {
153
130
  throw (0, _createSyntaxError.createSyntaxError)(propPattern, `Duplicate property name '${name}' in match object pattern.`);
154
131
  }
155
-
156
132
  seenNames.add(name);
157
133
  const propKey = key.concat(objKey);
158
-
159
134
  if (needsPropExistsCond(propPattern)) {
160
135
  conditions.push({
161
136
  type: 'prop-exists',
@@ -163,7 +138,6 @@ function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
163
138
  propName: name
164
139
  });
165
140
  }
166
-
167
141
  const {
168
142
  conditions: childConditions,
169
143
  bindings: childBindings
@@ -171,7 +145,6 @@ function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
171
145
  conditions.push(...childConditions);
172
146
  bindings.push(...childBindings);
173
147
  });
174
-
175
148
  if (rest != null && rest.argument != null) {
176
149
  const {
177
150
  id,
@@ -187,23 +160,19 @@ function analyzeProperties(key, pattern, seenBindingNames, properties, rest) {
187
160
  id
188
161
  });
189
162
  }
190
-
191
163
  return {
192
164
  conditions,
193
165
  bindings
194
166
  };
195
167
  }
196
-
197
168
  function constructorExpression(constructor) {
198
169
  switch (constructor.type) {
199
170
  case 'MatchIdentifierPattern':
200
171
  return constructor.id;
201
-
202
172
  case 'MatchMemberPattern':
203
173
  return convertMemberPattern(constructor);
204
174
  }
205
175
  }
206
-
207
176
  function analyzePattern(pattern, key, seenBindingNames) {
208
177
  switch (pattern.type) {
209
178
  case 'MatchWildcardPattern':
@@ -213,7 +182,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
213
182
  bindings: []
214
183
  };
215
184
  }
216
-
217
185
  case 'MatchLiteralPattern':
218
186
  {
219
187
  const {
@@ -229,7 +197,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
229
197
  bindings: []
230
198
  };
231
199
  }
232
-
233
200
  case 'MatchUnaryPattern':
234
201
  {
235
202
  const {
@@ -238,11 +205,9 @@ function analyzePattern(pattern, key, seenBindingNames) {
238
205
  loc,
239
206
  range
240
207
  } = pattern;
241
-
242
208
  if (argument.value === 0) {
243
209
  throw (0, _createSyntaxError.createSyntaxError)(pattern, `'+0' and '-0' are not yet supported in match unary patterns.`);
244
210
  }
245
-
246
211
  const arg = {
247
212
  type: 'UnaryExpression',
248
213
  operator,
@@ -263,7 +228,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
263
228
  bindings: []
264
229
  };
265
230
  }
266
-
267
231
  case 'MatchIdentifierPattern':
268
232
  {
269
233
  const {
@@ -282,7 +246,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
282
246
  bindings: []
283
247
  };
284
248
  }
285
-
286
249
  case 'MatchMemberPattern':
287
250
  {
288
251
  const arg = convertMemberPattern(pattern);
@@ -296,7 +259,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
296
259
  bindings: []
297
260
  };
298
261
  }
299
-
300
262
  case 'MatchBindingPattern':
301
263
  {
302
264
  const {
@@ -316,18 +278,15 @@ function analyzePattern(pattern, key, seenBindingNames) {
316
278
  bindings: [binding]
317
279
  };
318
280
  }
319
-
320
281
  case 'MatchAsPattern':
321
282
  {
322
283
  const {
323
284
  pattern: asPattern,
324
285
  target
325
286
  } = pattern;
326
-
327
287
  if (asPattern.type === 'MatchBindingPattern') {
328
288
  throw (0, _createSyntaxError.createSyntaxError)(pattern, `Match 'as' patterns are not allowed directly on binding patterns.`);
329
289
  }
330
-
331
290
  const {
332
291
  conditions,
333
292
  bindings
@@ -347,7 +306,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
347
306
  bindings: bindings.concat(binding)
348
307
  };
349
308
  }
350
-
351
309
  case 'MatchArrayPattern':
352
310
  {
353
311
  const {
@@ -371,7 +329,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
371
329
  conditions.push(...childConditions);
372
330
  bindings.push(...childBindings);
373
331
  });
374
-
375
332
  if (rest != null && rest.argument != null) {
376
333
  const {
377
334
  id,
@@ -387,13 +344,11 @@ function analyzePattern(pattern, key, seenBindingNames) {
387
344
  id
388
345
  });
389
346
  }
390
-
391
347
  return {
392
348
  conditions,
393
349
  bindings
394
350
  };
395
351
  }
396
-
397
352
  case 'MatchObjectPattern':
398
353
  {
399
354
  const {
@@ -413,7 +368,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
413
368
  bindings
414
369
  };
415
370
  }
416
-
417
371
  case 'MatchInstancePattern':
418
372
  {
419
373
  const {
@@ -437,7 +391,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
437
391
  bindings
438
392
  };
439
393
  }
440
-
441
394
  case 'MatchOrPattern':
442
395
  {
443
396
  const {
@@ -449,25 +402,20 @@ function analyzePattern(pattern, key, seenBindingNames) {
449
402
  conditions,
450
403
  bindings
451
404
  } = analyzePattern(subpattern, key, seenBindingNames);
452
-
453
405
  if (bindings.length > 0) {
454
406
  throw (0, _createSyntaxError.createSyntaxError)(pattern, `Bindings in match 'or' patterns are not yet supported.`);
455
407
  }
456
-
457
408
  if (conditions.length === 0) {
458
409
  hasWildcard = true;
459
410
  }
460
-
461
411
  return conditions;
462
412
  });
463
-
464
413
  if (hasWildcard) {
465
414
  return {
466
415
  conditions: [],
467
416
  bindings: []
468
417
  };
469
418
  }
470
-
471
419
  return {
472
420
  conditions: [{
473
421
  type: 'or',
@@ -478,7 +426,6 @@ function analyzePattern(pattern, key, seenBindingNames) {
478
426
  }
479
427
  }
480
428
  }
481
-
482
429
  function expressionOfKey(root, key) {
483
430
  return key.reduce((acc, prop) => prop.type === 'Identifier' ? {
484
431
  type: 'MemberExpression',
@@ -496,7 +443,6 @@ function expressionOfKey(root, key) {
496
443
  ...(0, _Builders.etc)()
497
444
  }, (0, _astNodeMutationHelpers.deepCloneNode)(root));
498
445
  }
499
-
500
446
  function testsOfCondition(root, condition) {
501
447
  switch (condition.type) {
502
448
  case 'eq':
@@ -513,7 +459,6 @@ function testsOfCondition(root, condition) {
513
459
  ...(0, _Builders.etc)()
514
460
  }];
515
461
  }
516
-
517
462
  case 'is-nan':
518
463
  {
519
464
  const {
@@ -529,7 +474,6 @@ function testsOfCondition(root, condition) {
529
474
  };
530
475
  return [(0, _Builders.callExpression)(callee, [expressionOfKey(root, key)])];
531
476
  }
532
-
533
477
  case 'array':
534
478
  {
535
479
  const {
@@ -562,7 +506,6 @@ function testsOfCondition(root, condition) {
562
506
  };
563
507
  return [isArray, lengthCheck];
564
508
  }
565
-
566
509
  case 'object':
567
510
  {
568
511
  const {
@@ -579,7 +522,6 @@ function testsOfCondition(root, condition) {
579
522
  };
580
523
  return [(0, _Builders.disjunction)([(0, _Builders.conjunction)([typeofObject, notNull]), typeofFunction])];
581
524
  }
582
-
583
525
  case 'instanceof':
584
526
  {
585
527
  const {
@@ -594,7 +536,6 @@ function testsOfCondition(root, condition) {
594
536
  ...(0, _Builders.etc)()
595
537
  }];
596
538
  }
597
-
598
539
  case 'prop-exists':
599
540
  {
600
541
  const {
@@ -610,7 +551,6 @@ function testsOfCondition(root, condition) {
610
551
  };
611
552
  return [inObject];
612
553
  }
613
-
614
554
  case 'or':
615
555
  {
616
556
  const {
@@ -621,11 +561,9 @@ function testsOfCondition(root, condition) {
621
561
  }
622
562
  }
623
563
  }
624
-
625
564
  function testsOfConditions(root, conditions) {
626
565
  return conditions.flatMap(condition => testsOfCondition(root, condition));
627
566
  }
628
-
629
567
  function statementsOfBindings(root, bindings) {
630
568
  return bindings.map(binding => {
631
569
  switch (binding.type) {
@@ -638,7 +576,6 @@ function statementsOfBindings(root, bindings) {
638
576
  } = binding;
639
577
  return (0, _Builders.variableDeclaration)(kind, id, expressionOfKey(root, key));
640
578
  }
641
-
642
579
  case 'array-rest':
643
580
  {
644
581
  const {
@@ -657,7 +594,6 @@ function statementsOfBindings(root, bindings) {
657
594
  }, [(0, _Builders.numberLiteral)(exclude)]);
658
595
  return (0, _Builders.variableDeclaration)(kind, id, init);
659
596
  }
660
-
661
597
  case 'object-rest':
662
598
  {
663
599
  const {
@@ -701,9 +637,7 @@ function statementsOfBindings(root, bindings) {
701
637
  }
702
638
  });
703
639
  }
704
-
705
640
  const fallthroughErrorMsgText = `Match: No case succesfully matched. Make exhaustive or add a wildcard case using '_'.`;
706
-
707
641
  function fallthroughErrorMsg(value) {
708
642
  return {
709
643
  type: 'BinaryExpression',
@@ -713,17 +647,14 @@ function fallthroughErrorMsg(value) {
713
647
  ...(0, _Builders.etc)()
714
648
  };
715
649
  }
716
-
717
650
  function fallthroughError(value) {
718
651
  return (0, _Builders.throwStatement)(fallthroughErrorMsg(value));
719
652
  }
720
-
721
653
  function calculateSimpleArgument(node) {
722
654
  switch (node.type) {
723
655
  case 'Identifier':
724
656
  case 'Super':
725
657
  return true;
726
-
727
658
  case 'MemberExpression':
728
659
  {
729
660
  const {
@@ -731,24 +662,19 @@ function calculateSimpleArgument(node) {
731
662
  property,
732
663
  computed
733
664
  } = node;
734
-
735
665
  if (computed && property.type !== 'Literal') {
736
666
  return false;
737
667
  }
738
-
739
668
  return calculateSimpleArgument(object);
740
669
  }
741
-
742
670
  default:
743
671
  return false;
744
672
  }
745
673
  }
746
-
747
674
  function analyzeCases(cases) {
748
675
  let hasBindings = false;
749
676
  let hasWildcard = false;
750
677
  const analyses = [];
751
-
752
678
  for (let i = 0; i < cases.length; i++) {
753
679
  const {
754
680
  pattern,
@@ -766,20 +692,17 @@ function analyzeCases(cases) {
766
692
  guard,
767
693
  body
768
694
  });
769
-
770
695
  if (conditions.length === 0 && guard == null) {
771
696
  hasWildcard = true;
772
697
  break;
773
698
  }
774
699
  }
775
-
776
700
  return {
777
701
  hasBindings,
778
702
  hasWildcard,
779
703
  analyses
780
704
  };
781
705
  }
782
-
783
706
  function mapMatchExpression(node) {
784
707
  const {
785
708
  argument,
@@ -793,7 +716,6 @@ function mapMatchExpression(node) {
793
716
  const isSimpleArgument = !hasBindings && calculateSimpleArgument(argument);
794
717
  const genRoot = !isSimpleArgument ? genIdent() : null;
795
718
  const root = genRoot == null ? argument : genRoot;
796
-
797
719
  if (isSimpleArgument) {
798
720
  const wildcardAnalaysis = hasWildcard ? analyses.pop() : null;
799
721
  const lastBody = wildcardAnalaysis != null ? wildcardAnalaysis.body : (0, _Builders.iife)([fallthroughError((0, _astNodeMutationHelpers.shallowCloneNode)(root))]);
@@ -804,11 +726,9 @@ function mapMatchExpression(node) {
804
726
  body
805
727
  } = analysis;
806
728
  const tests = testsOfConditions(root, conditions);
807
-
808
729
  if (guard != null) {
809
730
  tests.push(guard);
810
731
  }
811
-
812
732
  return {
813
733
  type: 'ConditionalExpression',
814
734
  test: (0, _Builders.conjunction)(tests),
@@ -818,7 +738,6 @@ function mapMatchExpression(node) {
818
738
  };
819
739
  }, lastBody);
820
740
  }
821
-
822
741
  const statements = analyses.map(({
823
742
  conditions,
824
743
  bindings,
@@ -838,7 +757,6 @@ function mapMatchExpression(node) {
838
757
  };
839
758
  const bindingNodes = statementsOfBindings(root, bindings);
840
759
  const caseBody = bindingNodes.concat(bodyNode);
841
-
842
760
  if (conditions.length > 0) {
843
761
  const tests = testsOfConditions(root, conditions);
844
762
  return {
@@ -863,15 +781,12 @@ function mapMatchExpression(node) {
863
781
  }
864
782
  }
865
783
  });
866
-
867
784
  if (!hasWildcard) {
868
785
  statements.push(fallthroughError((0, _astNodeMutationHelpers.shallowCloneNode)(root)));
869
786
  }
870
-
871
787
  const [params, args] = genRoot == null ? [[], []] : [[genRoot], [argument]];
872
788
  return (0, _Builders.iife)(statements, params, args);
873
789
  }
874
-
875
790
  function mapMatchStatement(node) {
876
791
  const {
877
792
  argument,
@@ -887,11 +802,9 @@ function mapMatchStatement(node) {
887
802
  const genRoot = !isSimpleArgument ? genIdent() : null;
888
803
  const root = genRoot == null ? argument : genRoot;
889
804
  const statements = [];
890
-
891
805
  if (genRoot != null) {
892
806
  statements.push((0, _Builders.variableDeclaration)('const', genRoot, argument));
893
807
  }
894
-
895
808
  analyses.forEach(({
896
809
  conditions,
897
810
  bindings,
@@ -916,7 +829,6 @@ function mapMatchStatement(node) {
916
829
  }];
917
830
  const bindingNodes = statementsOfBindings(root, bindings);
918
831
  const caseBody = bindingNodes.concat(guardedBodyStatements);
919
-
920
832
  if (conditions.length > 0) {
921
833
  const tests = testsOfConditions(root, conditions);
922
834
  statements.push({
@@ -937,11 +849,9 @@ function mapMatchStatement(node) {
937
849
  });
938
850
  }
939
851
  });
940
-
941
852
  if (!hasWildcard) {
942
853
  statements.push(fallthroughError((0, _astNodeMutationHelpers.shallowCloneNode)(root)));
943
854
  }
944
-
945
855
  return {
946
856
  type: 'LabeledStatement',
947
857
  label: topLabel,
@@ -953,7 +863,6 @@ function mapMatchStatement(node) {
953
863
  ...(0, _Builders.etc)()
954
864
  };
955
865
  }
956
-
957
866
  function transformProgram(program, _options) {
958
867
  genID = new _GenID.default('m');
959
868
  return _SimpleTransform.SimpleTransform.transformProgram(program, {
@@ -963,28 +872,23 @@ function transformProgram(program, _options) {
963
872
  {
964
873
  return mapMatchExpression(node);
965
874
  }
966
-
967
875
  case 'MatchStatement':
968
876
  {
969
877
  return mapMatchStatement(node);
970
878
  }
971
-
972
879
  case 'Identifier':
973
880
  {
974
881
  if (genID == null) {
975
882
  throw Error('GenID must be initialized at the start of the transform.');
976
883
  }
977
-
978
884
  genID.addUsage(node.name);
979
885
  return node;
980
886
  }
981
-
982
887
  default:
983
888
  {
984
889
  return node;
985
890
  }
986
891
  }
987
892
  }
988
-
989
893
  });
990
894
  }