mambascript 0.5.5 → 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.
- package/CHANGELOG.md +326 -0
- package/README.md +509 -267
- package/bin/mamba +1 -258
- package/decision.js +1 -246
- package/docs/coverage.md +70 -0
- package/docs/features.md +3348 -0
- package/docs/perf.md +94 -0
- package/docs/reference.md +1295 -0
- package/docs/vs-coffeescript.md +1593 -0
- package/docs/vs-iced-coffeescript.md +626 -0
- package/docs/vs-typescript.md +107 -0
- package/esm.js +8 -0
- package/jest.js +33 -0
- package/lib/black.js +17 -13
- package/lib/browser.js +2 -4
- package/lib/cli.js +207 -136
- package/lib/compiler.js +1162 -93
- package/lib/decision.js +10 -10
- package/lib/diagnostics.js +219 -0
- package/lib/esm-hooks.js +60 -0
- package/lib/fast-parser.js +3469 -0
- package/lib/functional-helpers.js +26 -9
- package/lib/helpers.js +67 -50
- package/lib/js-nodes.js +151 -12
- package/lib/lexer.js +1499 -0
- package/lib/light-module.js +200 -63
- package/lib/mamba.js +372 -0
- package/lib/module.js +23 -172
- package/lib/nodes.js +84 -21
- package/lib/optimiser.js +29 -9
- package/lib/optparse.js +32 -15
- package/lib/parser.js +9433 -4840
- package/lib/preprocessor.js +3 -5
- package/lib/register.js +49 -56
- package/lib/repl.js +28 -9
- package/lib/reporter.js +106 -69
- package/lib/run.js +3 -5
- package/lib/string-scanner.js +94 -0
- package/lib/syntax-tables.js +480 -0
- package/lib/type-checker.js +258 -44
- package/lib/type-helpers.js +28 -10
- package/lib/type-resolver.js +256 -34
- package/lib/type-scope.js +10 -6
- package/lib/type-walker.js +664 -85
- package/lib/types.js +17 -7
- package/lib/underscore.js +170 -76
- package/lib/unicode-classes.js +122 -0
- package/mambaview.js +1 -0
- package/package.json +49 -46
- package/stdlib.js +1 -0
- package/vendor/README.md +40 -0
- package/vendor/escodegen/LICENSE.BSD +19 -0
- package/vendor/escodegen/escodegen.js +2289 -0
- package/vendor/estraverse/LICENSE.BSD +19 -0
- package/vendor/estraverse/estraverse.js +706 -0
- package/vendor/mambacodegen/LICENSE +24 -0
- package/vendor/mambacodegen/lib/mscodegen.js +620 -0
- package/vendor/patches/escodegen.diff +130 -0
- package/vendor/patches/estraverse.diff +51 -0
- package/vendor/patches/pegjs.diff +70 -0
- package/vendor/patches/source-map.diff +160 -0
- package/vendor/source-map/LICENSE +28 -0
- package/vendor/source-map/lib/source-map/array-set.js +92 -0
- package/vendor/source-map/lib/source-map/base64-vlq.js +140 -0
- package/vendor/source-map/lib/source-map/base64.js +38 -0
- package/vendor/source-map/lib/source-map/binary-search.js +77 -0
- package/vendor/source-map/lib/source-map/source-map-consumer.js +404 -0
- package/vendor/source-map/lib/source-map/source-map-generator.js +229 -0
- package/vendor/source-map/lib/source-map/source-node.js +201 -0
- package/vendor/source-map/lib/source-map/util.js +57 -0
- package/vendor/source-map/lib/source-map.js +8 -0
- package/bin/fix +0 -17
- package/bin/updateImports +0 -46
- package/build.js +0 -25
- package/lib/module-esm.js +0 -901
- package/lib/pegjs-kofu-plugin.js +0 -35
- package/lib/pegjs-mamba-plugin.js +0 -35
- package/lib/processor-esm.js +0 -507
- package/mamba +0 -259
- package/msast.js +0 -1
- package/utils/gulp-mamba.js +0 -29
- /package/{lib/esm.js → vendor/patches/mambacodegen.diff} +0 -0
package/lib/module.js
CHANGED
|
@@ -1,176 +1,27 @@
|
|
|
1
|
-
// Generated by MambaScript 0.
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var Compiler, Decision, escodegen, escodegenFormat, ESMRewriter, ext, formatParserError, MambaScript, MambaView, mscodegen, NewCoffeScript, Nodes, Optimiser, Parser, pkg, Preprocessor, reporter, TypeError, TypeWalker;
|
|
5
|
-
formatParserError = require('./helpers').formatParserError;
|
|
6
|
-
Nodes = require('./nodes');
|
|
7
|
-
Preprocessor = require('./preprocessor').Preprocessor;
|
|
8
|
-
Parser = require('./parser');
|
|
9
|
-
TypeWalker = require('./type-walker');
|
|
10
|
-
Optimiser = require('./optimiser').Optimiser;
|
|
11
|
-
Compiler = require('./compiler').Compiler;
|
|
12
|
-
reporter = require('./reporter');
|
|
13
|
-
TypeError = require('./type-helpers').TypeError;
|
|
14
|
-
mscodegen = function () {
|
|
15
|
-
try {
|
|
16
|
-
return require('mambacodegen');
|
|
17
|
-
} catch (e$) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
}.call(this);
|
|
21
|
-
escodegen = function () {
|
|
22
|
-
try {
|
|
23
|
-
return require('escodegen');
|
|
24
|
-
} catch (e$1) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}.call(this);
|
|
28
|
-
NewCoffeScript = require('coffeescript');
|
|
29
|
-
ESMRewriter = require('../utils/esm');
|
|
1
|
+
// Generated by MambaScript 2.0.0
|
|
2
|
+
var core, Decision, key, MambaScript, MambaView, stdlib, val;
|
|
3
|
+
core = require('./light-module');
|
|
30
4
|
MambaView = require('./black');
|
|
31
5
|
Decision = require('./decision');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
MambaScript =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Parser: Parser,
|
|
48
|
-
Preprocessor: Preprocessor,
|
|
49
|
-
Nodes: Nodes,
|
|
50
|
-
NewCoffeScript: NewCoffeScript,
|
|
51
|
-
MambaView: MambaView,
|
|
52
|
-
Decision: Decision,
|
|
53
|
-
VERSION: pkg.version,
|
|
54
|
-
parse: function (mamba, options) {
|
|
55
|
-
var e, parsed, preprocessed;
|
|
56
|
-
if (null == options)
|
|
57
|
-
options = {};
|
|
58
|
-
try {
|
|
59
|
-
preprocessed = Preprocessor.process(mamba, { literate: options.literate });
|
|
60
|
-
parsed = Parser.parse(preprocessed, {
|
|
61
|
-
raw: options.raw,
|
|
62
|
-
inputSource: options.inputSource
|
|
63
|
-
});
|
|
64
|
-
TypeWalker.checkNodes(parsed);
|
|
65
|
-
if (reporter.has_errors())
|
|
66
|
-
throw new TypeError(reporter.report());
|
|
67
|
-
return options.optimise ? Optimiser.optimise(parsed) : parsed;
|
|
68
|
-
} catch (e$2) {
|
|
69
|
-
e = e$2;
|
|
70
|
-
if (e instanceof TypeError)
|
|
71
|
-
throw e.message;
|
|
72
|
-
if (!(e instanceof Parser.SyntaxError))
|
|
73
|
-
throw e;
|
|
74
|
-
throw new Error(formatParserError(preprocessed, e));
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
esCompile: function (mamba, options) {
|
|
78
|
-
var jsAST, msAst;
|
|
79
|
-
if (null == options)
|
|
80
|
-
options = {};
|
|
81
|
-
msAst = this.parse(mamba);
|
|
82
|
-
jsAST = this.compile(msAst, { bare: true });
|
|
83
|
-
return this.jsEsm(jsAST);
|
|
84
|
-
},
|
|
85
|
-
compile: function (msAst, options) {
|
|
86
|
-
return Compiler.compile(msAst, options).toBasicObject();
|
|
87
|
-
},
|
|
88
|
-
compileTypedToCS: function (msAst, options) {
|
|
89
|
-
return mscodegen(msAst);
|
|
90
|
-
},
|
|
91
|
-
cs: function (msAst, options) {
|
|
92
|
-
},
|
|
93
|
-
jsWithSourceMap: function (jsAst, name, options) {
|
|
94
|
-
var targetName;
|
|
95
|
-
if (null == name)
|
|
96
|
-
name = 'unknown';
|
|
97
|
-
if (null == options)
|
|
98
|
-
options = {};
|
|
99
|
-
if (!(null != escodegen))
|
|
100
|
-
throw new Error('escodegen not found: run `npm install escodegen`');
|
|
101
|
-
if (!{}.hasOwnProperty.call(jsAst, 'type'))
|
|
102
|
-
jsAst = jsAst.toBasicObject();
|
|
103
|
-
targetName = options.sourceMapFile || options.sourceMap && options.output.match(/^.*[\\\/]([^\\\/]+)$/)[1];
|
|
104
|
-
return escodegen.generate(jsAst, {
|
|
105
|
-
comment: !options.compact,
|
|
106
|
-
sourceMapWithCode: true,
|
|
107
|
-
sourceMap: name,
|
|
108
|
-
file: targetName || 'unknown',
|
|
109
|
-
format: options.compact ? escodegen.FORMAT_MINIFY : null != options.format ? options.format : escodegenFormat
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
jsEsm: function (jsAst, options) {
|
|
113
|
-
var code;
|
|
114
|
-
code = this.jsWithSourceMap(jsAst, null, options).code;
|
|
115
|
-
return ESMRewriter(code);
|
|
116
|
-
},
|
|
117
|
-
js: function (jsAst, options) {
|
|
118
|
-
return this.jsWithSourceMap(jsAst, null, options).code;
|
|
119
|
-
},
|
|
120
|
-
sourceMap: function (jsAst, name, options) {
|
|
121
|
-
return this.jsWithSourceMap(jsAst, name, options).map;
|
|
122
|
-
},
|
|
123
|
-
cs2js: function (input, options) {
|
|
124
|
-
var jsAst, msAst;
|
|
125
|
-
if (null == options)
|
|
126
|
-
options = {};
|
|
127
|
-
if (null != options.optimise)
|
|
128
|
-
options.optimise;
|
|
129
|
-
else
|
|
130
|
-
options.optimise = true;
|
|
131
|
-
msAst = MambaScript.parse(input, options);
|
|
132
|
-
jsAst = MambaScript.compile(msAst, { bare: options.bare });
|
|
133
|
-
return MambaScript.js(jsAst, { compact: options.compact || options.minify });
|
|
134
|
-
},
|
|
135
|
-
smoothCompile: function (input, options) {
|
|
136
|
-
var jsAst, msAst;
|
|
137
|
-
if (null == options)
|
|
138
|
-
options = {};
|
|
139
|
-
if (null != options.optimise)
|
|
140
|
-
options.optimise;
|
|
141
|
-
else
|
|
142
|
-
options.optimise = true;
|
|
143
|
-
msAst = MambaScript.parse(input, options);
|
|
144
|
-
jsAst = MambaScript.compile(msAst, { bare: true });
|
|
145
|
-
return MambaScript.jsEsm(jsAst, { compact: options.compact || options.minify });
|
|
146
|
-
},
|
|
147
|
-
svelteCompile: function (input) {
|
|
148
|
-
var options;
|
|
149
|
-
options = {
|
|
150
|
-
optimize: true,
|
|
151
|
-
bare: true,
|
|
152
|
-
header: true,
|
|
153
|
-
compact: true
|
|
154
|
-
};
|
|
155
|
-
return this.cs2js(input, options);
|
|
156
|
-
}
|
|
6
|
+
stdlib = require('./underscore');
|
|
7
|
+
MambaScript = {};
|
|
8
|
+
for (key in core) {
|
|
9
|
+
if (!isOwn$(core, key))
|
|
10
|
+
continue;
|
|
11
|
+
val = core[key];
|
|
12
|
+
MambaScript[key] = val;
|
|
13
|
+
}
|
|
14
|
+
MambaScript.MambaScript = MambaScript;
|
|
15
|
+
MambaScript.MambaView = MambaView;
|
|
16
|
+
MambaScript.BlackMamba = MambaView;
|
|
17
|
+
MambaScript.Decision = Decision;
|
|
18
|
+
MambaScript.stdlib = stdlib;
|
|
19
|
+
MambaScript.register = function () {
|
|
20
|
+
return require('./register');
|
|
157
21
|
};
|
|
158
22
|
module.exports = MambaScript;
|
|
159
|
-
if (null != (null != require.extensions ? require.extensions['.node'] : void 0))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
'.coffee',
|
|
165
|
-
'.litcoffee',
|
|
166
|
-
'.mamba'
|
|
167
|
-
], i$ = 0, length$ = cache$.length; i$ < length$; ++i$) {
|
|
168
|
-
ext = cache$[i$];
|
|
169
|
-
if (null != require.extensions[ext])
|
|
170
|
-
require.extensions[ext];
|
|
171
|
-
else
|
|
172
|
-
require.extensions[ext] = function () {
|
|
173
|
-
throw new Error('Hey make sure to Use MambaScript.register() or require the register module to require ' + ext + ' files.');
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
23
|
+
if (null != (null != require.extensions ? require.extensions['.node'] : void 0))
|
|
24
|
+
require('./register');
|
|
25
|
+
function isOwn$(o, p) {
|
|
26
|
+
return {}.hasOwnProperty.call(o, p);
|
|
27
|
+
}
|
package/lib/nodes.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// Generated by MambaScript 0.
|
|
2
|
-
var
|
|
3
|
-
// Generated by MambaScript 0.5.2
|
|
4
|
-
var ArrayInitialiser, Block, Bool, Class, CompoundAssignOp, concat, concatMap, Conditional, createNodes, difference, exports, ForOf, FunctionApplications, Functions, GenSym, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, Primitives, Range, RegExp, RegExps, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, union, While;
|
|
1
|
+
// Generated by MambaScript 2.0.0
|
|
2
|
+
var ArrayInitialiser, Block, Bool, Break, cache$, cache$1, Class, CompoundAssignOp, concat, concatMap, Conditional, Continue, createNodes, difference, DynamicImport, exports, ForFrom, ForOf, FunctionApplications, Functions, GenSym, Grab, handleLists, handlePrimitives, HeregExp, Identifier, Identifiers, map, NegatedConditional, NewOp, Nodes, nub, ObjectInitialiser, ObjectInitialiserMember, Primitives, Range, RegExp, RegExps, Share, Slice, StaticMemberAccessOps, Super, Switch, SwitchCase, TaggedTemplate, union, While, Yield;
|
|
5
3
|
cache$ = require('./functional-helpers');
|
|
6
4
|
map = cache$.map;
|
|
7
5
|
concat = cache$.concat;
|
|
@@ -60,7 +58,7 @@ createNodes = function (subclasses, superclasses) {
|
|
|
60
58
|
if (null != ('undefined' !== typeof specs && null != specs ? specs[0] : void 0))
|
|
61
59
|
klass.prototype.childNodes = specs[0];
|
|
62
60
|
if (isCategory)
|
|
63
|
-
createNodes(specs[1], [klass].concat(
|
|
61
|
+
createNodes(specs[1], [klass].concat(Array.from(superclasses)));
|
|
64
62
|
return exports[className] = klass;
|
|
65
63
|
}(className));
|
|
66
64
|
}
|
|
@@ -141,6 +139,26 @@ createNodes({
|
|
|
141
139
|
'left',
|
|
142
140
|
'right'
|
|
143
141
|
]],
|
|
142
|
+
Yield: [[
|
|
143
|
+
'isDelegate',
|
|
144
|
+
'expression'
|
|
145
|
+
]],
|
|
146
|
+
TaggedTemplate: [[
|
|
147
|
+
'tag',
|
|
148
|
+
'quasis',
|
|
149
|
+
'expressions'
|
|
150
|
+
]],
|
|
151
|
+
Grab: [[
|
|
152
|
+
'isNamespace',
|
|
153
|
+
'assignee',
|
|
154
|
+
'source'
|
|
155
|
+
]],
|
|
156
|
+
Share: [[
|
|
157
|
+
'isAll',
|
|
158
|
+
'expression',
|
|
159
|
+
'source'
|
|
160
|
+
]],
|
|
161
|
+
DynamicImport: [['expression']],
|
|
144
162
|
SeqOp: null
|
|
145
163
|
}
|
|
146
164
|
],
|
|
@@ -170,6 +188,7 @@ createNodes({
|
|
|
170
188
|
PostDecrementOp: null,
|
|
171
189
|
PostIncrementOp: null,
|
|
172
190
|
TypeofOp: null,
|
|
191
|
+
AwaitOp: null,
|
|
173
192
|
UnaryExistsOp: null,
|
|
174
193
|
UnaryNegateOp: null,
|
|
175
194
|
UnaryPlusOp: null
|
|
@@ -239,6 +258,13 @@ createNodes({
|
|
|
239
258
|
'filter',
|
|
240
259
|
'body'
|
|
241
260
|
]],
|
|
261
|
+
ForFrom: [[
|
|
262
|
+
'isAwait',
|
|
263
|
+
'valAssignee',
|
|
264
|
+
'target',
|
|
265
|
+
'filter',
|
|
266
|
+
'body'
|
|
267
|
+
]],
|
|
242
268
|
Switch: [[
|
|
243
269
|
'expression',
|
|
244
270
|
'cases',
|
|
@@ -303,7 +329,8 @@ createNodes({
|
|
|
303
329
|
null,
|
|
304
330
|
{
|
|
305
331
|
Int: null,
|
|
306
|
-
Float: null
|
|
332
|
+
Float: null,
|
|
333
|
+
BigInt: null
|
|
307
334
|
}
|
|
308
335
|
],
|
|
309
336
|
String: null
|
|
@@ -346,6 +373,15 @@ Primitives = cache$1.Primitives;
|
|
|
346
373
|
CompoundAssignOp = cache$1.CompoundAssignOp;
|
|
347
374
|
StaticMemberAccessOps = cache$1.StaticMemberAccessOps;
|
|
348
375
|
Range = cache$1.Range;
|
|
376
|
+
ObjectInitialiserMember = cache$1.ObjectInitialiserMember;
|
|
377
|
+
Break = cache$1.Break;
|
|
378
|
+
Continue = cache$1.Continue;
|
|
379
|
+
ForFrom = cache$1.ForFrom;
|
|
380
|
+
Yield = cache$1.Yield;
|
|
381
|
+
TaggedTemplate = cache$1.TaggedTemplate;
|
|
382
|
+
Grab = cache$1.Grab;
|
|
383
|
+
Share = cache$1.Share;
|
|
384
|
+
DynamicImport = cache$1.DynamicImport;
|
|
349
385
|
ArrayInitialiser = cache$1.ArrayInitialiser;
|
|
350
386
|
ObjectInitialiser = cache$1.ObjectInitialiser;
|
|
351
387
|
NegatedConditional = cache$1.NegatedConditional;
|
|
@@ -436,16 +472,24 @@ Nodes.prototype.clone = function () {
|
|
|
436
472
|
return n;
|
|
437
473
|
};
|
|
438
474
|
Nodes.prototype['instanceof'] = function () {
|
|
439
|
-
var
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
475
|
+
var ancestry, c, i, klass, n;
|
|
476
|
+
klass = this.constructor;
|
|
477
|
+
if (!Object.prototype.hasOwnProperty.call(klass, 'ancestry')) {
|
|
478
|
+
ancestry = {};
|
|
479
|
+
ancestry[this.className] = true;
|
|
480
|
+
for (var i$ = 0, length$ = klass.superclasses.length; i$ < length$; ++i$) {
|
|
481
|
+
c = klass.superclasses[i$];
|
|
482
|
+
ancestry[c.prototype.className] = true;
|
|
483
|
+
}
|
|
484
|
+
klass.ancestry = ancestry;
|
|
485
|
+
}
|
|
486
|
+
ancestry = klass.ancestry;
|
|
487
|
+
n = arguments.length;
|
|
488
|
+
i = 0;
|
|
489
|
+
while (i < n) {
|
|
490
|
+
if (ancestry[arguments[i].prototype.className])
|
|
491
|
+
return true;
|
|
492
|
+
i++;
|
|
449
493
|
}
|
|
450
494
|
return false;
|
|
451
495
|
};
|
|
@@ -479,8 +523,15 @@ handlePrimitives = function (ctor) {
|
|
|
479
523
|
};
|
|
480
524
|
};
|
|
481
525
|
handlePrimitives(Class, 'boundMembers');
|
|
526
|
+
handlePrimitives(ObjectInitialiserMember, 'computed');
|
|
527
|
+
handlePrimitives(Break, 'label');
|
|
528
|
+
handlePrimitives(Continue, 'label');
|
|
482
529
|
handlePrimitives(CompoundAssignOp, 'op');
|
|
483
530
|
handlePrimitives(ForOf, 'isOwn');
|
|
531
|
+
handlePrimitives(ForFrom, 'isAwait');
|
|
532
|
+
handlePrimitives(Yield, 'isDelegate');
|
|
533
|
+
handlePrimitives(Grab, 'isNamespace');
|
|
534
|
+
handlePrimitives(Share, 'isAll');
|
|
484
535
|
handlePrimitives(HeregExp, 'flags');
|
|
485
536
|
handlePrimitives(Identifiers, 'data');
|
|
486
537
|
handlePrimitives(Primitives, 'data');
|
|
@@ -494,6 +545,7 @@ handleLists = function (ctor) {
|
|
|
494
545
|
return ctor.prototype.listMembers = listProps;
|
|
495
546
|
};
|
|
496
547
|
handleLists(ArrayInitialiser, 'members');
|
|
548
|
+
handleLists(TaggedTemplate, 'quasis', 'expressions');
|
|
497
549
|
handleLists(Block, 'statements');
|
|
498
550
|
handleLists(Functions, 'parameters');
|
|
499
551
|
handleLists(FunctionApplications, 'arguments');
|
|
@@ -525,9 +577,16 @@ Class.prototype.initialise = function () {
|
|
|
525
577
|
};
|
|
526
578
|
Class.prototype.childNodes.push('name');
|
|
527
579
|
ObjectInitialiser.prototype.keys = function () {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
580
|
+
var m;
|
|
581
|
+
return function (accum$) {
|
|
582
|
+
for (var i$ = 0, length$ = this.members.length; i$ < length$; ++i$) {
|
|
583
|
+
m = this.members[i$];
|
|
584
|
+
if (!(null != m.key))
|
|
585
|
+
continue;
|
|
586
|
+
accum$.push(m.key);
|
|
587
|
+
}
|
|
588
|
+
return accum$;
|
|
589
|
+
}.call(this, []);
|
|
531
590
|
};
|
|
532
591
|
ObjectInitialiser.prototype.vals = function () {
|
|
533
592
|
return map(this.members, function (m) {
|
|
@@ -541,7 +600,11 @@ RegExps.prototype.initialise = function (_, flags) {
|
|
|
541
600
|
'g',
|
|
542
601
|
'i',
|
|
543
602
|
'm',
|
|
544
|
-
'
|
|
603
|
+
's',
|
|
604
|
+
'u',
|
|
605
|
+
'y',
|
|
606
|
+
'd',
|
|
607
|
+
'v'
|
|
545
608
|
], i$ = 0, length$ = cache$2.length; i$ < length$; ++i$) {
|
|
546
609
|
flag = cache$2[i$];
|
|
547
610
|
this.flags[flag] = in$(flag, flags);
|
|
@@ -588,4 +651,4 @@ function in$(member, list) {
|
|
|
588
651
|
if (i in list && list[i] === member)
|
|
589
652
|
return true;
|
|
590
653
|
return false;
|
|
591
|
-
}
|
|
654
|
+
}
|
package/lib/optimiser.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
// Generated by MambaScript 0.
|
|
2
|
-
var
|
|
3
|
-
// Generated by MambaScript 0.5.2
|
|
4
|
-
var all, any, beingDeclared, concat, concatMap, declarationsFor, defaultRules, difference, envEnrichments, exports, foldl, foldl1, isFalsey, isTruthy, makeDispatcher, mayHaveSideEffects, MS, union, usedAsExpression;
|
|
1
|
+
// Generated by MambaScript 2.0.0
|
|
2
|
+
var all, any, beingDeclared, cache$, cache$1, concat, concatMap, declarationsFor, defaultRules, difference, envEnrichments, exports, extendScope, foldl, foldl1, isFalsey, isTruthy, makeDispatcher, mayHaveSideEffects, MS, union, usedAsExpression;
|
|
5
3
|
cache$ = require('./functional-helpers');
|
|
6
4
|
all = cache$.all;
|
|
7
5
|
any = cache$.any;
|
|
@@ -11,6 +9,7 @@ difference = cache$.difference;
|
|
|
11
9
|
foldl = cache$.foldl;
|
|
12
10
|
foldl1 = cache$.foldl1;
|
|
13
11
|
union = cache$.union;
|
|
12
|
+
extendScope = cache$.extendScope;
|
|
14
13
|
cache$1 = require('./helpers');
|
|
15
14
|
beingDeclared = cache$1.beingDeclared;
|
|
16
15
|
declarationsFor = cache$1.declarationsFor;
|
|
@@ -52,6 +51,7 @@ isTruthy = makeDispatcher(false, [
|
|
|
52
51
|
MS.DeleteOp,
|
|
53
52
|
MS.ForIn,
|
|
54
53
|
MS.ForOf,
|
|
54
|
+
MS.ForFrom,
|
|
55
55
|
MS.Function,
|
|
56
56
|
MS.BoundFunction,
|
|
57
57
|
MS.HeregExp,
|
|
@@ -90,6 +90,12 @@ isTruthy = makeDispatcher(false, [
|
|
|
90
90
|
return !!this.data;
|
|
91
91
|
}
|
|
92
92
|
],
|
|
93
|
+
[
|
|
94
|
+
MS.BigInt,
|
|
95
|
+
function () {
|
|
96
|
+
return !/^(0[xob])?0+$/.test(this.data);
|
|
97
|
+
}
|
|
98
|
+
],
|
|
93
99
|
[
|
|
94
100
|
MS.Conditional,
|
|
95
101
|
function () {
|
|
@@ -180,6 +186,12 @@ isFalsey = makeDispatcher(false, [
|
|
|
180
186
|
return !this.data;
|
|
181
187
|
}
|
|
182
188
|
],
|
|
189
|
+
[
|
|
190
|
+
MS.BigInt,
|
|
191
|
+
function () {
|
|
192
|
+
return /^(0[xob])?0+$/.test(this.data);
|
|
193
|
+
}
|
|
194
|
+
],
|
|
183
195
|
[
|
|
184
196
|
MS.Conditional,
|
|
185
197
|
function () {
|
|
@@ -257,6 +269,12 @@ mayHaveSideEffects = makeDispatcher(false, [
|
|
|
257
269
|
MS.NewOp,
|
|
258
270
|
MS.Return,
|
|
259
271
|
MS.Super,
|
|
272
|
+
MS.Yield,
|
|
273
|
+
MS.ForFrom,
|
|
274
|
+
MS.TaggedTemplate,
|
|
275
|
+
MS.Grab,
|
|
276
|
+
MS.Share,
|
|
277
|
+
MS.DynamicImport,
|
|
260
278
|
MS.PreDecrementOp,
|
|
261
279
|
MS.PreIncrementOp,
|
|
262
280
|
MS.PostDecrementOp,
|
|
@@ -266,6 +284,7 @@ mayHaveSideEffects = makeDispatcher(false, [
|
|
|
266
284
|
MS.Throw,
|
|
267
285
|
MS.JavaScript,
|
|
268
286
|
MS.ExtendsOp,
|
|
287
|
+
MS.AwaitOp,
|
|
269
288
|
function () {
|
|
270
289
|
return true;
|
|
271
290
|
}
|
|
@@ -308,7 +327,7 @@ mayHaveSideEffects = makeDispatcher(false, [
|
|
|
308
327
|
function (inScope) {
|
|
309
328
|
if (mayHaveSideEffects(this.left, inScope))
|
|
310
329
|
return true;
|
|
311
|
-
if (this.left['instanceof'](MS.
|
|
330
|
+
if (this.left['instanceof'](MS.Int, MS.Float, MS.String, MS.Bool, MS.Function, MS.BoundFunction, MS.RegExp, MS.HeregExp, MS.ArrayInitialiser, MS.ObjectInitialiser))
|
|
312
331
|
return false;
|
|
313
332
|
return mayHaveSideEffects(this.right, inScope);
|
|
314
333
|
}
|
|
@@ -367,6 +386,7 @@ mayHaveSideEffects = makeDispatcher(false, [
|
|
|
367
386
|
MS.Float,
|
|
368
387
|
MS.Identifier,
|
|
369
388
|
MS.Int,
|
|
389
|
+
MS.BigInt,
|
|
370
390
|
MS.String,
|
|
371
391
|
function () {
|
|
372
392
|
return false;
|
|
@@ -389,7 +409,7 @@ exports.Optimiser = function () {
|
|
|
389
409
|
Optimiser.optimise = function (this$) {
|
|
390
410
|
return function () {
|
|
391
411
|
var cache$2;
|
|
392
|
-
return (cache$2 = new this$).optimise.apply(cache$2,
|
|
412
|
+
return (cache$2 = new this$).optimise.apply(cache$2, Array.from(arguments));
|
|
393
413
|
};
|
|
394
414
|
}(Optimiser);
|
|
395
415
|
Optimiser.isTruthy = isTruthy;
|
|
@@ -751,7 +771,7 @@ exports.Optimiser = function () {
|
|
|
751
771
|
ancestry: ancestry
|
|
752
772
|
}), fn, inScope, ancestry)) {
|
|
753
773
|
}
|
|
754
|
-
inScope =
|
|
774
|
+
inScope = extendScope(inScope, envEnrichments(this[childName][n], inScope));
|
|
755
775
|
}
|
|
756
776
|
} else {
|
|
757
777
|
while (this[childName] !== walk.call(this[childName] = fn.call(this[childName], {
|
|
@@ -759,7 +779,7 @@ exports.Optimiser = function () {
|
|
|
759
779
|
ancestry: ancestry
|
|
760
780
|
}), fn, inScope, ancestry)) {
|
|
761
781
|
}
|
|
762
|
-
inScope =
|
|
782
|
+
inScope = extendScope(inScope, envEnrichments(this[childName], inScope));
|
|
763
783
|
}
|
|
764
784
|
}
|
|
765
785
|
ancestry.shift();
|
|
@@ -813,4 +833,4 @@ function in$(member, list) {
|
|
|
813
833
|
if (i in list && list[i] === member)
|
|
814
834
|
return true;
|
|
815
835
|
return false;
|
|
816
|
-
}
|
|
836
|
+
}
|
package/lib/optparse.js
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
// Generated by MambaScript 0.
|
|
2
|
-
var
|
|
3
|
-
// Generated by MambaScript 0.5.2
|
|
4
|
-
var buildRule, buildRules, LONG_FLAG, MULTI_FLAG, normalizeArguments, OPTIONAL, OptionParser, SHORT_FLAG;
|
|
1
|
+
// Generated by MambaScript 2.0.0
|
|
2
|
+
var buildRule, buildRules, LONG_FLAG, MULTI_FLAG, NEGATED_FLAG, normalizeArguments, OPTIONAL, OptionParser, SHORT_FLAG;
|
|
5
3
|
exports.OptionParser = OptionParser = function () {
|
|
6
4
|
function OptionParser(rules, param$) {
|
|
7
5
|
this.banner = param$;
|
|
8
6
|
this.rules = buildRules(rules);
|
|
9
7
|
}
|
|
10
|
-
OptionParser.prototype.parse = function (args) {
|
|
11
|
-
var arg, i, isOption, matchedRule, options, rule, value;
|
|
8
|
+
OptionParser.prototype.parse = function (args, param$) {
|
|
9
|
+
var arg, i, interleaved, isOption, matchedRule, negated, options, rule, value;
|
|
10
|
+
if (null == param$)
|
|
11
|
+
param$ = {};
|
|
12
|
+
interleaved = param$.interleaved;
|
|
12
13
|
options = {
|
|
13
14
|
'arguments': [],
|
|
14
15
|
literals: []
|
|
15
16
|
};
|
|
16
17
|
args = normalizeArguments(args);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
i = -1;
|
|
19
|
+
while (++i < args.length) {
|
|
20
|
+
arg = args[i];
|
|
20
21
|
if (arg === '--') {
|
|
21
22
|
options.literals = args.slice(i + 1);
|
|
22
23
|
break;
|
|
23
24
|
}
|
|
24
25
|
isOption = !!(arg.match(LONG_FLAG) || arg.match(SHORT_FLAG));
|
|
25
26
|
matchedRule = false;
|
|
27
|
+
if (negated = arg.match(NEGATED_FLAG)) {
|
|
28
|
+
for (var i$ = 0, length$ = this.rules.length; i$ < length$; ++i$) {
|
|
29
|
+
rule = this.rules[i$];
|
|
30
|
+
if (!(rule.longFlag === '--' + negated[1] && !rule.hasArgument))
|
|
31
|
+
continue;
|
|
32
|
+
options[rule.name] = false;
|
|
33
|
+
matchedRule = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (matchedRule)
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
26
39
|
for (var i$1 = 0, length$1 = this.rules.length; i$1 < length$1; ++i$1) {
|
|
27
40
|
rule = this.rules[i$1];
|
|
28
41
|
if (rule.shortFlag === arg || rule.longFlag === arg) {
|
|
@@ -34,10 +47,13 @@ exports.OptionParser = OptionParser = function () {
|
|
|
34
47
|
}
|
|
35
48
|
if (isOption && !matchedRule)
|
|
36
49
|
throw new Error('unrecognized option: ' + arg);
|
|
37
|
-
if (!isOption)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
if (!isOption)
|
|
51
|
+
if (interleaved) {
|
|
52
|
+
options['arguments'].push(arg);
|
|
53
|
+
} else {
|
|
54
|
+
options['arguments'] = args.slice(i);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
41
57
|
}
|
|
42
58
|
return options;
|
|
43
59
|
};
|
|
@@ -58,6 +74,7 @@ exports.OptionParser = OptionParser = function () {
|
|
|
58
74
|
return OptionParser;
|
|
59
75
|
}();
|
|
60
76
|
LONG_FLAG = /^(--\w[\w\-]+)/;
|
|
77
|
+
NEGATED_FLAG = /^--no-(\w[\w\-]*)$/;
|
|
61
78
|
SHORT_FLAG = /^(-\w)/;
|
|
62
79
|
MULTI_FLAG = /^-(\w{2,})/;
|
|
63
80
|
OPTIONAL = /\[(\w+(\*?))\]/;
|
|
@@ -68,7 +85,7 @@ buildRules = function (rules) {
|
|
|
68
85
|
tuple = rules[i$];
|
|
69
86
|
if (tuple.length < 3)
|
|
70
87
|
tuple.unshift(null);
|
|
71
|
-
accum$.push(buildRule.apply(null,
|
|
88
|
+
accum$.push(buildRule.apply(null, Array.from(tuple)));
|
|
72
89
|
}
|
|
73
90
|
return accum$;
|
|
74
91
|
}.call(this, []);
|
|
@@ -104,4 +121,4 @@ normalizeArguments = function (args) {
|
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
123
|
return result;
|
|
107
|
-
};
|
|
124
|
+
};
|