Compare commits

...

119 Commits

Author SHA1 Message Date
Sebastian McKenzie
9aa010d987 v2.11.4 2015-01-13 20:15:35 +11:00
Sebastian McKenzie
bd179ace86 add 2.11.4 changelog 2015-01-13 20:08:38 +11:00
Sebastian McKenzie
4df6d6043e make dependency versions static - fixes #475 2015-01-13 20:07:34 +11:00
Sebastian McKenzie
7ed7475c46 v2.11.3 2015-01-13 14:35:14 +11:00
Sebastian McKenzie
b2dc560a2d allow a string to be passed as the optional option 2015-01-13 14:33:18 +11:00
Sebastian McKenzie
010dbe1cce v2.11.2 2015-01-13 11:29:46 +11:00
Sebastian McKenzie
75cd0bab02 add 2.11.2 changelog 2015-01-13 11:26:07 +11:00
Sebastian McKenzie
3283991ed0 flip es6 geneartors include regenerator tests 2015-01-13 10:56:36 +11:00
Sebastian McKenzie
a66ce5b6ce add ignore ast check to es6 generators test because regenerator outputs an invalid ast 2015-01-13 10:44:17 +11:00
Sebastian McKenzie
9620f50f22 fix #474 test 2015-01-13 10:32:39 +11:00
Sebastian McKenzie
cc049ea851 Merge pull request #474 from amasad/master
Handle esprima-like AST catch clause in a TryStatement. Fixes #473
2015-01-13 10:26:47 +11:00
Amjad Masad
e5a04ae117 Add test 2015-01-12 17:56:16 -05:00
Amjad Masad
e07e74f010 Handle esprima-like AST catch clause in a TryStatement. Fixes #473 2015-01-12 17:32:02 -05:00
Sebastian McKenzie
7b04c501eb fix formatting of #472 2015-01-13 08:54:43 +11:00
Sebastian McKenzie
70349dd4b3 Merge pull request #472 from monsanto/no-traceback-on-syntax-err
don't print traceback on syntax error in CLI
2015-01-13 08:52:42 +11:00
Christopher Monsanto
2cedc843a8 don't print traceback on syntax error in CLI 2015-01-12 16:49:28 -05:00
Sebastian McKenzie
cf40fe3430 v2.11.1 2015-01-13 08:21:54 +11:00
Sebastian McKenzie
09ffeed139 add 2.11.1 changelog 2015-01-13 08:19:33 +11:00
Sebastian McKenzie
18f79d6253 Merge pull request #470 from monsanto/fix-dict-aliasing
remove Dict from core aliasable constructors
2015-01-13 08:17:23 +11:00
Christopher Monsanto
6f5270f38f remove Dict from core aliasable constructors 2015-01-12 14:00:43 -05:00
Brian Donovan
aac7aac373 Merge pull request #469 from clavery/master
remove console.log from react transforms
2015-01-12 10:29:29 -08:00
Charles Lavery
9361470dc7 remove console.log from react transforms 2015-01-12 13:19:32 -05:00
Sebastian McKenzie
cf579f4b6e v2.11.0 2015-01-13 01:53:03 +11:00
Sebastian McKenzie
2e497eef98 fix linting errors 2015-01-13 01:51:21 +11:00
Sebastian McKenzie
7867daaa04 add 2.11.0 changelog 2015-01-13 01:50:30 +11:00
Sebastian McKenzie
eabbcd31ad add comments to ambiguous code 2015-01-13 01:50:30 +11:00
Sebastian McKenzie
17d198f3d6 Merge pull request #468 from AluisioASG/core-aliasable
Whitelist constructors aliasable to core-js
2015-01-13 01:46:19 +11:00
Aluísio Augusto Silva Gonçalves
afd5376c8d Whitelist constructors aliasable to core-js
Expand the list of identifiers for which we substitute `_core.<Something>`
for `<Something>`.  Also an alternative fix for #421.
2015-01-12 12:29:37 -02:00
Sebastian McKenzie
02a50c9f7e fix unnecessary default parameter iife - fixes #251 2015-01-13 01:16:00 +11:00
Sebastian McKenzie
df9fa32b82 add optional to keep module id extensions - fixes #420 2015-01-13 01:12:14 +11:00
Sebastian McKenzie
831b420df3 special case single super method call with spread, fixes #227 2015-01-13 01:09:10 +11:00
Sebastian McKenzie
123186003c add support for super instead of closures - fixes #425 2015-01-13 01:00:35 +11:00
Sebastian McKenzie
ea627ed57c don't use function variable declaration for class constructor 2015-01-13 00:03:52 +11:00
Sebastian McKenzie
157bb48776 add 3.0.0 fast transformer note 2015-01-12 23:27:04 +11:00
Sebastian McKenzie
76a3771943 change ambiguous _inherits parameters 2015-01-12 20:54:37 +11:00
Sebastian McKenzie
54f8889a30 v2.10.1 2015-01-12 20:09:54 +11:00
Sebastian McKenzie
bab159bc08 fix version number in changelog 2015-01-12 20:08:14 +11:00
Sebastian McKenzie
23950963e5 add upgrade core-js note 2015-01-12 20:07:51 +11:00
Sebastian McKenzie
d1daac5550 add global shim due to core-js 0.4.4 2015-01-12 20:07:30 +11:00
Sebastian McKenzie
d93ece5ccf add 2.10.11 changelog 2015-01-12 20:05:19 +11:00
Sebastian McKenzie
c8c667bf16 add back loop ensure block 2015-01-12 20:04:19 +11:00
Sebastian McKenzie
49cdacbcb4 add includeRegenerator option 2015-01-12 20:03:02 +11:00
Sebastian McKenzie
f97bd584f7 upgrade core-js 2015-01-12 19:49:04 +11:00
Sebastian McKenzie
f1328aa82f v2.10.0 2015-01-12 11:52:32 +11:00
Sebastian McKenzie
e298a5d350 remove unused check function 2015-01-12 11:50:45 +11:00
Sebastian McKenzie
89a6ef0b26 add 2.10.0 changelog 2015-01-12 11:50:19 +11:00
Sebastian McKenzie
c7ac9b7815 rename --reactCompat arg to --react-compat 2015-01-12 11:47:04 +11:00
Sebastian McKenzie
55c99b9122 upgrade acorn-6to5 2015-01-12 11:45:21 +11:00
Sebastian McKenzie
545c8c3adb define class methods instead of assigning them - fixes #454 2015-01-12 11:44:23 +11:00
Sebastian McKenzie
d093dc8231 disallow setters without one parameter - fixes #455 2015-01-12 10:25:37 +11:00
Sebastian McKenzie
eaf9d58b8d Merge branch 'master' of github.com:6to5/6to5 2015-01-12 10:19:53 +11:00
Sebastian McKenzie
6131cea5b2 add classesFastSuper optional transformer - fixes #451 2015-01-12 10:19:22 +11:00
Sebastian McKenzie
ca4831febe Merge pull request #453 from amasad/master
Add --reactCompat option to cli
2015-01-12 09:57:21 +11:00
Amjad Masad
9cf8d05a19 Add --reactCompat option to cli 2015-01-11 12:47:17 -05:00
Sebastian McKenzie
2a4f03330b better bin name for 6to5-node 2015-01-11 22:59:36 +11:00
Sebastian McKenzie
83bc614bad add note about splitting up super transforming #411 2015-01-11 22:42:45 +11:00
Sebastian McKenzie
99ccb4111a start adding support for this mapping for supers 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
f6c72e9ae9 add newline to scope 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
a90730d4bf Merge pull request #449 from monsanto/fix-6to5-node-name
fix _6to5-node name in help screen
2015-01-11 18:19:04 +11:00
Christopher Monsanto
29503d2d37 fix _6to5-node name in help screen 2015-01-10 23:04:13 -05:00
Sebastian McKenzie
35451ed408 Merge pull request #447 from fkling/cli
Fix short --whitelist option
2015-01-11 11:21:41 +11:00
Felix Kling
7167aeb65a Fix short --whitelist option
`6to5 -w generators` doesn't work because `-w` is also short for
`--watch`. This changes the short option for `--whitelist` to `-l`.
2015-01-10 11:03:26 -08:00
Sebastian McKenzie
29d0489443 add autoindentation note 2015-01-11 04:55:34 +11:00
Sebastian McKenzie
82aa2686f9 fix writable being set on accessors 2015-01-11 04:55:27 +11:00
Sebastian McKenzie
24616fa08a fix linting errors 2015-01-11 03:35:37 +11:00
Sebastian McKenzie
9f3e1eabfd simplify define properties 2015-01-11 03:21:05 +11:00
Sebastian McKenzie
286d2f84bd add configurable and writable property to defined properties 2015-01-11 02:43:17 +11:00
Sebastian McKenzie
7fc484d82e add ES5 getter/setter split up note - closes #444 2015-01-11 02:30:11 +11:00
Sebastian McKenzie
ad6ab57fe3 only use raw type references in coreAliasing on Symbol - fixes #421 2015-01-11 01:00:04 +11:00
Sebastian McKenzie
348fe045d3 reformat for of transformers and add pattern support 2015-01-11 00:35:41 +11:00
Sebastian McKenzie
980b20316b Merge pull request #441 from monsanto/fast-for-of
Optional for-of transformer that puts arrays in fast path
2015-01-11 00:32:56 +11:00
Sebastian McKenzie
5b52e507ca fix non-identifier class super tests 2015-01-10 22:55:19 +11:00
Sebastian McKenzie
9853c9d78d add empty statement case to toBlock 2015-01-10 22:42:35 +11:00
Sebastian McKenzie
72ec771725 fix unnecessarily shifting super ref 2015-01-10 22:42:20 +11:00
Sebastian McKenzie
75e97d9f7e format scope default declarations better 2015-01-10 22:34:08 +11:00
Sebastian McKenzie
295faf185c remove unnecessary ensureBlock in let scoping transformer #434 2015-01-10 22:33:57 +11:00
Sebastian McKenzie
54b05f33f2 move super reference into closure 2015-01-10 22:26:51 +11:00
Sebastian McKenzie
1985146760 use Array.isArray instead of _.isArray 2015-01-10 22:26:37 +11:00
Sebastian McKenzie
13a52dd300 always use an IIFE for classes - fixes #435 2015-01-10 22:18:30 +11:00
Sebastian McKenzie
9d4bea70e6 Merge pull request #433 from gaearon/perf-traverse-refactor
Refactor traversal to avoid closures for perf
2015-01-10 22:06:08 +11:00
Dan Abramov
421906bcc1 Refactor traversal to avoid closures 2015-01-10 14:02:08 +03:00
Sebastian McKenzie
508b3531e5 Merge pull request #432 from gaearon/perf-stable
Replace _.each and for-in with for loop in hot paths
2015-01-10 21:49:37 +11:00
Sebastian McKenzie
c67c407cd0 v2.9.4 2015-01-10 16:28:02 +11:00
Sebastian McKenzie
aa552fea0d add 2.9.4 changelog 2015-01-10 16:25:39 +11:00
Sebastian McKenzie
9bbf109dc8 support UpdateExpressions as MemberExpression objects - fixes #440 2015-01-10 16:24:17 +11:00
Christopher Monsanto
393d52088a optional for-of transformer that puts arrays in fast path 2015-01-09 20:53:48 -05:00
Dan Abramov
5783973734 A few minor perf improvements 2015-01-09 22:00:07 +03:00
Dan Abramov
55e01afd0d Improve performance on hot paths by using for loops 2015-01-09 16:51:34 +03:00
Dan Abramov
1231dc6cef Replace _.each and for-in with for loop in hot paths 2015-01-09 16:00:53 +03:00
Sebastian McKenzie
b08f2061b5 fix destructuring tests 2015-01-09 21:43:24 +11:00
Sebastian McKenzie
1536d3de91 Revert "add base optional object observe transformer"
This reverts commit b619e843a9.
2015-01-09 21:18:55 +11:00
Sebastian McKenzie
fddacb1612 don't assign array expressions to a temp variable in destructuring #431 2015-01-09 21:18:51 +11:00
Sebastian McKenzie
9d1ff2b71b v2.9.3 2015-01-09 20:10:17 +11:00
Sebastian McKenzie
1c8d24f78c remove exportsWildcard helper in favor of defaults #430 2015-01-09 20:08:05 +11:00
Sebastian McKenzie
b619e843a9 add base optional object observe transformer 2015-01-09 19:57:21 +11:00
Sebastian McKenzie
e6a71c5849 move npm version up 2015-01-09 19:56:22 +11:00
Sebastian McKenzie
682668c219 v2.9.2 2015-01-09 19:51:44 +11:00
Sebastian McKenzie
dd64297838 add 2.9.2 changelog 2015-01-09 19:49:10 +11:00
Sebastian McKenzie
944a9d3908 pass exports to exportsWildcard - fixes #430 2015-01-09 19:48:11 +11:00
Sebastian McKenzie
d6922c9b75 v2.9.1 2015-01-09 19:34:28 +11:00
Sebastian McKenzie
fb0fcc7138 fix runtime generator breaking the helper inclusion loop - fixes #429 2015-01-09 19:31:43 +11:00
Sebastian McKenzie
89148e6029 Merge pull request #424 from 6to5/more-super-issues
Ensure more than one level of superclass works.
2015-01-09 08:35:40 +11:00
Brian Donovan
28d10b8eb4 Ensure more than one level of superclass works. 2015-01-08 13:33:02 -08:00
Sebastian McKenzie
3509990563 enable esnext tests by default 2015-01-09 07:23:17 +11:00
Sebastian McKenzie
c5960fb9f7 Merge pull request #408 from 6to5/fix-esnext-class-tests
[WIP] Fix super with getters and setters and with class prototypes changing.
2015-01-09 07:22:35 +11:00
Brian Donovan
07131576cf Use undefined instead of void 0. 2015-01-08 11:59:01 -08:00
Sebastian McKenzie
e75e778300 v2.9.0 2015-01-09 06:02:43 +11:00
Sebastian McKenzie
f6cb14c975 upgrade acorn-6to5 2015-01-09 06:00:19 +11:00
Brian Donovan
af1912ab7a Ensure constructors use the current super class.
This is an extension of 324a4a1b22.
2015-01-08 09:31:18 -08:00
Brian Donovan
8c478f29bc Use desc.writable instead of "writable" in desc as suggested by @stefanpenner. 2015-01-08 09:21:35 -08:00
Brian Donovan
5b4d6d7ba9 Replace superIdentifier with superProperty.
This also disallows the usage of bare `super` that is not part of a
member expression, call expression, or new expression.
2015-01-08 09:21:32 -08:00
Sebastian McKenzie
1776b072b0 v2.8.2 2015-01-09 00:08:42 +11:00
Sebastian McKenzie
726fad1b6c move publish-core into publish task 2015-01-09 00:06:21 +11:00
Sebastian McKenzie
23c16b0094 fix github url in no templates directory 2015-01-09 00:06:12 +11:00
Sebastian McKenzie
24f70ee4d0 add alternate core package - fixes #387 2015-01-08 23:31:03 +11:00
Sebastian McKenzie
fe9b0afd95 v2.8.1 2015-01-08 23:14:56 +11:00
Sebastian McKenzie
47695a8710 add 2.8.1 changelog 2015-01-08 23:12:36 +11:00
Sebastian McKenzie
e1c7584280 fix computed accessors on objects 2015-01-08 23:11:58 +11:00
Brian Donovan
324a4a1b22 Fix super with getters and setters and with class prototypes changing. 2015-01-07 21:10:36 -08:00
112 changed files with 2056 additions and 701 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@ test/tmp
/runtime.js
coverage
dist
.package.json

View File

@@ -9,3 +9,4 @@ Makefile
dist
tests.json
CHANGELOG.md
.package.json

View File

@@ -11,6 +11,96 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 2.11.4
* **Internal**
* Make all dependency versions fixed.
## 2.11.3
* **Bug Fix**
* Allow a string to be passed as the `optional` option.
## 2.11.2
* **Bug Fix**
* Support esprima-style catch clause handlers.
* **Polish**
* Don't print a stacktrace for syntax errors in the CLI.
## 2.11.1
* **Bug Fix**
* Remove stray `console.log` outputting debug code.
* Remove `Dict` from `coreAliasing`.
## 2.11.0
* **Bug Fix**
* Fix unnecessary IIFE in default parameters on method calls.
* Add support for supers inside of closures.
* **New Feature**
* Add `--keep-module-id-extensions`/`keepModuleIdExtensions` option to keep extensions in module ids.
* **Polish**
* Special case single argument spread properties in `super` inside classes.
* Don't use a variable declaration for class declaration IFFE.
* Rename `inherits` helper parameters.
* `coreAliasing` transformer now aliases `Promise`, `Set`, `Map` and more. Thanks [@AluisioASG](https://github.com/AluisioASG).
## 2.10.1
* **Internal**
* Upgrade `core-js` to `0.4.4`.
* **New Feature**
* Added `--include-regenerator` option to CLI and `includeRegenerator` option to API that includes the regenerator runtime if necessary.
## 2.10.0
* **New Feature**
* Add `classesFastSuper` optional transformer that doesn't support parent getters and prototype changing.
* Add `forOfFast` transformer that speeds up `for...of` on arrays but produces more code.
* Add `--react-compat` to `bin/6to5`.
* **Spec Compliancy**
* Disallow setters without a single parameter.
* Add `configurable` and `writable` to defined properties.
* Use define instead of assignment for class methods.
* **Polish**
* Fix bin name in `6to5-node --help`.
* Fix shorthand `--whitelist` name in `bin/6to5`.
* **Internal**
* Hot code optimisation of traversal etc thanks to [gaearon](https://github.com/gaearon).
## 2.9.4
* **Bug Fix**
* Support `UpdateExpression`s as `MemberExpression` objects.
## 2.9.3
* **Bug Fix**
* Remove `exportsWildcard` helper in favor of `defaults`.
## 2.9.2
* **Bug Fix**
* Pass `exports` to `exportWildcard` helper to allow for use inside the optional runtime.
## 2.9.1
* **Bug Fix**
* Fix runtime generator breaking the helper inclusion loop.
## 2.9.0
* **Internal**
* Upgrade `acorn-6to5`.
* Now supports destructuring shorthand properties.
## 2.8.1
* **Bug Fix**
* Fix computed accessors on object literals.
## 2.8.0
* **New Feature**

View File

@@ -6,7 +6,7 @@ MOCHA_CMD = node_modules/mocha/bin/_mocha
export NODE_ENV = test
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core
build:
mkdir -p dist
@@ -71,6 +71,9 @@ publish:
make test
read -p "Version: " version; \
npm version $$version --message "v%s"
make build
cp dist/6to5.min.js browser.js
cp dist/polyfill.min.js browser-polyfill.js
@@ -79,12 +82,21 @@ publish:
node bin/cache-templates
test -f templates.json
read -p "Version: " version; \
npm version $$version --message "v%s"
npm publish
git push --follow-tags
# generate
bin/generate-core-package-json >package2.json
mv package.json .package.json
mv package2.json package.json
npm publish
# restore
rm -rf package.json
mv .package.json package.json
rm -rf templates.json browser.js runtime.js browser-polyfill.js
bootstrap:

View File

@@ -7,3 +7,7 @@
* Remove `allowImportExportEverywhere` option from acorn.
* Remove this shorthand from playground.
* Remove `super()` inside non-constructors - add descriptive error message.
* Split up ES5 getter/setter transforming and ES6 property methods into separate transformers.
* Add autoindentation.
* Move `super` transformation from classes into a separate transformer that also supports object expressions.
* Prefix all fast transformers with `fast`, make them declare that they're a fast transformer similar to optional transformers and add a `--fast` flag to enable them all.

View File

@@ -15,7 +15,7 @@ commander.option("-e, --experimental", "Enable experimental support for proposed
commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
@@ -24,6 +24,9 @@ commander.option("-c, --remove-comments", "Remove comments from the compiled cod
commander.option("-I, --indent [width]", "Indent width [2]", 2);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false);
commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.on("--help", function(){
var outKeys = function (title, obj) {
@@ -99,17 +102,20 @@ if (errors.length) {
//
exports.opts = {
sourceMapName: commander.outFile,
experimental: commander.experimental,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
keepModuleIdExtensions: commander.keepModuleIdExtensions,
includeRegenerator: commander.includeRegenerator,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
format: {
indent: {
style: util.repeat(parseInt(commander.indent))

View File

@@ -20,7 +20,17 @@ exports.transform = function (filename, code, opts) {
opts = _.extend(opts || {}, index.opts);
opts.filename = filename;
var result = to5.transform(code, opts);
var result;
try {
result = to5.transform(code, opts);
} catch (e) {
if (e instanceof SyntaxError) {
console.error("SyntaxError:", e.message);
process.exit(1);
} else {
throw e;
}
}
result.filename = filename;
result.actual = code;
return result;

View File

@@ -10,29 +10,31 @@ var util = require("../lib/6to5/util");
var vm = require("vm");
var _ = require("lodash");
commander.option("-e, --eval [script]", "Evaluate script");
commander.option("-p, --print", "Evaluate script and print result");
commander.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
commander.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js]");
commander.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-g, --playground", "Enable playground support");
commander.option("-c, --cache", "Cache compiled files and require paths");
var program = new commander.Command("6to5-node");
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print", "Evaluate script and print result");
program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js]");
program.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
program.option("-g, --playground", "Enable playground support");
program.option("-c, --cache", "Cache compiled files and require paths");
var pkg = require("../package.json");
commander.version(pkg.version);
commander.usage("[options] [ -e script | script.js ] [arguments]");
commander.parse(process.argv);
program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
if (commander.cache) roadrunner.load();
if (program.cache) roadrunner.load();
//
to5.register({
experimental: commander.experimental,
extensions: commander.extensions,
playground: commander.playground,
ignore: commander.ignore,
cache: commander.cache && roadrunner.get("6to5")
experimental: program.experimental,
extensions: program.extensions,
playground: program.playground,
ignore: program.ignore,
cache: program.cache && roadrunner.get("6to5")
});
//
@@ -41,17 +43,17 @@ var _eval = function (code, filename) {
code = to5.transform(code, {
filename: filename,
blacklist: ["useStrict"],
experimental: commander.experimental,
playground: commander.playground
experimental: program.experimental,
playground: program.playground
}).code;
return vm.runInThisContext(code, filename);
};
if (commander.eval) {
var result = _eval(commander.eval, "eval");
if (commander.print) console.log(result);
if (program.eval) {
var result = _eval(program.eval, "eval");
if (program.print) console.log(result);
} else {
if (commander.args.length) {
if (program.args.length) {
// slice all arguments up to the first filename since they're 6to5 args that we handle
var args = process.argv.slice(2);
@@ -77,7 +79,7 @@ if (commander.eval) {
}
}
if (commander.cache) roadrunner.save();
if (program.cache) roadrunner.save();
function replStart() {
repl.start({

11
bin/generate-core-package-json Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env node
var pkg = require("../package.json");
pkg.name += "-core";
delete pkg.dependencies.chokidar;
delete pkg.optionalDependencies;
delete pkg.devDependencies;
delete pkg.preferGlobal;
delete pkg.scripts;
delete pkg.bin;
console.log(JSON.stringify(pkg, null, " "));

View File

@@ -35,8 +35,8 @@ File.helpers = [
"async-to-generator",
"interop-require-wildcard",
"typeof",
"exports-wildcard",
"extends"
"extends",
"get"
];
File.excludeHelpersFromRuntime = [
@@ -48,21 +48,23 @@ File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {});
_.defaults(opts, {
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
code: true,
ast: true
keepModuleIdExtensions: false,
includeRegenerator: false,
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
code: true,
ast: true
});
// normalise windows path separators to unix
@@ -70,6 +72,7 @@ File.normaliseOptions = function (opts) {
opts.blacklist = util.arrayify(opts.blacklist);
opts.whitelist = util.arrayify(opts.whitelist);
opts.optional = util.arrayify(opts.optional);
_.defaults(opts, {
moduleRoot: opts.sourceRoot

View File

@@ -61,7 +61,7 @@ Buffer.prototype.space = function () {
Buffer.prototype.removeLast = function (cha) {
if (!this.isLast(cha)) return;
this.buf = this.buf.slice(0, -1);
this.buf = this.buf.substr(0, this.buf.length - 1);
this.position.unshift(cha);
};
@@ -77,10 +77,9 @@ Buffer.prototype.newline = function (i, removeLast) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
var self = this;
_.times(i, function () {
self.newline(null, removeLast);
});
for (var j = 0; j < i; j++) {
this.newline(null, removeLast);
}
return;
}
@@ -115,13 +114,18 @@ Buffer.prototype._push = function (str) {
};
Buffer.prototype.endsWith = function (str) {
return this.buf.slice(-str.length) === str;
var d = this.buf.length - str.length;
return d >= 0 && this.buf.lastIndexOf(str) === d;
};
Buffer.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
var last = buf[buf.length - 1];
var chars = [].concat(cha);
return _.contains(chars, _.last(buf));
if (Array.isArray(cha)) {
return _.contains(cha, last);
} else {
return cha === last;
}
};

View File

@@ -125,7 +125,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
var lines = 0;
if (node.start != null) {
if (node.start != null && !node._ignoreUserWhitespace) {
// user node
if (leading) {
lines = self.whitespace.getNewlinesBefore(node);

View File

@@ -107,7 +107,16 @@ exports.TryStatement = function (node, print) {
this.keyword("try");
print(node.block);
this.space();
print(node.handler);
// Esprima bug puts the catch clause in a `handlers` array.
// see https://code.google.com/p/esprima/issues/detail?id=433
// We run into this from regenerator generated ast.
if (node.handlers) {
print(node.handlers[0]);
} else {
print(node.handler);
}
if (node.finalizer) {
this.space();
this.push("finally ");

View File

@@ -6,14 +6,19 @@ var t = require("../../types");
var _ = require("lodash");
var find = function (obj, node, parent) {
if (!obj) return;
var result;
_.each(obj, function (fn, type) {
var types = Object.keys(obj);
for (var i = 0; i < types.length; i++) {
var type = types[i];
if (t["is" + type](node)) {
var fn = obj[type];
result = fn(node, parent);
if (result != null) return false;
if (result != null) break;
}
});
}
return result;
};
@@ -99,7 +104,13 @@ _.each(Node.prototype, function (fn, key) {
Node[key] = function (node, parent) {
var n = new Node(node, parent);
var args = _.toArray(arguments).slice(2);
// Avoid leaking arguments to prevent deoptimization
var skipCount = 2;
var args = new Array(arguments.length - skipCount);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i + 2];
}
return n[key].apply(n, args);
};
});

View File

@@ -21,6 +21,13 @@ _.each([
});
});
exports.UpdateExpression = function (node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
// (foo++).test()
return true;
}
};
exports.ObjectExpression = function (node, parent) {
if (t.isExpressionStatement(parent)) {
// ({ foo: "bar" });

View File

@@ -62,11 +62,15 @@ _.each({
CallExpression: { after: 1 },
Literal: { after: 1 }
}, function (amounts, type) {
if (_.isNumber(amounts)) amounts = { after: amounts, before: amounts };
if (_.isNumber(amounts)) {
amounts = { after: amounts, before: amounts };
}
_.each(amounts, function (amount, key) {
exports[key].nodes[type] = function () {
return amount;
};
_.each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
_.each(amounts, function (amount, key) {
exports[key].nodes[type] = function () {
return amount;
};
});
});
});

View File

@@ -1,33 +1,27 @@
module.exports = Position;
var _ = require("lodash");
function Position() {
this.line = 1;
this.column = 0;
}
Position.prototype.push = function (str) {
var self = this;
_.each(str, function (cha) {
if (cha === "\n") {
self.line++;
self.column = 0;
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
self.column++;
this.column++;
}
});
}
};
Position.prototype.unshift = function (str) {
var self = this;
_.each(str, function (cha) {
if (cha === "\n") {
self.line--;
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
self.column--;
this.column--;
}
});
}
};

View File

@@ -11,15 +11,18 @@ Whitespace.prototype.getNewlinesBefore = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var i = 0; i < tokens.length; i++) {
token = tokens[i];
_.each(tokens, function (token, i) {
// this is the token this node starts with
if (node.start === token.start) {
startToken = tokens[i - 1];
endToken = token;
return false;
break;
}
});
}
return this.getNewlinesBetween(startToken, endToken);
};
@@ -28,15 +31,18 @@ Whitespace.prototype.getNewlinesAfter = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var i = 0; i < tokens.length; i++) {
token = tokens[i];
_.each(tokens, function (token, i) {
// this is the token this node ends with
if (node.end === token.end) {
startToken = token;
endToken = tokens[i + 1];
return false;
break;
}
});
}
if (endToken.type.type === "eof") {
return 1;

View File

@@ -20,7 +20,7 @@ module.exports = function (namespace) {
_.each(File.helpers, function (name) {
if (_.contains(File.excludeHelpersFromRuntime, name)) {
return false;
return;
}
var key = t.identifier(t.toIdentifier(name));

View File

@@ -156,8 +156,10 @@ DefaultFormatter.prototype.getModuleName = function () {
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
}
// remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
if (!opts.keepModuleIdExtensions) {
// remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
}
moduleName += filenameRelative;
@@ -217,7 +219,8 @@ DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node,
};
DefaultFormatter.prototype._exportsWildcard = function (objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("exports-wildcard"), [
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [
t.identifier("exports"),
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
};

View File

@@ -31,15 +31,17 @@ UMDFormatter.prototype.transform = function (ast) {
var factory = t.functionExpression(null, args, t.blockStatement(body));
// runner
// amd
var defineArgs = [t.literal("exports")];
if (this.passModuleArg) defineArgs.push(t.literal("module"));
defineArgs = defineArgs.concat(names);
defineArgs = [t.arrayExpression(defineArgs)];
// common
var testExports = util.template("test-exports");
var testModule = util.template("test-module");
var testModule = util.template("test-module");
var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
var commonArgs = [t.identifier("exports")];
@@ -48,6 +50,12 @@ UMDFormatter.prototype.transform = function (ast) {
return t.callExpression(t.identifier("require"), [name]);
}));
// globals
//var umdArgs = [];
//
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));

View File

@@ -0,0 +1,5 @@
(function () {
if (SUPER_NAME != null) {
SUPER_NAME.apply(this, arguments);
}
});

View File

@@ -1,3 +1,3 @@
if (SUPER_NAME !== null) {
SUPER_NAME.apply(this, arguments);
if (Object.getPrototypeOf(CLASS_NAME) !== null) {
Object.getPrototypeOf(CLASS_NAME).apply(this, arguments);
}

View File

@@ -1,7 +0,0 @@
(function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
}
}
})

View File

@@ -0,0 +1,13 @@
for (var LOOP_OBJECT = OBJECT,
IS_ARRAY = Array.isArray(LOOP_OBJECT),
INDEX = 0,
LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) {
if (IS_ARRAY) {
if (INDEX >= LOOP_OBJECT.length) break;
ID = LOOP_OBJECT[INDEX++];
} else {
INDEX = LOOP_OBJECT.next();
if (INDEX.done) break;
ID = INDEX.value;
}
}

View File

@@ -0,0 +1,23 @@
(function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
});

View File

@@ -1,14 +1,14 @@
(function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
(function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
child.prototype = Object.create(parent && parent.prototype, {
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
})

View File

@@ -1,5 +0,0 @@
(function (KEY) {
CONTENT;
return KEY;
})(OBJECT);

View File

@@ -1 +0,0 @@
Object.defineProperties(OBJECT, PROPS);

View File

@@ -43,6 +43,7 @@ transform.moduleFormatters = {
_.each({
specNoForInOfAssignment: require("./transformers/spec-no-for-in-of-assignment"),
specSetters: require("./transformers/spec-setters"),
// playground
methodBinding: require("./transformers/playground-method-binding"),
@@ -58,17 +59,18 @@ _.each({
arrayComprehension: require("./transformers/es7-array-comprehension"),
generatorComprehension: require("./transformers/es7-generator-comprehension"),
arrowFunctions: require("./transformers/es6-arrow-functions"),
classesFastSuper: require("./transformers/optional-classes-fast-super"),
classes: require("./transformers/es6-classes"),
computedPropertyNames: require("./transformers/es6-computed-property-names"),
objectSpread: require("./transformers/es7-object-spread"),
exponentiationOperator: require("./transformers/es7-exponentiation-operator"),
spread: require("./transformers/es6-spread"),
templateLiterals: require("./transformers/es6-template-literals"),
propertyMethodAssignment: require("./transformers/es6-property-method-assignment"),
computedPropertyNames: require("./transformers/es6-computed-property-names"),
destructuring: require("./transformers/es6-destructuring"),
defaultParameters: require("./transformers/es6-default-parameters"),
forOfFast: require("./transformers/optional-for-of-fast"),
forOf: require("./transformers/es6-for-of"),
unicodeRegex: require("./transformers/es6-unicode-regex"),
abstractReferences: require("./transformers/es7-abstract-references"),

View File

@@ -3,36 +3,11 @@ var util = require("../../util");
var t = require("../../types");
exports.ClassDeclaration = function (node, parent, file, scope) {
var closure = true;
if (t.isProgram(parent) || t.isBlockStatement(parent)) {
closure = false;
}
var factory = new Class(node, file, scope, closure);
var newNode = factory.run();
if (factory.closure) {
if (closure) {
// declaration in an expression context...
// export default class Foo {}
scope.push({
kind: "var",
key: node.id.key,
id: node.id
});
return t.assignmentExpression("=", node.id, newNode);
} else {
// has a super class or PrivateDeclaration etc
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, newNode)
]);
}
} else {
return newNode;
}
return new Class(node, file, scope, true).run();
};
exports.ClassExpression = function (node, parent, file, scope) {
return new Class(node, file, scope, true).run();
return new Class(node, file, scope, false).run();
};
/**
@@ -44,11 +19,11 @@ exports.ClassExpression = function (node, parent, file, scope) {
* @param {Boolean} closure
*/
function Class(node, file, scope, closure) {
this.closure = closure;
this.scope = scope;
this.node = node;
this.file = file;
function Class(node, file, scope, isStatement) {
this.isStatement = isStatement;
this.scope = scope;
this.node = node;
this.file = file;
this.hasInstanceMutators = false;
this.hasStaticMutators = false;
@@ -75,25 +50,32 @@ Class.prototype.run = function () {
var body = this.body = [];
var constructor = t.functionExpression(null, [], t.blockStatement([]));
if (this.node.id) constructor.id = className;
var constructor;
if (this.node.id) {
constructor = t.functionDeclaration(className, [], t.blockStatement([]));
body.push(constructor);
} else {
constructor = t.functionExpression(null, [], t.blockStatement([]));
body.push(t.variableDeclaration("var", [
t.variableDeclarator(className, constructor)
]));
}
this.constructor = constructor;
body.push(t.variableDeclaration("let", [
t.variableDeclarator(className, constructor)
]));
var closureParams = [];
var closureArgs = [];
//
if (superName) {
this.closure = true;
closureArgs.push(superName);
// so we're only evaluating it once
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(superRef, superName)
]));
superName = superRef;
if (!t.isIdentifier(superName)) {
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
superName = superRef;
}
closureParams.push(superName);
this.superName = superName;
body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [className, superName])));
@@ -103,19 +85,25 @@ Class.prototype.run = function () {
t.inheritsComments(body[0], this.node);
if (this.closure) {
if (body.length === 1) {
// only a constructor so no need for a closure container
return constructor;
} else {
body.push(t.returnStatement(className));
return t.callExpression(
t.functionExpression(null, [], t.blockStatement(body)),
[]
);
}
var init;
if (body.length === 1) {
// only a constructor so no need for a closure container
init = t.toExpression(constructor);
} else {
return body;
body.push(t.returnStatement(className));
init = t.callExpression(
t.functionExpression(null, closureParams, t.blockStatement(body)),
closureArgs
);
}
if (this.isStatement) {
return t.variableDeclaration("let", [
t.variableDeclarator(className, init)
]);
} else {
return init;
}
};
@@ -149,7 +137,7 @@ Class.prototype.buildBody = function () {
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
constructor.body.body.push(util.template("class-super-constructor-call", {
SUPER_NAME: superName
CLASS_NAME: className
}, true));
}
@@ -157,15 +145,11 @@ Class.prototype.buildBody = function () {
var staticProps;
if (this.hasInstanceMutators) {
var protoId = util.template("prototype-identifier", {
CLASS_NAME: className
});
instanceProps = util.buildDefineProperties(this.instanceMutatorMap, protoId);
instanceProps = util.buildDefineProperties(this.instanceMutatorMap);
}
if (this.hasStaticMutators) {
staticProps = util.buildDefineProperties(this.staticMutatorMap, className);
staticProps = util.buildDefineProperties(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
@@ -190,70 +174,49 @@ Class.prototype.pushMethod = function (node) {
var methodName = node.key;
var kind = node.kind;
var mutatorMap = this.instanceMutatorMap;
if (node.static) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
if (kind === "") {
// method
var className = this.className;
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
methodName = t.memberExpression(className, methodName, node.computed);
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
t.inheritsComments(expr, node);
this.body.push(expr);
} else {
// mutator
var mutatorMap = this.instanceMutatorMap;
if (node.static) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
util.pushMutatorMap(mutatorMap, methodName, kind, node);
kind = "value";
}
util.pushMutatorMap(mutatorMap, methodName, kind, node.computed, node);
};
/**
* Given a `methodNode`, produce a `MemberExpression` super class reference.
* Gets a node representing the super class value of the named property.
*
* @param {Node} methodNode MethodDefinition
* @param {Node} node Identifier
* @param {Node} parent
* @example
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {boolean} isStatic
* @param {boolean} isComputed
*
* @returns {Node}
*/
Class.prototype.superIdentifier = function (methodNode, id, parent) {
var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superName, t.identifier("call"));
} else {
id = superName;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superName, t.identifier("prototype"));
} else {
return superName;
}
Class.prototype.superProperty = function (property, isStatic, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("get"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
thisExpression
]
);
};
/**
@@ -264,23 +227,87 @@ Class.prototype.superIdentifier = function (methodNode, id, parent) {
Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
var method = methodNode.value;
var self = this;
var self = this;
traverse(method, {
enter: function (node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
return self.superIdentifier(methodNode, node, parent);
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
var topLevelThisReference;
// super.test(); -> ClassName.prototype.MethodName.call(this);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(t.thisExpression());
traverse2(method, true);
if (topLevelThisReference) {
method.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(topLevelThisReference, t.thisExpression())
]));
}
function traverse2(node, topLevel) {
traverse(node, {
enter: function (node, parent) {
if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
traverse2(node, false);
return this.skip();
}
var property;
var computed;
var args;
if (t.isIdentifier(node, { name: "super" })) {
if (!(t.isMemberExpression(parent) && !parent.computed && parent.property === node)) {
throw self.file.errorWithNode(node, "illegal use of bare super");
}
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (t.isIdentifier(callee, { name: "super" })) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
} else {
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// super.test(); -> _get(Object.getPrototypeOf(ClassName.prototype), "test", this).call(this);
property = callee.property;
computed = callee.computed;
args = node.arguments;
}
} else if (t.isMemberExpression(node)) {
if (!t.isIdentifier(node.object, { name: "super" })) return;
// super.name; -> _get(Object.getPrototypeOf(ClassName.prototype), "name", this);
property = node.property;
computed = node.computed;
}
if (property) {
var thisReference;
if (topLevel) {
thisReference = t.thisExpression();
} else {
topLevelThisReference = thisReference = topLevelThisReference || self.file.generateUidIdentifier("this");
}
var superProperty = self.superProperty(property, methodNode.static, computed, thisReference);
if (args) {
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
return t.callExpression(
t.memberExpression(superProperty, t.identifier("apply"), false),
[thisReference, args[0].argument]
);
} else {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call"), false),
[thisReference].concat(args)
);
}
} else {
return superProperty;
}
}
}
}
});
});
}
};
/**
@@ -290,7 +317,7 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
*/
Class.prototype.pushConstructor = function (method) {
if (method.kind !== "") {
if (method.kind) {
throw this.file.errorWithNode(method, "illegal kind for constructor method");
}
@@ -302,8 +329,9 @@ Class.prototype.pushConstructor = function (method) {
t.inherits(construct, fn);
t.inheritsComments(construct, method);
construct.defaults = fn.defaults;
construct.params = fn.params;
construct.body = fn.body;
construct.rest = fn.rest;
construct._ignoreUserWhitespace = true;
construct.defaults = fn.defaults;
construct.params = fn.params;
construct.body = fn.body;
construct.rest = fn.rest;
};

View File

@@ -7,7 +7,7 @@ exports.ObjectExpression = function (node, parent, file, scope) {
var i;
for (i in node.properties) {
hasComputed = t.isProperty(node.properties[i], { computed: true });
hasComputed = t.isProperty(node.properties[i], { computed: true, kind: "init" });
if (hasComputed) break;
}
@@ -25,6 +25,8 @@ exports.ObjectExpression = function (node, parent, file, scope) {
for (i in props) {
prop = props[i];
if (prop.kind !== "init") continue;
key = prop.key;
if (!prop.computed && t.isIdentifier(key)) {
@@ -44,7 +46,7 @@ exports.ObjectExpression = function (node, parent, file, scope) {
broken = true;
}
if (!broken || t.isLiteral(t.toComputedKey(prop, prop.key), { value: "__proto__" })) {
if (prop.kind !== "init" || !broken || t.isLiteral(t.toComputedKey(prop, prop.key), { value: "__proto__" })) {
initProps.push(prop);
props[i] = null;
}

View File

@@ -31,7 +31,7 @@ exports.Function = function (node, parent, file, scope) {
throw file.errorWithNode(node, "Temporal dead zone - accessing a variable before it's initialized");
}
if (scope.has(node.name)) {
if (scope.has(node.name, true)) {
iife = true;
}
};

View File

@@ -134,7 +134,7 @@ var pushPattern = function (opts) {
var file = opts.file;
var scope = opts.scope;
if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
if (!t.isArrayExpression(parentId) && !t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
var key = scope.generateUidBasedOnNode(parentId, file);
nodes.push(t.variableDeclaration("var", [

View File

@@ -8,7 +8,7 @@ exports.ForOfStatement = function (node, parent, file, scope) {
var stepKey = file.generateUidIdentifier("step", scope);
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left)) {
if (t.isIdentifier(left) || t.isPattern(left)) {
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
declar = t.variableDeclaration(left.kind, [

View File

@@ -1,3 +1,9 @@
var regenerator = require("regenerator");
exports.ast = {
before: require("regenerator").transform
before: function (ast, file) {
regenerator.transform(ast, {
includeRuntime: file.opts.includeRegenerator && "if used"
});
}
};

View File

@@ -46,14 +46,14 @@ exports.Property = function (node, parent, file, scope) {
}
};
exports.ObjectExpression = function (node, parent, file, scope) {
exports.ObjectExpression = function (node) {
var mutatorMap = {};
var hasAny = false;
node.properties = node.properties.filter(function (prop) {
if (prop.kind === "get" || prop.kind === "set") {
hasAny = true;
util.pushMutatorMap(mutatorMap, prop.key, prop.kind, prop.value);
util.pushMutatorMap(mutatorMap, prop.key, prop.kind, prop.computed, prop.value);
return false;
} else {
return true;
@@ -62,21 +62,8 @@ exports.ObjectExpression = function (node, parent, file, scope) {
if (!hasAny) return;
if (node.properties.length) {
var objId = scope.generateUidBasedOnNode(parent, file);
return util.template("object-define-properties-closure", {
KEY: objId,
OBJECT: node,
CONTENT: util.template("object-define-properties", {
OBJECT: objId,
PROPS: util.buildDefineProperties(mutatorMap)
})
});
} else {
return util.template("object-define-properties", {
OBJECT: node,
PROPS: util.buildDefineProperties(mutatorMap)
});
}
return t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
[node, util.buildDefineProperties(mutatorMap)]
);
};

View File

@@ -0,0 +1,74 @@
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
exports.optional = true;
exports.Class = function (node) {
var superClass = node.superClass || t.identifier("Function");
var hasConstructor = false;
var body = node.body.body;
for (var i in body) {
var methodNode = body[i];
hasConstructor = hasConstructor || methodNode.key.name === "constructor";
traverse(methodNode, {
enter: function (node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
return superIdentifier(superClass, methodNode, node, parent);
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// super.test(); -> ClassName.prototype.MethodName.call(this);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(t.thisExpression());
}
}
});
}
if (node.superClass && !hasConstructor) {
body.unshift(t.methodDefinition(
t.identifier("constructor"),
util.template("class-super-constructor-call-fast", {
SUPER_NAME: superClass
})
));
}
};
var superIdentifier = function (superClass, methodNode, id, parent) {
var methodName = methodNode.key;
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superClass, t.identifier("call"));
} else {
id = superClass;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superClass, t.identifier("prototype"));
} else {
return superClass;
}
};

View File

@@ -8,6 +8,15 @@ var coreHas = function (node) {
return node.name !== "_" && _.has(core, node.name);
};
var ALIASABLE_CONSTRUCTORS = [
"Symbol",
"Promise",
"Map",
"WeakMap",
"Set",
"WeakSet"
];
exports.optional = true;
exports.ast = {
@@ -31,8 +40,8 @@ exports.ast = {
this.skip();
return t.prependToMemberExpression(node, file._coreId);
}
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && coreHas(node)) {
// new Promise -> new _core.Promise
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && _.contains(ALIASABLE_CONSTRUCTORS, node.name)) {
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
return t.memberExpression(file._coreId, node);
} else if (t.isCallExpression(node)) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)

View File

@@ -0,0 +1,37 @@
var util = require("../../util");
var t = require("../../types");
exports.optional = true;
exports.ForOfStatement = function (node, parent, file, scope) {
var left = node.left;
var declar, id;
if (t.isIdentifier(left) || t.isPattern(left)) {
id = left;
} else if (t.isVariableDeclaration(left)) {
id = left.declarations[0].id;
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(id)
]);
} else {
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var node2 = util.template("for-of-fast", {
LOOP_OBJECT: file.generateUidIdentifier("loopObject", scope),
IS_ARRAY: file.generateUidIdentifier("isArray", scope),
OBJECT: node.right,
INDEX: file.generateUidIdentifier("i", scope),
ID: id
});
t.inheritsComments(node2, node);
t.ensureBlock(node);
var block = node2.body;
if (declar) block.body.unshift(declar);
block.body = block.body.concat(node.body.body);
return node2;
};

View File

@@ -61,11 +61,16 @@ exports.XJSOpeningElement = {
}
}
var props = node.attributes;
if (props.length) {
var attribs = node.attributes;
if (attribs.length) {
var _props = [];
var objs = [];
// so basically in order to support spread elements we
// loop over all the attributes, breaking on spreads
// we then push a new object containing all prior attributes
// to an array for later processing
var pushProps = function () {
if (!_props.length) return;
@@ -73,8 +78,8 @@ exports.XJSOpeningElement = {
_props = [];
};
while (props.length) {
var prop = props.shift();
while (attribs.length) {
var prop = attribs.shift();
if (t.isXJSSpreadAttribute(prop)) {
pushProps();
objs.push(prop.argument);
@@ -86,22 +91,25 @@ exports.XJSOpeningElement = {
pushProps();
if (objs.length === 1) {
props = objs[0];
// only one object
attribs = objs[0];
} else {
// looks like we have multiple objects
if (!t.isObjectExpression(objs[0])) {
objs.unshift(t.objectExpression([]));
}
props = t.callExpression(
// spread it
attribs = t.callExpression(
t.memberExpression(t.identifier("React"), t.identifier("__spread")),
objs
);
}
} else {
props = t.literal(null);
attribs = t.literal(null);
}
args.push(props);
args.push(attribs);
if (reactCompat) {
if (tagName && isTag(tagName)) {

View File

@@ -0,0 +1,6 @@
exports.MethodDefinition =
exports.Property = function (node, parent, file) {
if (node.kind === "set" && node.value.params.length !== 1) {
throw file.errorWithNode(node.value, "Setters must have only one parameter");
}
};

View File

@@ -4,15 +4,101 @@ var Scope = require("./scope");
var t = require("../types");
var _ = require("lodash");
function TraversalContext(previousContext) {
this.didSkip = false;
this.didRemove = false;
this.didStop = false;
this.didFlatten = previousContext ? previousContext.didFlatten : false;
}
TraversalContext.prototype.flatten = function () {
this.didFlatten = true;
};
TraversalContext.prototype.remove = function () {
this.didRemove = true;
this.skip();
};
TraversalContext.prototype.skip = function () {
this.didSkip = true;
};
TraversalContext.prototype.stop = function () {
this.didStop = true;
this.skip();
};
TraversalContext.prototype.maybeReplace = function (result, obj, key, node) {
if (result === false) return node;
if (result == null) return node;
var isArray = Array.isArray(result);
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
if (isArray) {
this.flatten();
}
return node;
};
TraversalContext.prototype.visit = function (obj, key, opts, scope, parent) {
var node = obj[key];
if (!node) return;
// type is blacklisted
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1) return;
var result;
var ourScope = scope;
if (t.isScope(node)) ourScope = new Scope(node, scope);
// enter
if (opts.enter) {
result = opts.enter.call(this, node, parent, ourScope);
node = this.maybeReplace(result, obj, key, node);
if (this.didRemove) {
obj[key] = null;
this.flatten();
}
// stop traversal
if (this.didSkip) return;
}
// traverse node
traverse(node, opts, ourScope);
// exit
if (opts.exit) {
result = opts.exit.call(this, node, parent, ourScope);
node = this.maybeReplace(result, obj, key, node);
}
};
function traverse(parent, opts, scope) {
// falsy node
if (!parent) return;
// array of nodes
if (_.isArray(parent)) {
_.each(parent, function (node) {
traverse(node, opts, scope);
});
if (Array.isArray(parent)) {
for (var i = 0; i < parent.length; i++)
traverse(parent[i], opts, scope);
return;
}
@@ -21,99 +107,21 @@ function traverse(parent, opts, scope) {
if (!keys) return;
opts = opts || {};
var context = null;
var stopped = false;
for (var i in keys) {
var key = keys[i];
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var nodes = parent[key];
if (!nodes) continue;
var flatten = false;
var handle = function (obj, key) {
var node = obj[key];
if (!node) return;
// type is blacklisted
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1) return;
// replace node
var maybeReplace = function (result) {
if (result === false) return;
if (result == null) return;
var isArray = _.isArray(result);
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;
if (isArray) flatten = true;
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
};
var skipped = false;
var removed = false;
var context = {
stop: function () {
skipped = stopped = true;
},
skip: function () {
skipped = true;
},
remove: function () {
this.skip();
removed = true;
}
};
//
var ourScope = scope;
if (t.isScope(node)) ourScope = new Scope(node, scope);
// enter
if (opts.enter) {
var result = opts.enter.call(context, node, parent, ourScope);
maybeReplace(result);
if (removed) {
obj[key] = null;
flatten = true;
}
// stop iteration
if (skipped) return;
if (Array.isArray(nodes)) {
for (var k = 0; k < nodes.length; k++) {
context = new TraversalContext(context);
context.visit(nodes, k, opts, scope, parent);
if (context.didStop) return;
}
// traverse node
traverse(node, opts, ourScope);
// exit
if (opts.exit) {
maybeReplace(opts.exit.call(context, node, parent, ourScope));
}
};
if (_.isArray(nodes)) {
for (i in nodes) {
handle(nodes, i);
if (stopped) return;
}
if (flatten) {
if (context && context.didFlatten) {
parent[key] = _.flatten(parent[key]);
if (key === "body") {
@@ -122,8 +130,9 @@ function traverse(parent, opts, scope) {
}
}
} else {
handle(parent, key);
if (stopped) return;
context = new TraversalContext(context);
context.visit(parent, key, opts, scope, parent);
if (context.didStop) return;
}
}
}

View File

@@ -24,7 +24,13 @@ function Scope(block, parent) {
}
var vars = require("jshint/src/vars");
Scope.defaultDeclarations = _.flatten([vars.newEcmaIdentifiers, vars.node, vars.ecmaIdentifiers, vars.reservedVars].map(_.keys));
Scope.defaultDeclarations = _.flatten([
vars.newEcmaIdentifiers,
vars.node,
vars.ecmaIdentifiers,
vars.reservedVars
].map(_.keys));
Scope.add = function (node, references) {
if (!node) return;

View File

@@ -9,6 +9,7 @@
"ExpressionStatement": ["expression"],
"File": ["program", "comments", "tokens"],
"FunctionExpression": ["id", "params", "body", "generator"],
"FunctionDeclaration": ["id", "params", "body", "generator"],
"Identifier": ["name"],
"IfStatement": ["test", "consequent", "alternate"],
"ImportDeclaration": ["specifiers", "source"],
@@ -16,6 +17,7 @@
"Literal": ["value"],
"LogicalExpression": ["operator", "left", "right"],
"MemberExpression": ["object", "property", "computed"],
"MethodDefinition": ["key", "value", "computed", "kind"],
"NewExpression": ["callee", "arguments"],
"ObjectExpression": ["properties"],
"Program": ["body"],

View File

@@ -307,6 +307,31 @@ t.toStatement = function (node, ignore) {
return node;
};
/**
* Description
*
* @param {Object} node
* @returns {Object}
*/
exports.toExpression = function (node) {
if (t.isExpressionStatement(node)) {
node = node.expression;
}
if (t.isClass(node)) {
node.type = "ClassExpression";
} else if (t.isFunction(node)) {
node.type = "FunctionExpression";
}
if (t.isExpression(node)) {
return node;
} else {
throw new Error("cannot turn " + node.type + " to an expression");
}
};
/**
* Description
*
@@ -320,7 +345,11 @@ t.toBlock = function (node, parent) {
return node;
}
if (!_.isArray(node)) {
if (t.isEmptyStatement(node)) {
node = [];
}
if (!Array.isArray(node)) {
if (!t.isStatement(node)) {
if (t.isFunction(parent)) {
node = t.returnStatement(node);

View File

@@ -39,7 +39,7 @@ exports.list = function (val) {
exports.regexify = function (val) {
if (!val) return new RegExp(/.^/);
if (_.isArray(val)) val = val.join("|");
if (Array.isArray(val)) val = val.join("|");
if (_.isString(val)) return new RegExp(val);
if (_.isRegExp(val)) return val;
throw new TypeError("illegal type for regexify");
@@ -48,7 +48,7 @@ exports.regexify = function (val) {
exports.arrayify = function (val) {
if (!val) return [];
if (_.isString(val)) return exports.list(val);
if (_.isArray(val)) return val;
if (Array.isArray(val)) return val;
throw new TypeError("illegal type for arrayify");
};
@@ -65,12 +65,12 @@ exports.sourceMapToComment = function (map) {
return "//# sourceMappingURL=data:application/json;base64," + base64;
};
exports.pushMutatorMap = function (mutatorMap, key, kind, method) {
exports.pushMutatorMap = function (mutatorMap, key, kind, computed, method) {
var alias;
if (t.isIdentifier(key)) {
alias = key.name;
if (method.computed) alias = "computed:" + alias;
if (computed) alias = "computed:" + alias;
} else if (t.isLiteral(key)) {
alias = String(key.value);
} else {
@@ -86,7 +86,7 @@ exports.pushMutatorMap = function (mutatorMap, key, kind, method) {
mutatorMap[alias] = map;
map._key = key;
if (method.computed) {
if (computed) {
map._computed = true;
}
@@ -101,7 +101,12 @@ exports.buildDefineProperties = function (mutatorMap) {
var propNode = t.property("init", map._key, mapNode, map._computed);
if (!map.get && !map.set) {
map.writable = t.literal(true);
}
map.enumerable = t.literal(true);
map.configurable = t.literal(true);
_.each(map, function (node, key) {
if (key[0] === "_") return;
@@ -188,7 +193,13 @@ exports.codeFrame = function (lines, lineNumber, colNumber) {
exports.repeat = function (width, cha) {
cha = cha || " ";
return new Array(width + 1).join(cha);
var result = "";
for (var i = 0; i < width; i++) {
result += cha;
}
return result;
};
exports.normaliseAst = function (ast, comments, tokens) {
@@ -256,7 +267,7 @@ var loadTemplates = function () {
if (!fs.existsSync(templatesLoc)) {
throw new Error("no templates directory - this is most likely the " +
"result of a broken `npm publish`. Please report to " +
"https://githut.com/6to5/6to5/issues");
"https://github.com/6to5/6to5/issues");
}
_.each(fs.readdirSync(templatesLoc), function (name) {

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.8.0",
"version": "2.11.4",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -39,36 +39,36 @@
"test": "make test"
},
"dependencies": {
"acorn-6to5": "0.11.1-11",
"acorn-6to5": "0.11.1-13",
"ast-types": "~0.6.1",
"chokidar": "0.11.1",
"commander": "2.5.0",
"core-js": "^0.4.1",
"core-js": "0.4.4",
"estraverse": "1.8.0",
"esutils": "1.1.6",
"esvalid": "^1.1.0",
"esvalid": "1.1.0",
"fs-readdir-recursive": "0.1.0",
"jshint": "^2.5.10",
"jshint": "2.5.10",
"lodash": "2.4.1",
"mkdirp": "0.5.0",
"private": "0.1.6",
"regenerator": "^0.8.3",
"regenerator": "0.8.3",
"regexpu": "0.3.0",
"roadrunner": "^1.0.4",
"roadrunner": "1.0.4",
"source-map": "0.1.40",
"source-map-support": "0.2.8"
},
"devDependencies": {
"browserify": "6.3.2",
"chai": "^1.9.2",
"chai": "1.9.2",
"istanbul": "0.3.2",
"jshint-stylish": "^1.0.0",
"jshint-stylish": "1.0.0",
"matcha": "0.6.0",
"mocha": "1.21.4",
"rimraf": "2.2.8",
"uglify-js": "2.4.15"
},
"optionalDependencies": {
"kexec": "^0.2.0"
"kexec": "0.2.0"
}
}

View File

@@ -12,7 +12,7 @@ suite("browserify", function() {
assert.ok(bundle.length, "bundle output code");
// ensure that the code runs without throwing an exception
vm.runInNewContext(bundle, {});
vm.runInNewContext("var global = this;\n" + bundle, {});
done();
})
})

View File

@@ -1,5 +1,3 @@
if (!process.env.ALL_6TO5_TESTS) return;
require("./_transformation-helper")({
name: "esnext"
});

View File

@@ -1,9 +1,11 @@
class Animal {
class Base {
get sound() {
return 'I am a ' + this.type + '.';
}
}
class Animal extends Base {}
class Cat extends Animal {
get type() { return 'cat'; }

View File

@@ -1,2 +1,3 @@
++i;
i++;
(foo++).test();

View File

@@ -1,2 +1,3 @@
++i;
i++;
(foo++).test();

View File

@@ -3,7 +3,6 @@ class Test extends Foo {
woops.super.test();
super();
super.test();
foob(super);
super(...arguments);
super("test", ...arguments);

View File

@@ -1,52 +1,89 @@
"use strict";
var _slice = Array.prototype.slice;
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
child.prototype = Object.create(parent && parent.prototype, {
};
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function () {
var _Foo = Foo;
var Test = function Test() {
var _Foo$prototype$test, _Foo$prototype$test2;
var Test = (function (Foo) {
function Test() {
var _get2, _get3;
woops["super"].test();
_Foo.call(this);
_Foo.prototype.test.call(this);
foob(_Foo);
_get(Object.getPrototypeOf(Test.prototype), "constructor", this).call(this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
_Foo.call.apply(_Foo, [this].concat(_slice.call(arguments)));
_Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments)));
_get(Object.getPrototypeOf(Test.prototype), "constructor", this).apply(this, arguments);
(_get2 = _get(Object.getPrototypeOf(Test.prototype), "constructor", this)).call.apply(_get2, [this, "test"].concat(_slice.call(arguments)));
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
};
_get(Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments);
(_get3 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get3, [this, "test"].concat(_slice.call(arguments)));
}
_inherits(Test, _Foo);
_inherits(Test, Foo);
Test.prototype.test = function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
_Foo.prototype.test.call(this);
(_Foo$prototype$test3 = _Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = _Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
};
Test.foo = function () {
var _Foo$foo, _Foo$foo2;
_Foo.foo.call(this);
(_Foo$foo = _Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = _Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
};
_prototypeProperties(Test, {
foo: {
value: function () {
var _get4;
_get(Object.getPrototypeOf(Test), "foo", this).call(this);
_get(Object.getPrototypeOf(Test), "foo", this).apply(this, arguments);
(_get4 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get4, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _get5;
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments);
(_get5 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get5, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();
})(Foo);

View File

@@ -1,28 +1,49 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
child.prototype = Object.create(parent && parent.prototype, {
};
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function () {
var _Foo = Foo;
var Test = function Test() {
_Foo.prototype.test;
_Foo.prototype.test.whatever;
};
var Test = (function (Foo) {
function Test() {
_get(Object.getPrototypeOf(Test.prototype), "test", this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever;
}
_inherits(Test, _Foo);
_inherits(Test, Foo);
return Test;
})();
})(Foo);

View File

@@ -0,0 +1,5 @@
class Test {
constructor() {
console.log(super);
}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "illegal use of bare super"
}

View File

@@ -1,32 +1,65 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
child.prototype = Object.create(parent && parent.prototype, {
};
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function () {
var _Foo = Foo;
var Test = function Test() {
_Foo.prototype.test.whatever();
_Foo.prototype.test.call(this);
};
var Test = (function (Foo) {
function Test() {
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever();
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
}
_inherits(Test, _Foo);
_inherits(Test, Foo);
Test.test = function () {
return _Foo.wow.call(this);
};
_prototypeProperties(Test, {
test: {
value: function () {
return _get(Object.getPrototypeOf(Test), "wow", this).call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();
})(Foo);

View File

@@ -1,31 +1,30 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
child.prototype = Object.create(parent && parent.prototype, {
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var Test = function Test() {
this.state = "test";
};
var Foo = (function () {
var _Bar = Bar;
var Foo = function Foo() {
var Foo = (function (Bar) {
function Foo() {
this.state = "test";
};
}
_inherits(Foo, _Bar);
_inherits(Foo, Bar);
return Foo;
})();
})(Bar);

View File

@@ -5,16 +5,21 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
function Test() {}
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -5,13 +5,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
function Test() {}
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -1,7 +1,23 @@
"use strict";
var Test = function Test() {};
Test.prototype.test = function () {
return 5 + 5;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = (function () {
function Test() {}
_prototypeProperties(Test, null, {
test: {
value: function () {
return 5 + 5;
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -5,13 +5,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
function Test() {}
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -1,5 +1,10 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var BaseView = function BaseView() {
this.autoRender = true;
};
@@ -11,9 +16,16 @@ var BaseView = function () {
var BaseView = (function () {
var _class2 = function () {};
_class2.prototype.foo = function () {
this.autoRender = true;
};
_prototypeProperties(_class2, null, {
foo: {
value: function () {
this.autoRender = true;
},
writable: true,
enumerable: true,
configurable: true
}
});
return _class2;
})();

View File

@@ -5,14 +5,23 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var A = function A() {};
var A = (function () {
function A() {}
A.a = function () {};
_prototypeProperties(A, {
a: {
value: function () {},
writable: true,
enumerable: true,
configurable: true
},
b: {
get: function () {},
set: function (b) {},
enumerable: true,
configurable: true
}
});
_prototypeProperties(A, {
b: {
get: function () {},
set: function (b) {},
enumerable: true
}
});
return A;
})();

View File

@@ -1,42 +1,40 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
child.prototype = Object.create(parent && parent.prototype, {
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var BaseController = (function () {
var _Chaplin$Controller = Chaplin.Controller;
var BaseController = function BaseController() {
if (_Chaplin$Controller !== null) {
_Chaplin$Controller.apply(this, arguments);
var BaseController = (function (_Chaplin$Controller) {
function BaseController() {
if (Object.getPrototypeOf(BaseController) !== null) {
Object.getPrototypeOf(BaseController).apply(this, arguments);
}
};
}
_inherits(BaseController, _Chaplin$Controller);
return BaseController;
})();
})(Chaplin.Controller);
var BaseController2 = (function () {
var _Chaplin$Controller$Another = Chaplin.Controller.Another;
var BaseController2 = function BaseController2() {
if (_Chaplin$Controller$Another !== null) {
_Chaplin$Controller$Another.apply(this, arguments);
var BaseController2 = (function (_Chaplin$Controller$Another) {
function BaseController2() {
if (Object.getPrototypeOf(BaseController2) !== null) {
Object.getPrototypeOf(BaseController2).apply(this, arguments);
}
};
}
_inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})();
})(Chaplin.Controller.Another);

View File

@@ -1,29 +1,28 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
child.prototype = Object.create(parent && parent.prototype, {
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: child,
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function () {
var _Foo = Foo;
var Test = function Test() {
if (_Foo !== null) {
_Foo.apply(this, arguments);
var Test = (function (Foo) {
function Test() {
if (Object.getPrototypeOf(Test) !== null) {
Object.getPrototypeOf(Test).apply(this, arguments);
}
};
}
_inherits(Test, _Foo);
_inherits(Test, Foo);
return Test;
})();
})(Foo);

View File

@@ -1,5 +1,28 @@
"use strict";
var Test = function Test() {
Function.prototype.hasOwnProperty.call(this, "test");
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var Test = function Test() {
_get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
};

View File

@@ -1,38 +1,18 @@
"use strict";
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = [1, 2];
var _ref2 = _slicedToArray(_ref, 2);
var a = _ref[0];
var b = _ref[1];
var _ref2 = [3, 4];
var a = _ref2[0];
var b = _ref2[1];
var _ref3 = [3, 4];
var c = _ref2[0];
var d = _ref2[1];
var _ref3 = { e: 5, f: 6 };
var _ref3 = _slicedToArray(_ref3, 2);
var e = _ref3.e;
var f = _ref3.f;
var _ref4 = { a: 7, b: 8 };
var c = _ref3[0];
var d = _ref3[1];
var _ref4 = { e: 5, f: 6 };
var e = _ref4.e;
var f = _ref4.f;
var _ref5 = { a: 7, b: 8 };
var g = _ref5.a;
var h = _ref5.b;
var g = _ref4.a;
var h = _ref4.b;

View File

@@ -18,13 +18,11 @@ var _slicedToArray = function (arr, i) {
var _ref = ["hello", [", ", "junk"], ["world"]];
var _ref2 = _slicedToArray(_ref, 4);
var a = _ref[0];
var _ref$1 = _slicedToArray(_ref[1], 1);
var a = _ref2[0];
var _ref2$1 = _slicedToArray(_ref2[1], 1);
var b = _ref$1[0];
var _ref$2 = _slicedToArray(_ref[2], 1);
var b = _ref2$1[0];
var _ref2$2 = _slicedToArray(_ref2[2], 1);
var c = _ref2$2[0];
var d = _ref2[3];
var c = _ref$2[0];
var d = _ref[3];

View File

@@ -18,13 +18,11 @@ var _slicedToArray = function (arr, i) {
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
var _ref2 = _slicedToArray(_ref, 5);
var a = _ref[1];
var _ref$2 = _slicedToArray(_ref[2], 1);
var a = _ref2[1];
var _ref2$2 = _slicedToArray(_ref2[2], 1);
var b = _ref$2[0];
var _ref$3 = _slicedToArray(_ref[3], 1);
var b = _ref2$2[0];
var _ref2$3 = _slicedToArray(_ref2[3], 1);
var c = _ref2$3[0];
var d = _ref2[4];
var c = _ref$3[0];
var d = _ref[4];

View File

@@ -0,0 +1 @@
function *x() {}

View File

@@ -0,0 +1,400 @@
"use strict";
!(function () {
var hasOwn = Object.prototype.hasOwnProperty;
var undefined;
var iteratorSymbol = typeof Symbol === "function" && Symbol.iterator || "@@iterator";
if (typeof regeneratorRuntime === "object") {
return;
}
var runtime = regeneratorRuntime = typeof exports === "undefined" ? {} : exports;
function wrap(innerFn, outerFn, self, tryList) {
return new Generator(innerFn, outerFn, self || null, tryList || []);
}
runtime.wrap = wrap;
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
var ContinueSentinel = {};
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunction.displayName = "GeneratorFunction";
runtime.isGeneratorFunction = function (genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
};
runtime.mark = function (genFun) {
genFun.__proto__ = GeneratorFunctionPrototype;
genFun.prototype = Object.create(Gp);
return genFun;
};
runtime.async = function (innerFn, outerFn, self, tryList) {
return new Promise(function (resolve, reject) {
var generator = wrap(innerFn, outerFn, self, tryList);
var callNext = step.bind(generator.next);
var callThrow = step.bind(generator["throw"]);
function step(arg) {
try {
var info = this(arg);
var value = info.value;
} catch (error) {
return reject(error);
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(callNext, callThrow);
}
}
callNext();
});
};
function Generator(innerFn, outerFn, self, tryList) {
var generator = outerFn ? Object.create(outerFn.prototype) : this;
var context = new Context(tryList);
var state = GenStateSuspendedStart;
function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
return doneResult();
}
while (true) {
var delegate = context.delegate;
if (delegate) {
try {
var info = delegate.iterator[method](arg);
method = "next";
arg = undefined;
} catch (uncaught) {
context.delegate = null;
method = "throw";
arg = uncaught;
continue;
}
if (info.done) {
context[delegate.resultName] = info.value;
context.next = delegate.nextLoc;
} else {
state = GenStateSuspendedYield;
return info;
}
context.delegate = null;
}
if (method === "next") {
if (state === GenStateSuspendedStart && typeof arg !== "undefined") {
throw new TypeError("attempt to send " + JSON.stringify(arg) + " to newborn generator");
}
if (state === GenStateSuspendedYield) {
context.sent = arg;
} else {
delete context.sent;
}
} else if (method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw arg;
}
if (context.dispatchException(arg)) {
method = "next";
arg = undefined;
}
} else if (method === "return") {
context.abrupt("return", arg);
}
state = GenStateExecuting;
try {
var value = innerFn.call(self, context);
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
var info = {
value: value,
done: context.done
};
if (value === ContinueSentinel) {
if (context.delegate && method === "next") {
arg = undefined;
}
} else {
return info;
}
} catch (thrown) {
state = GenStateCompleted;
if (method === "next") {
context.dispatchException(thrown);
} else {
arg = thrown;
}
}
}
}
generator.next = invoke.bind(generator, "next");
generator["throw"] = invoke.bind(generator, "throw");
generator["return"] = invoke.bind(generator, "return");
return generator;
}
Gp[iteratorSymbol] = function () {
return this;
};
Gp.toString = function () {
return "[object Generator]";
};
function pushTryEntry(triple) {
var entry = {
tryLoc: triple[0]
};
if (1 in triple) {
entry.catchLoc = triple[1];
}
if (2 in triple) {
entry.finallyLoc = triple[2];
}
this.tryEntries.push(entry);
}
function resetTryEntry(entry, i) {
var record = entry.completion || {};
record.type = i === 0 ? "normal" : "return";
delete record.arg;
entry.completion = record;
}
function Context(tryList) {
this.tryEntries = [{
tryLoc: "root"
}];
tryList.forEach(pushTryEntry, this);
this.reset();
}
runtime.keys = function (object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}
next.done = true;
return next;
};
};
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}
if (typeof iterable.next === "function") {
return iterable;
}
if (!isNaN(iterable.length)) {
var i = -1;
function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}
next.value = undefined;
next.done = true;
return next;
}
return next.next = next;
}
}
return {
next: doneResult
};
}
runtime.values = values;
function doneResult() {
return {
value: undefined,
done: true
};
}
Context.prototype = {
constructor: Context,
reset: function () {
this.prev = 0;
this.next = 0;
this.sent = undefined;
this.done = false;
this.delegate = null;
this.tryEntries.forEach(resetTryEntry);
for (var tempIndex = 0, tempName; hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20; ++tempIndex) {
this[tempName] = null;
}
},
stop: function () {
this.done = true;
var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}
return this.rval;
},
dispatchException: function (exception) {
if (this.done) {
throw exception;
}
var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;
return !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;
if (entry.tryLoc === "root") {
return handle("end");
}
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}
} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}
} else {
throw new Error("try statement without catch or finally");
}
}
}
},
_findFinallyEntry: function (finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && (entry.finallyLoc === finallyLoc || this.prev < entry.finallyLoc)) {
return entry;
}
}
},
abrupt: function (type, arg) {
var entry = this._findFinallyEntry();
var record = entry ? entry.completion : {};
record.type = type;
record.arg = arg;
if (entry) {
this.next = entry.finallyLoc;
} else {
this.complete(record);
}
return ContinueSentinel;
},
complete: function (record) {
if (record.type === "throw") {
throw record.arg;
}
if (record.type === "break" || record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = record.arg;
this.next = "end";
}
return ContinueSentinel;
},
finish: function (finallyLoc) {
var entry = this._findFinallyEntry(finallyLoc);
return this.complete(entry.completion);
},
"catch": function (tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry, i);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function (iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};
return ContinueSentinel;
}
};
})();
var x = regeneratorRuntime.mark(function x() {
return regeneratorRuntime.wrap(function x$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
case "end":
return context$1$0.stop();
}
}, x, this);
});

View File

@@ -0,0 +1,4 @@
{
"noCheckAst": true,
"includeRegenerator": true
}

View File

@@ -7,15 +7,17 @@ define(["exports", "foo"], function (exports, _foo) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -7,15 +7,17 @@ define(["exports", "foo"], function (exports, _foo) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -6,15 +6,17 @@ var _interopRequireWildcard = function (obj) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(require("foo")));
_defaults(exports, _interopRequireWildcard(require("foo")));
exports.foo = require("foo").foo;
exports.foo = require("foo").foo;

View File

@@ -6,15 +6,17 @@ var _interopRequireWildcard = function (obj) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(require("foo")));
_defaults(exports, _interopRequireWildcard(require("foo")));
exports.foo = require("foo").foo;
exports.foo = require("foo").foo;

View File

@@ -13,15 +13,17 @@
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -13,15 +13,17 @@
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -0,0 +1,8 @@
var x = "y";
var valueSet;
var obj = {
get [x] () { return 1 },
set [x] (value) { valueSet = value }
};
obj.y = "foo";
obj.y === 1 && valueSet === "foo";

View File

@@ -0,0 +1,25 @@
"use strict";
var _defineProperty = function (obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
};
var x = "y";
var valueSet;
var obj = Object.defineProperties({}, _defineProperty({}, x, {
get: function () {
return 1;
},
set: function (value) {
valueSet = value;
},
enumerable: true,
configurable: true
}));
obj.y = "foo";
obj.y === 1 && valueSet === "foo";

View File

@@ -8,6 +8,7 @@ var obj = Object.defineProperties({}, {
set: function (value) {
this._foo = value;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
get: function () {
return 5 + 5;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
set: function (value) {
this._foo = value;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -7,7 +7,7 @@ var D = (function () {
var F = new WeakMap(),
G = new WeakMap();
var E = new WeakMap();
var D = function D() {};
function D() {}
return D;
})();

View File

@@ -0,0 +1,25 @@
class Test extends Foo {
constructor() {
woops.super.test();
super();
super.test();
super(...arguments);
super("test", ...arguments);
super.test(...arguments);
super.test("test", ...arguments);
}
test() {
super();
super(...arguments);
super("test", ...arguments);
}
static foo() {
super();
super(...arguments);
super("test", ...arguments);
}
}

View File

@@ -0,0 +1,67 @@
"use strict";
var _slice = Array.prototype.slice;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function (Foo) {
function Test() {
var _Foo$prototype$test, _Foo$prototype$test2;
woops["super"].test();
Foo.call(this);
Foo.prototype.test.call(this);
Foo.call.apply(Foo, [this].concat(_slice.call(arguments)));
Foo.call.apply(Foo, [this, "test"].concat(_slice.call(arguments)));
(_Foo$prototype$test = Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test2 = Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
}
_inherits(Test, Foo);
_prototypeProperties(Test, {
foo: {
value: function () {
var _Foo$foo, _Foo$foo2;
Foo.foo.call(this);
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
Foo.prototype.test.call(this);
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -0,0 +1,6 @@
class Test extends Foo {
constructor() {
super.test;
super.test.whatever;
}
}

View File

@@ -0,0 +1,27 @@
"use strict";
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function (Foo) {
function Test() {
Foo.prototype.test;
Foo.prototype.test.whatever;
}
_inherits(Test, Foo);
return Test;
})(Foo);

View File

@@ -0,0 +1,10 @@
class Test extends Foo {
constructor() {
super.test.whatever();
super.test();
}
static test() {
return super.wow();
}
}

View File

@@ -0,0 +1,43 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function (Foo) {
function Test() {
Foo.prototype.test.whatever();
Foo.prototype.test.call(this);
}
_inherits(Test, Foo);
_prototypeProperties(Test, {
test: {
value: function () {
return Foo.wow.call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -0,0 +1,3 @@
{
"optional": ["classesFastSuper"]
}

View File

@@ -0,0 +1,7 @@
class BaseController extends Chaplin.Controller {
}
class BaseController2 extends Chaplin.Controller.Another {
}

View File

@@ -0,0 +1,40 @@
"use strict";
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
};
var BaseController = (function (_Chaplin$Controller) {
function BaseController() {
if (Chaplin.Controller != null) {
Chaplin.Controller.apply(this, arguments);
}
}
_inherits(BaseController, _Chaplin$Controller);
return BaseController;
})(Chaplin.Controller);
var BaseController2 = (function (_Chaplin$Controller$Another) {
function BaseController2() {
if (Chaplin.Controller.Another != null) {
Chaplin.Controller.Another.apply(this, arguments);
}
}
_inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})(Chaplin.Controller.Another);

View File

@@ -0,0 +1 @@
class Test extends Foo { }

View File

@@ -0,0 +1,28 @@
"use strict";
var _inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
};
var Test = (function (Foo) {
function Test() {
if (Foo != null) {
Foo.apply(this, arguments);
}
}
_inherits(Test, Foo);
return Test;
})(Foo);

View File

@@ -0,0 +1,5 @@
class Test {
constructor() {
super.hasOwnProperty("test");
}
}

View File

@@ -0,0 +1,5 @@
"use strict";
var Test = function Test() {
Function.prototype.hasOwnProperty.call(this, "test");
};

Some files were not shown because too many files have changed in this diff Show More