mambascript 0.5.4 → 2.0.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 (82) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/README.md +509 -267
  3. package/bin/mamba +1 -258
  4. package/decision.js +1 -246
  5. package/docs/coverage.md +70 -0
  6. package/docs/features.md +3348 -0
  7. package/docs/perf.md +94 -0
  8. package/docs/reference.md +1295 -0
  9. package/docs/vs-coffeescript.md +1593 -0
  10. package/docs/vs-iced-coffeescript.md +626 -0
  11. package/docs/vs-typescript.md +107 -0
  12. package/esm.js +8 -0
  13. package/jest.js +33 -0
  14. package/lib/black.js +17 -13
  15. package/lib/browser.js +2 -4
  16. package/lib/cli.js +207 -136
  17. package/lib/compiler.js +1162 -93
  18. package/lib/decision.js +10 -10
  19. package/lib/diagnostics.js +219 -0
  20. package/lib/esm-hooks.js +60 -0
  21. package/lib/fast-parser.js +3469 -0
  22. package/lib/functional-helpers.js +26 -9
  23. package/lib/helpers.js +67 -50
  24. package/lib/js-nodes.js +151 -12
  25. package/lib/lexer.js +1499 -0
  26. package/lib/light-module.js +200 -63
  27. package/lib/mamba.js +372 -0
  28. package/lib/module.js +23 -172
  29. package/lib/nodes.js +84 -21
  30. package/lib/optimiser.js +29 -9
  31. package/lib/optparse.js +32 -15
  32. package/lib/parser.js +9433 -4840
  33. package/lib/preprocessor.js +3 -5
  34. package/lib/register.js +49 -56
  35. package/lib/repl.js +28 -9
  36. package/lib/reporter.js +106 -69
  37. package/lib/run.js +3 -5
  38. package/lib/string-scanner.js +94 -0
  39. package/lib/syntax-tables.js +480 -0
  40. package/lib/type-checker.js +258 -44
  41. package/lib/type-helpers.js +28 -10
  42. package/lib/type-resolver.js +256 -34
  43. package/lib/type-scope.js +10 -6
  44. package/lib/type-walker.js +664 -85
  45. package/lib/types.js +17 -7
  46. package/lib/underscore.js +170 -76
  47. package/lib/unicode-classes.js +122 -0
  48. package/mambaview.js +1 -0
  49. package/package.json +49 -46
  50. package/stdlib.js +1 -0
  51. package/vendor/README.md +40 -0
  52. package/vendor/escodegen/LICENSE.BSD +19 -0
  53. package/vendor/escodegen/escodegen.js +2289 -0
  54. package/vendor/estraverse/LICENSE.BSD +19 -0
  55. package/vendor/estraverse/estraverse.js +706 -0
  56. package/vendor/mambacodegen/LICENSE +24 -0
  57. package/vendor/mambacodegen/lib/mscodegen.js +620 -0
  58. package/vendor/patches/escodegen.diff +130 -0
  59. package/vendor/patches/estraverse.diff +51 -0
  60. package/vendor/patches/pegjs.diff +70 -0
  61. package/vendor/patches/source-map.diff +160 -0
  62. package/vendor/source-map/LICENSE +28 -0
  63. package/vendor/source-map/lib/source-map/array-set.js +92 -0
  64. package/vendor/source-map/lib/source-map/base64-vlq.js +140 -0
  65. package/vendor/source-map/lib/source-map/base64.js +38 -0
  66. package/vendor/source-map/lib/source-map/binary-search.js +77 -0
  67. package/vendor/source-map/lib/source-map/source-map-consumer.js +404 -0
  68. package/vendor/source-map/lib/source-map/source-map-generator.js +229 -0
  69. package/vendor/source-map/lib/source-map/source-node.js +201 -0
  70. package/vendor/source-map/lib/source-map/util.js +57 -0
  71. package/vendor/source-map/lib/source-map.js +8 -0
  72. package/bin/fix +0 -17
  73. package/bin/updateImports +0 -46
  74. package/build.js +0 -25
  75. package/lib/module-esm.js +0 -901
  76. package/lib/pegjs-kofu-plugin.js +0 -35
  77. package/lib/pegjs-mamba-plugin.js +0 -35
  78. package/lib/processor-esm.js +0 -507
  79. package/mamba +0 -259
  80. package/msast.js +0 -1
  81. package/utils/gulp-mamba.js +0 -29
  82. /package/{lib/esm.js → vendor/patches/mambacodegen.diff} +0 -0
package/lib/module-esm.js DELETED
@@ -1,901 +0,0 @@
1
- // Generated by KofuScript 0.0.3-alpha.2
2
- var present = console.log;
3
- // Generated by KofuScript 0.0.3-alpha.2
4
- var ArrayInitialiser, Block, Bool, Class, CoffeeScript, Compiler, CompoundAssignOp, concat, Conditional, createNodes, cscodegen, escodegen, escodegenFormat, ext, foldl, formatParserError, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, NegatedConditional, NewCoffeScript, NewOp, Nodes, Nodes, NodeTypeObj, nub, ObjectInitialiser, Optimiser, Parser, pkg, Preprocessor, Primitives, Range, RegExp, RegExps, reporter, Slice, span, StaticMemberAccessOps, Super, Switch, SwitchCase, TypeError, TypeWalker, While;
5
- formatParserError = function (input, e) {
6
- var found, message, realColumn, unicode;
7
- realColumn = cleanMarkers(('' + input.split('\n')[e.line - 1] + '\n').slice(0, e.column)).length;
8
- if (!(null != e.found))
9
- return 'Syntax error on line ' + e.line + ', column ' + realColumn + ': unexpected end of input';
10
- found = JSON.stringify(humanReadable(e.found));
11
- found = found.replace(/^"|"$/g, '').replace(/'/g, "\\'").replace(/\\"/g, '"');
12
- unicode = e.found.charCodeAt(0).toString(16).toUpperCase();
13
- unicode = '\\u' + '0000'.slice(unicode.length) + unicode;
14
- message = 'Syntax error on line ' + e.line + ', column ' + realColumn + ": unexpected '" + found + "' (" + unicode + ')';
15
- return '' + message + '\n' + pointToErrorLocation(input, e.line, realColumn);
16
- };
17
- this.any = function (list, fn) {
18
- var e;
19
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
20
- e = list[i$];
21
- if (fn(e))
22
- return true;
23
- }
24
- return false;
25
- };
26
- this.all = function (list, fn) {
27
- var e;
28
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
29
- e = list[i$];
30
- if (!fn(e))
31
- return false;
32
- }
33
- return true;
34
- };
35
- this.find = function (list, fn) {
36
- var e;
37
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
38
- e = list[i$];
39
- if (fn(e))
40
- return e;
41
- }
42
- return null;
43
- };
44
- this.foldl = foldl = function (memo, list, fn) {
45
- var i;
46
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
47
- i = list[i$];
48
- memo = fn(memo, i);
49
- }
50
- return memo;
51
- };
52
- this.foldl1 = function (list, fn) {
53
- return foldl(list[0], list.slice(1), fn);
54
- };
55
- this.map = map = function (list, fn) {
56
- var e;
57
- return function (accum$) {
58
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
59
- e = list[i$];
60
- accum$.push(fn(e));
61
- }
62
- return accum$;
63
- }.call(this, []);
64
- };
65
- this.concat = concat = function (list) {
66
- var cache$;
67
- return (cache$ = []).concat.apply(cache$, [].slice.call(list));
68
- };
69
- this.concatMap = function (list, fn) {
70
- return concat(map(list, fn));
71
- };
72
- this.intersect = function (listA, listB) {
73
- var a;
74
- return function (accum$) {
75
- for (var i$ = 0, length$ = listA.length; i$ < length$; ++i$) {
76
- a = listA[i$];
77
- if (!in$(a, listB))
78
- continue;
79
- accum$.push(a);
80
- }
81
- return accum$;
82
- }.call(this, []);
83
- };
84
- this.difference = function (listA, listB) {
85
- var a;
86
- return function (accum$) {
87
- for (var i$ = 0, length$ = listA.length; i$ < length$; ++i$) {
88
- a = listA[i$];
89
- if (!!in$(a, listB))
90
- continue;
91
- accum$.push(a);
92
- }
93
- return accum$;
94
- }.call(this, []);
95
- };
96
- this.nub = nub = function (list) {
97
- var i, result;
98
- result = [];
99
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
100
- i = list[i$];
101
- if (!!in$(i, result))
102
- continue;
103
- result.push(i);
104
- }
105
- return result;
106
- };
107
- this.union = function (listA, listB) {
108
- var b;
109
- return listA.concat(function (accum$) {
110
- for (var cache$ = nub(listB), i$ = 0, length$ = cache$.length; i$ < length$; ++i$) {
111
- b = cache$[i$];
112
- if (!!in$(b, listA))
113
- continue;
114
- accum$.push(b);
115
- }
116
- return accum$;
117
- }.call(this, []));
118
- };
119
- this.flip = function (fn) {
120
- return function (b, a) {
121
- return fn.call(this, a, b);
122
- };
123
- };
124
- this.owns = function (hop) {
125
- return function (a, b) {
126
- return hop.call(a, b);
127
- };
128
- }({}.hasOwnProperty);
129
- this.span = span = function (list, f) {
130
- var cache$, ys, zs;
131
- if (list.length === 0) {
132
- return [
133
- [],
134
- []
135
- ];
136
- } else if (f(list[0])) {
137
- cache$ = span(list.slice(1), f);
138
- ys = cache$[0];
139
- zs = cache$[1];
140
- return [
141
- [list[0]].concat([].slice.call(ys)),
142
- zs
143
- ];
144
- } else {
145
- return [
146
- [],
147
- list
148
- ];
149
- }
150
- };
151
- this.divMod = function (a, b) {
152
- var c, div, mod;
153
- c = a % b;
154
- mod = c < 0 ? c + b : c;
155
- div = Math.floor(a / b);
156
- return [
157
- div,
158
- mod
159
- ];
160
- };
161
- this.partition = function (list, fn) {
162
- var item, result;
163
- result = [
164
- [],
165
- []
166
- ];
167
- for (var i$ = 0, length$ = list.length; i$ < length$; ++i$) {
168
- item = list[i$];
169
- result[+!fn(item)].push(item);
170
- }
171
- return result;
172
- };
173
- this.first = function (list) {
174
- return list[0];
175
- };
176
- this.last = function (list) {
177
- return list[list.length - 1];
178
- };
179
- NodeTypeObj = {};
180
- createNodes = function (subclasses, superclasses) {
181
- var className, specs;
182
- if (null == superclasses)
183
- superclasses = [];
184
- for (className in subclasses) {
185
- if (!isOwn$(subclasses, className))
186
- continue;
187
- specs = subclasses[className];
188
- (function (className) {
189
- var externalCtor$, isCategory, klass, params, superclass;
190
- superclass = null != superclasses[0] ? superclasses[0] : function () {
191
- };
192
- isCategory = 'undefined' !== typeof specs && null != specs && specs.length === 2;
193
- params = 'undefined' !== typeof specs && null != specs ? function () {
194
- switch (specs.length) {
195
- case 0:
196
- return [];
197
- case 1:
198
- case 2:
199
- return specs[0];
200
- }
201
- }.call(this) : null;
202
- if (null != params)
203
- params;
204
- else
205
- params = null != superclass.prototype.childNodes ? superclass.prototype.childNodes : [];
206
- klass = function (super$) {
207
- extends$(class$, super$);
208
- externalCtor$ = isCategory ? function () {
209
- } : function () {
210
- var i, param;
211
- for (var i$ = 0, length$ = params.length; i$ < length$; ++i$) {
212
- param = params[i$];
213
- i = i$;
214
- this[param] = arguments[i];
215
- }
216
- if (null != this.initialise)
217
- this.initialise.apply(this, arguments);
218
- return this;
219
- };
220
- function class$() {
221
- return externalCtor$.apply(this, arguments);
222
- }
223
- class$.prototype.className = className;
224
- class$.superclasses = superclasses;
225
- return class$;
226
- }(superclass);
227
- if (null != ('undefined' !== typeof specs && null != specs ? specs[0] : void 0))
228
- klass.prototype.childNodes = specs[0];
229
- if (isCategory)
230
- createNodes(specs[1], [klass].concat([].slice.call(superclasses)));
231
- return NodeTypeObj[className] = klass;
232
- }(className));
233
- }
234
- };
235
- createNodes({
236
- Nodes: [
237
- [],
238
- {
239
- BinOps: [
240
- [
241
- 'left',
242
- 'right'
243
- ],
244
- {
245
- AssignOps: [
246
- [
247
- 'assignee',
248
- 'expression'
249
- ],
250
- {
251
- AssignOp: null,
252
- ClassProtoAssignOp: null,
253
- CompoundAssignOp: [[
254
- 'op',
255
- 'assignee',
256
- 'expression'
257
- ]]
258
- }
259
- ],
260
- BitOps: [
261
- null,
262
- {
263
- BitAndOp: null,
264
- BitOrOp: null,
265
- BitXorOp: null,
266
- LeftShiftOp: null,
267
- SignedRightShiftOp: null,
268
- UnsignedRightShiftOp: null
269
- }
270
- ],
271
- ComparisonOps: [
272
- null,
273
- {
274
- EQOp: null,
275
- GTEOp: null,
276
- GTOp: null,
277
- LTEOp: null,
278
- LTOp: null,
279
- NEQOp: null
280
- }
281
- ],
282
- ConcatOp: null,
283
- ExistsOp: null,
284
- ExtendsOp: null,
285
- InOp: null,
286
- InstanceofOp: null,
287
- LogicalOps: [
288
- null,
289
- {
290
- LogicalAndOp: null,
291
- LogicalOrOp: null
292
- }
293
- ],
294
- MathsOps: [
295
- null,
296
- {
297
- ExpOp: null,
298
- DivideOp: null,
299
- MultiplyOp: null,
300
- RemOp: null,
301
- SubtractOp: null
302
- }
303
- ],
304
- OfOp: null,
305
- PlusOp: null,
306
- Range: [[
307
- 'isInclusive',
308
- 'left',
309
- 'right'
310
- ]],
311
- SeqOp: null
312
- }
313
- ],
314
- Statements: [
315
- [],
316
- {
317
- Break: null,
318
- Continue: null,
319
- Debugger: null,
320
- Return: [['expression']],
321
- Throw: [['expression']]
322
- }
323
- ],
324
- UnaryOps: [
325
- ['expression'],
326
- {
327
- BitNotOp: null,
328
- DeleteOp: null,
329
- DoOp: null,
330
- LogicalNotOp: null,
331
- NewOp: [[
332
- 'ctor',
333
- 'arguments'
334
- ]],
335
- PreDecrementOp: null,
336
- PreIncrementOp: null,
337
- PostDecrementOp: null,
338
- PostIncrementOp: null,
339
- TypeofOp: null,
340
- UnaryExistsOp: null,
341
- UnaryNegateOp: null,
342
- UnaryPlusOp: null
343
- }
344
- ],
345
- MemberAccessOps: [
346
- null,
347
- {
348
- StaticMemberAccessOps: [
349
- [
350
- 'expression',
351
- 'memberName'
352
- ],
353
- {
354
- MemberAccessOp: null,
355
- ProtoMemberAccessOp: null,
356
- SoakedMemberAccessOp: null,
357
- SoakedProtoMemberAccessOp: null
358
- }
359
- ],
360
- DynamicMemberAccessOps: [
361
- [
362
- 'expression',
363
- 'indexingExpr'
364
- ],
365
- {
366
- DynamicMemberAccessOp: null,
367
- DynamicProtoMemberAccessOp: null,
368
- SoakedDynamicMemberAccessOp: null,
369
- SoakedDynamicProtoMemberAccessOp: null
370
- }
371
- ]
372
- }
373
- ],
374
- ChainedComparisonOp: [['expression']],
375
- FunctionApplications: [
376
- [
377
- 'function',
378
- 'arguments'
379
- ],
380
- {
381
- FunctionApplication: null,
382
- SoakedFunctionApplication: null
383
- }
384
- ],
385
- Super: [['arguments']],
386
- Program: [['body']],
387
- Block: [['statements']],
388
- Conditional: [[
389
- 'condition',
390
- 'consequent',
391
- 'alternate'
392
- ]],
393
- ForIn: [[
394
- 'valAssignee',
395
- 'keyAssignee',
396
- 'target',
397
- 'step',
398
- 'filter',
399
- 'body'
400
- ]],
401
- ForOf: [[
402
- 'isOwn',
403
- 'keyAssignee',
404
- 'valAssignee',
405
- 'target',
406
- 'filter',
407
- 'body'
408
- ]],
409
- Switch: [[
410
- 'expression',
411
- 'cases',
412
- 'alternate'
413
- ]],
414
- SwitchCase: [[
415
- 'conditions',
416
- 'consequent'
417
- ]],
418
- Try: [[
419
- 'body',
420
- 'catchAssignee',
421
- 'catchBody',
422
- 'finallyBody'
423
- ]],
424
- While: [[
425
- 'condition',
426
- 'body'
427
- ]],
428
- ArrayInitialiser: [['members']],
429
- ObjectInitialiser: [['members']],
430
- ObjectInitialiserMember: [[
431
- 'key',
432
- 'expression'
433
- ]],
434
- Class: [[
435
- 'nameAssignee',
436
- 'parent',
437
- 'ctor',
438
- 'body',
439
- 'boundMembers'
440
- ]],
441
- Constructor: [['expression']],
442
- Functions: [
443
- [
444
- 'parameters',
445
- 'body'
446
- ],
447
- {
448
- Function: null,
449
- BoundFunction: null
450
- }
451
- ],
452
- DefaultParam: [[
453
- 'param',
454
- 'default'
455
- ]],
456
- Identifiers: [
457
- ['data'],
458
- {
459
- Identifier: null,
460
- GenSym: null
461
- }
462
- ],
463
- Null: null,
464
- Primitives: [
465
- ['data'],
466
- {
467
- Bool: null,
468
- JavaScript: null,
469
- Numbers: [
470
- null,
471
- {
472
- Int: null,
473
- Float: null
474
- }
475
- ],
476
- String: null
477
- }
478
- ],
479
- RegExps: [
480
- null,
481
- {
482
- RegExp: [[
483
- 'data',
484
- 'flags'
485
- ]],
486
- HeregExp: [[
487
- 'expression',
488
- 'flags'
489
- ]]
490
- }
491
- ],
492
- This: null,
493
- Undefined: null,
494
- Slice: [[
495
- 'expression',
496
- 'isInclusive',
497
- 'left',
498
- 'right'
499
- ]],
500
- Rest: [['expression']],
501
- Spread: [['expression']],
502
- Module: [[
503
- 'ident',
504
- 'body'
505
- ]],
506
- Annotation: [['data']]
507
- }
508
- ]
509
- });
510
- cache$ = NodeTypeObj;
511
- Nodes = cache$.Nodes;
512
- Primitives = cache$.Primitives;
513
- CompoundAssignOp = cache$.CompoundAssignOp;
514
- StaticMemberAccessOps = cache$.StaticMemberAccessOps;
515
- Range = cache$.Range;
516
- ArrayInitialiser = cache$.ArrayInitialiser;
517
- ObjectInitialiser = cache$.ObjectInitialiser;
518
- NegatedConditional = cache$.NegatedConditional;
519
- Conditional = cache$.Conditional;
520
- Identifier = cache$.Identifier;
521
- ForOf = cache$.ForOf;
522
- Functions = cache$.Functions;
523
- While = cache$.While;
524
- Class = cache$.Class;
525
- Block = cache$.Block;
526
- NewOp = cache$.NewOp;
527
- Bool = cache$.Bool;
528
- FunctionApplications = cache$.FunctionApplications;
529
- RegExps = cache$.RegExps;
530
- RegExp = cache$.RegExp;
531
- HeregExp = cache$.HeregExp;
532
- Super = cache$.Super;
533
- Slice = cache$.Slice;
534
- Switch = cache$.Switch;
535
- Identifiers = cache$.Identifiers;
536
- SwitchCase = cache$.SwitchCase;
537
- GenSym = cache$.GenSym;
538
- Nodes.fromBasicObject = function (obj) {
539
- return NodeTypeObj[obj.type].fromBasicObject(obj);
540
- };
541
- Nodes.prototype.listMembers = [];
542
- Nodes.prototype.toBasicObject = function () {
543
- var child, obj, p;
544
- obj = { type: this.className };
545
- if (null != this.line)
546
- obj.line = this.line;
547
- if (null != this.column)
548
- obj.column = this.column;
549
- if (null != this.raw) {
550
- obj.raw = this.raw;
551
- if (null != this.offset)
552
- obj.range = [
553
- this.offset,
554
- this.offset + this.raw.length
555
- ];
556
- }
557
- for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
558
- child = this.childNodes[i$];
559
- if (in$(child, this.listMembers)) {
560
- obj[child] = function (accum$) {
561
- for (var i$1 = 0, length$1 = this[child].length; i$1 < length$1; ++i$1) {
562
- p = this[child][i$1];
563
- accum$.push(p.toBasicObject());
564
- }
565
- return accum$;
566
- }.call(this, []);
567
- } else {
568
- obj[child] = null != this[child] ? this[child].toBasicObject() : void 0;
569
- }
570
- }
571
- return obj;
572
- };
573
- Nodes.prototype.fold = function (memo, fn) {
574
- var child, p;
575
- for (var i$ = 0, length$ = this.childNodes.length; i$ < length$; ++i$) {
576
- child = this.childNodes[i$];
577
- if (in$(child, this.listMembers)) {
578
- memo = function (accum$) {
579
- for (var i$1 = 0, length$1 = this[child].length; i$1 < length$1; ++i$1) {
580
- p = this[child][i$1];
581
- accum$.push(p.fold(memo, fn));
582
- }
583
- return accum$;
584
- }.call(this, []);
585
- } else {
586
- memo = this[child].fold(memo, fn);
587
- }
588
- }
589
- return fn(memo, this);
590
- };
591
- Nodes.prototype.clone = function () {
592
- var ctor, k, n, v;
593
- ctor = function () {
594
- };
595
- ctor.prototype = this.constructor.prototype;
596
- n = new ctor;
597
- for (k in this) {
598
- if (!isOwn$(this, k))
599
- continue;
600
- v = this[k];
601
- n[k] = v;
602
- }
603
- return n;
604
- };
605
- Nodes.prototype['instanceof'] = function () {
606
- var ctor, ctors, superclasses;
607
- ctors = arguments.length > 0 ? [].slice.call(arguments, 0) : [];
608
- superclasses = map(this.constructor.superclasses, function (c) {
609
- return c.prototype.className;
610
- });
611
- for (var i$ = 0, length$ = ctors.length; i$ < length$; ++i$) {
612
- ctor = ctors[i$];
613
- if (!in$(ctor.prototype.className, [this.className].concat([].slice.call(superclasses))))
614
- continue;
615
- return true;
616
- }
617
- return false;
618
- };
619
- Nodes.prototype.r = function (param$) {
620
- this.raw = param$;
621
- return this;
622
- };
623
- Nodes.prototype.p = function (param$, param$1, param$2) {
624
- this.line = param$;
625
- this.column = param$1;
626
- this.offset = param$2;
627
- return this;
628
- };
629
- Nodes.prototype.generated = false;
630
- Nodes.prototype.g = function () {
631
- this.generated = true;
632
- return this;
633
- };
634
- handlePrimitives = function (ctor) {
635
- var primitives;
636
- primitives = arguments.length > 1 ? [].slice.call(arguments, 1) : [];
637
- ctor.prototype.childNodes = difference(ctor.prototype.childNodes, primitives);
638
- return ctor.prototype.toBasicObject = function () {
639
- var obj, primitive;
640
- obj = Nodes.prototype.toBasicObject.call(this);
641
- for (var i$ = 0, length$ = primitives.length; i$ < length$; ++i$) {
642
- primitive = primitives[i$];
643
- obj[primitive] = this[primitive];
644
- }
645
- return obj;
646
- };
647
- };
648
- handlePrimitives(Class, 'boundMembers');
649
- handlePrimitives(CompoundAssignOp, 'op');
650
- handlePrimitives(ForOf, 'isOwn');
651
- handlePrimitives(HeregExp, 'flags');
652
- handlePrimitives(Identifiers, 'data');
653
- handlePrimitives(Primitives, 'data');
654
- handlePrimitives(Range, 'isInclusive');
655
- handlePrimitives(RegExp, 'data', 'flags');
656
- handlePrimitives(Slice, 'isInclusive');
657
- handlePrimitives(StaticMemberAccessOps, 'memberName');
658
- handleLists = function (ctor) {
659
- var listProps;
660
- listProps = arguments.length > 1 ? [].slice.call(arguments, 1) : [];
661
- return ctor.prototype.listMembers = listProps;
662
- };
663
- handleLists(ArrayInitialiser, 'members');
664
- handleLists(Block, 'statements');
665
- handleLists(Functions, 'parameters');
666
- handleLists(FunctionApplications, 'arguments');
667
- handleLists(NewOp, 'arguments');
668
- handleLists(ObjectInitialiser, 'members');
669
- handleLists(Super, 'arguments');
670
- handleLists(Switch, 'cases');
671
- handleLists(SwitchCase, 'conditions');
672
- Block.wrap = function (s) {
673
- return new Block(null != s ? [s] : []).r(s.raw).p(s.line, s.column);
674
- };
675
- Class.prototype.initialise = function () {
676
- if (null != this.boundMembers)
677
- this.boundMembers;
678
- else
679
- this.boundMembers = [];
680
- this.name = new GenSym('class');
681
- if (null != this.nameAssignee)
682
- return this.name = function () {
683
- switch (false) {
684
- case !this.nameAssignee['instanceof'](Identifier):
685
- return new Identifier(this.nameAssignee.data);
686
- case !this.nameAssignee['instanceof'](StaticMemberAccessOps):
687
- return new Identifier(this.nameAssignee.memberName);
688
- default:
689
- return this.name;
690
- }
691
- }.call(this);
692
- };
693
- Class.prototype.childNodes.push('name');
694
- ObjectInitialiser.prototype.keys = function () {
695
- return map(this.members, function (m) {
696
- return m.key;
697
- });
698
- };
699
- ObjectInitialiser.prototype.vals = function () {
700
- return map(this.members, function (m) {
701
- return m.expression;
702
- });
703
- };
704
- RegExps.prototype.initialise = function (_, flags) {
705
- var flag;
706
- this.flags = {};
707
- for (var cache$1 = [
708
- 'g',
709
- 'i',
710
- 'm',
711
- 'y'
712
- ], i$ = 0, length$ = cache$1.length; i$ < length$; ++i$) {
713
- flag = cache$1[i$];
714
- this.flags[flag] = in$(flag, flags);
715
- }
716
- };
717
- NodeTypeObj.NegatedConditional = function (super$) {
718
- extends$(NegatedConditional, super$);
719
- function NegatedConditional() {
720
- Conditional.apply(this, arguments);
721
- }
722
- return NegatedConditional;
723
- }(Conditional);
724
- NodeTypeObj.NegatedWhile = function (super$1) {
725
- extends$(NegatedWhile, super$1);
726
- function NegatedWhile() {
727
- While.apply(this, arguments);
728
- }
729
- return NegatedWhile;
730
- }(While);
731
- NodeTypeObj.Loop = function (super$2) {
732
- extends$(Loop, super$2);
733
- function Loop(body) {
734
- While.call(this, new Bool(true).g(), body);
735
- }
736
- return Loop;
737
- }(While);
738
- Nodes = NodeTypeObj;
739
- Preprocessor = require('./preprocessor').Preprocessor;
740
- Parser = require('./parser');
741
- TypeWalker = require('./type-walker');
742
- Optimiser = require('./optimiser').Optimiser;
743
- Compiler = require('./compiler').Compiler;
744
- reporter = require('./reporter');
745
- TypeError = require('./type-helpers').TypeError;
746
- cscodegen = function () {
747
- try {
748
- return require('cscodegen');
749
- } catch (e$) {
750
- return;
751
- }
752
- }.call(this);
753
- escodegen = function () {
754
- try {
755
- return require('escodegen');
756
- } catch (e$1) {
757
- return;
758
- }
759
- }.call(this);
760
- NewCoffeScript = require('coffeescript');
761
- pkg = require('./../package.json');
762
- escodegenFormat = {
763
- indent: {
764
- style: ' ',
765
- base: 0
766
- },
767
- renumber: true,
768
- hexadecimal: true,
769
- quotes: 'auto',
770
- parentheses: false
771
- };
772
- CoffeeScript = {
773
- CoffeeScript: CoffeeScript,
774
- Compiler: Compiler,
775
- Optimiser: Optimiser,
776
- Parser: Parser,
777
- Preprocessor: Preprocessor,
778
- Nodes: Nodes,
779
- NewCoffeScript: NewCoffeScript,
780
- VERSION: pkg.version,
781
- parse: function (coffee, options) {
782
- var e, parsed, preprocessed;
783
- if (null == options)
784
- options = {};
785
- try {
786
- preprocessed = Preprocessor.process(coffee, { literate: options.literate });
787
- parsed = Parser.parse(preprocessed, {
788
- raw: options.raw,
789
- inputSource: options.inputSource
790
- });
791
- TypeWalker.checkNodes(parsed);
792
- if (reporter.has_errors())
793
- throw new TypeError(reporter.report());
794
- return options.optimise ? Optimiser.optimise(parsed) : parsed;
795
- } catch (e$2) {
796
- e = e$2;
797
- if (e instanceof TypeError)
798
- throw e.message;
799
- if (!(e instanceof Parser.SyntaxError))
800
- throw e;
801
- throw new Error(formatParserError(preprocessed, e));
802
- }
803
- },
804
- compile: function (csAst, options) {
805
- return Compiler.compile(csAst, options).toBasicObject();
806
- },
807
- compileTypedToCS: function (csAst, options) {
808
- return cscodegen(csAst);
809
- },
810
- cs: function (csAst, options) {
811
- },
812
- jsWithSourceMap: function (jsAst, name, options) {
813
- var targetName;
814
- if (null == name)
815
- name = 'unknown';
816
- if (null == options)
817
- options = {};
818
- if (!(null != escodegen))
819
- throw new Error('escodegen not found: run `npm install escodegen`');
820
- if (!{}.hasOwnProperty.call(jsAst, 'type'))
821
- jsAst = jsAst.toBasicObject();
822
- targetName = options.sourceMapFile || options.sourceMap && options.output.match(/^.*[\\\/]([^\\\/]+)$/)[1];
823
- return escodegen.generate(jsAst, {
824
- comment: !options.compact,
825
- sourceMapWithCode: true,
826
- sourceMap: name,
827
- file: targetName || 'unknown',
828
- format: options.compact ? escodegen.FORMAT_MINIFY : null != options.format ? options.format : escodegenFormat
829
- });
830
- },
831
- js: function (jsAst, options) {
832
- return this.jsWithSourceMap(jsAst, null, options).code;
833
- },
834
- sourceMap: function (jsAst, name, options) {
835
- return this.jsWithSourceMap(jsAst, name, options).map;
836
- },
837
- cs2js: function (input, options) {
838
- var csAST, jsAST;
839
- if (null == options)
840
- options = {};
841
- if (null != options.optimise)
842
- options.optimise;
843
- else
844
- options.optimise = true;
845
- csAST = CoffeeScript.parse(input, options);
846
- jsAST = CoffeeScript.compile(csAST, { bare: options.bare });
847
- return CoffeeScript.js(jsAST, { compact: options.compact || options.minify });
848
- },
849
- svelteCompile: function (input) {
850
- var options;
851
- options = {
852
- optimize: true,
853
- bare: true,
854
- header: true,
855
- compact: true
856
- };
857
- return this.cs2js(input, options);
858
- }
859
- };
860
- module.exports = CoffeeScript;
861
- if (null != (null != require.extensions ? require.extensions['.node'] : void 0)) {
862
- CoffeeScript.register = function () {
863
- return require('./register');
864
- };
865
- for (var cache$1 = [
866
- '.coffee',
867
- '.litcoffee',
868
- '.tcoffee',
869
- '.typed.coffee',
870
- '.kofu'
871
- ], i$ = 0, length$ = cache$1.length; i$ < length$; ++i$) {
872
- ext = cache$1[i$];
873
- if (null != require.extensions[ext])
874
- require.extensions[ext];
875
- else
876
- require.extensions[ext] = function () {
877
- throw new Error('Use CoffeeScript.register() or require the coffee-script-redux/register module to require ' + ext + ' files.');
878
- };
879
- }
880
- }
881
- function in$(member, list) {
882
- for (var i = 0, length = list.length; i < length; ++i)
883
- if (i in list && list[i] === member)
884
- return true;
885
- return false;
886
- }
887
- function isOwn$(o, p) {
888
- return {}.hasOwnProperty.call(o, p);
889
- }
890
- function extends$(child, parent) {
891
- for (var key in parent)
892
- if (isOwn$(parent, key))
893
- child[key] = parent[key];
894
- function ctor() {
895
- this.constructor = child;
896
- }
897
- ctor.prototype = parent.prototype;
898
- child.prototype = new ctor;
899
- child.__super__ = parent.prototype;
900
- return child;
901
- }