jass 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +47 -0
- data/README.md +45 -0
- data/lib/jass.rb +55 -0
- data/lib/jass/base.rb +141 -0
- data/lib/jass/bundle_processor.rb +28 -0
- data/lib/jass/compiler.rb +112 -0
- data/lib/jass/dependency.rb +14 -0
- data/lib/jass/errors.rb +29 -0
- data/lib/jass/es6_processor.rb +17 -0
- data/lib/jass/function.rb +13 -0
- data/lib/jass/global_directive_processor.rb +12 -0
- data/lib/jass/plugin.rb +13 -0
- data/lib/jass/railtie.rb +12 -0
- data/lib/jass/version.rb +3 -0
- data/vendor/node_modules/@types/acorn/index.d.ts +256 -0
- data/vendor/node_modules/@types/acorn/package.json +29 -0
- data/vendor/node_modules/@types/estree/index.d.ts +546 -0
- data/vendor/node_modules/@types/estree/package.json +22 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/index.js +17 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/inject.js +72 -0
- data/vendor/node_modules/acorn-dynamic-import/lib/walk.js +22 -0
- data/vendor/node_modules/acorn-dynamic-import/package.json +45 -0
- data/vendor/node_modules/acorn-dynamic-import/src/index.js +4 -0
- data/vendor/node_modules/acorn-dynamic-import/src/inject.js +52 -0
- data/vendor/node_modules/acorn-dynamic-import/src/walk.js +12 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-es7-plugin.js +17 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-v3.js +333 -0
- data/vendor/node_modules/acorn-es7-plugin/acorn-v4.js +194 -0
- data/vendor/node_modules/acorn-es7-plugin/package.json +29 -0
- data/vendor/node_modules/acorn-jsx/index.js +3 -0
- data/vendor/node_modules/acorn-jsx/inject.js +449 -0
- data/vendor/node_modules/acorn-jsx/package.json +28 -0
- data/vendor/node_modules/acorn-jsx/xhtml.js +255 -0
- data/vendor/node_modules/acorn/bin/_acorn.js +69 -0
- data/vendor/node_modules/acorn/bin/acorn +4 -0
- data/vendor/node_modules/acorn/bin/run_test262.js +22 -0
- data/vendor/node_modules/acorn/bin/test262.whitelist +409 -0
- data/vendor/node_modules/acorn/dist/acorn.es.js +5305 -0
- data/vendor/node_modules/acorn/dist/acorn.js +5336 -0
- data/vendor/node_modules/acorn/dist/acorn_loose.es.js +1412 -0
- data/vendor/node_modules/acorn/dist/acorn_loose.js +1422 -0
- data/vendor/node_modules/acorn/dist/walk.es.js +419 -0
- data/vendor/node_modules/acorn/dist/walk.js +439 -0
- data/vendor/node_modules/acorn/package.json +56 -0
- data/vendor/node_modules/ansi-styles/index.js +165 -0
- data/vendor/node_modules/ansi-styles/package.json +56 -0
- data/vendor/node_modules/arr-diff/index.js +58 -0
- data/vendor/node_modules/arr-diff/package.json +49 -0
- data/vendor/node_modules/arr-flatten/index.js +22 -0
- data/vendor/node_modules/arr-flatten/package.json +76 -0
- data/vendor/node_modules/array-unique/index.js +28 -0
- data/vendor/node_modules/array-unique/package.json +37 -0
- data/vendor/node_modules/braces/index.js +399 -0
- data/vendor/node_modules/braces/package.json +83 -0
- data/vendor/node_modules/buble/bin/buble +24 -0
- data/vendor/node_modules/buble/bin/handleError.js +58 -0
- data/vendor/node_modules/buble/bin/runBuble.js +150 -0
- data/vendor/node_modules/buble/bin/showHelp.js +16 -0
- data/vendor/node_modules/buble/dist/buble-browser-deps.umd.js +14857 -0
- data/vendor/node_modules/buble/dist/buble-browser.cjs.js +9941 -0
- data/vendor/node_modules/buble/dist/buble-browser.es.js +9933 -0
- data/vendor/node_modules/buble/dist/buble.cjs.js +9433 -0
- data/vendor/node_modules/buble/dist/buble.es.js +9425 -0
- data/vendor/node_modules/buble/package.json +74 -0
- data/vendor/node_modules/buble/register.js +90 -0
- data/vendor/node_modules/buble/src/index.js +98 -0
- data/vendor/node_modules/buble/src/program/BlockStatement.js +373 -0
- data/vendor/node_modules/buble/src/program/Node.js +112 -0
- data/vendor/node_modules/buble/src/program/Program.js +74 -0
- data/vendor/node_modules/buble/src/program/Scope.js +116 -0
- data/vendor/node_modules/buble/src/program/extractNames.js +35 -0
- data/vendor/node_modules/buble/src/program/keys.js +4 -0
- data/vendor/node_modules/buble/src/program/types/ArrayExpression.js +70 -0
- data/vendor/node_modules/buble/src/program/types/ArrowFunctionExpression.js +52 -0
- data/vendor/node_modules/buble/src/program/types/AssignmentExpression.js +185 -0
- data/vendor/node_modules/buble/src/program/types/BinaryExpression.js +12 -0
- data/vendor/node_modules/buble/src/program/types/BreakStatement.js +26 -0
- data/vendor/node_modules/buble/src/program/types/CallExpression.js +104 -0
- data/vendor/node_modules/buble/src/program/types/ClassBody.js +237 -0
- data/vendor/node_modules/buble/src/program/types/ClassDeclaration.js +79 -0
- data/vendor/node_modules/buble/src/program/types/ClassExpression.js +51 -0
- data/vendor/node_modules/buble/src/program/types/ContinueStatement.js +17 -0
- data/vendor/node_modules/buble/src/program/types/ExportDefaultDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ExportNamedDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ForInStatement.js +76 -0
- data/vendor/node_modules/buble/src/program/types/ForOfStatement.js +89 -0
- data/vendor/node_modules/buble/src/program/types/ForStatement.js +54 -0
- data/vendor/node_modules/buble/src/program/types/FunctionDeclaration.js +25 -0
- data/vendor/node_modules/buble/src/program/types/FunctionExpression.js +74 -0
- data/vendor/node_modules/buble/src/program/types/Identifier.js +54 -0
- data/vendor/node_modules/buble/src/program/types/IfStatement.js +29 -0
- data/vendor/node_modules/buble/src/program/types/ImportDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/types/ImportDefaultSpecifier.js +8 -0
- data/vendor/node_modules/buble/src/program/types/ImportSpecifier.js +8 -0
- data/vendor/node_modules/buble/src/program/types/JSXAttribute.js +20 -0
- data/vendor/node_modules/buble/src/program/types/JSXClosingElement.js +27 -0
- data/vendor/node_modules/buble/src/program/types/JSXClosingFragment.js +22 -0
- data/vendor/node_modules/buble/src/program/types/JSXElement.js +57 -0
- data/vendor/node_modules/buble/src/program/types/JSXExpressionContainer.js +10 -0
- data/vendor/node_modules/buble/src/program/types/JSXFragment.js +4 -0
- data/vendor/node_modules/buble/src/program/types/JSXOpeningElement.js +93 -0
- data/vendor/node_modules/buble/src/program/types/JSXOpeningFragment.js +7 -0
- data/vendor/node_modules/buble/src/program/types/JSXSpreadAttribute.js +10 -0
- data/vendor/node_modules/buble/src/program/types/Literal.js +43 -0
- data/vendor/node_modules/buble/src/program/types/MemberExpression.js +13 -0
- data/vendor/node_modules/buble/src/program/types/NewExpression.js +55 -0
- data/vendor/node_modules/buble/src/program/types/ObjectExpression.js +250 -0
- data/vendor/node_modules/buble/src/program/types/Property.js +52 -0
- data/vendor/node_modules/buble/src/program/types/ReturnStatement.js +32 -0
- data/vendor/node_modules/buble/src/program/types/SpreadElement.js +12 -0
- data/vendor/node_modules/buble/src/program/types/Super.js +88 -0
- data/vendor/node_modules/buble/src/program/types/TaggedTemplateExpression.js +63 -0
- data/vendor/node_modules/buble/src/program/types/TemplateElement.js +7 -0
- data/vendor/node_modules/buble/src/program/types/TemplateLiteral.js +80 -0
- data/vendor/node_modules/buble/src/program/types/ThisExpression.js +31 -0
- data/vendor/node_modules/buble/src/program/types/UpdateExpression.js +32 -0
- data/vendor/node_modules/buble/src/program/types/VariableDeclaration.js +101 -0
- data/vendor/node_modules/buble/src/program/types/VariableDeclarator.js +43 -0
- data/vendor/node_modules/buble/src/program/types/index.js +98 -0
- data/vendor/node_modules/buble/src/program/types/shared/LoopStatement.js +105 -0
- data/vendor/node_modules/buble/src/program/types/shared/ModuleDeclaration.js +10 -0
- data/vendor/node_modules/buble/src/program/wrap.js +68 -0
- data/vendor/node_modules/buble/src/support.js +97 -0
- data/vendor/node_modules/buble/src/utils/CompileError.js +30 -0
- data/vendor/node_modules/buble/src/utils/array.js +11 -0
- data/vendor/node_modules/buble/src/utils/checkConst.js +8 -0
- data/vendor/node_modules/buble/src/utils/deindent.js +30 -0
- data/vendor/node_modules/buble/src/utils/destructure.js +377 -0
- data/vendor/node_modules/buble/src/utils/getSnippet.js +30 -0
- data/vendor/node_modules/buble/src/utils/isReference.js +41 -0
- data/vendor/node_modules/buble/src/utils/locate.js +20 -0
- data/vendor/node_modules/buble/src/utils/patterns.js +1 -0
- data/vendor/node_modules/buble/src/utils/removeTrailingComma.js +13 -0
- data/vendor/node_modules/buble/src/utils/reserved.js +6 -0
- data/vendor/node_modules/buble/src/utils/spread.js +70 -0
- data/vendor/node_modules/builtin-modules/builtin-modules.json +39 -0
- data/vendor/node_modules/builtin-modules/index.js +10 -0
- data/vendor/node_modules/builtin-modules/package.json +40 -0
- data/vendor/node_modules/builtin-modules/static.js +2 -0
- data/vendor/node_modules/chalk/index.js +228 -0
- data/vendor/node_modules/chalk/package.json +66 -0
- data/vendor/node_modules/chalk/templates.js +128 -0
- data/vendor/node_modules/chalk/types/index.d.ts +97 -0
- data/vendor/node_modules/color-convert/conversions.js +861 -0
- data/vendor/node_modules/color-convert/index.js +78 -0
- data/vendor/node_modules/color-convert/package.json +46 -0
- data/vendor/node_modules/color-convert/route.js +97 -0
- data/vendor/node_modules/color-name/index.js +152 -0
- data/vendor/node_modules/color-name/package.json +25 -0
- data/vendor/node_modules/color-name/test.js +7 -0
- data/vendor/node_modules/date-time/index.js +33 -0
- data/vendor/node_modules/date-time/package.json +39 -0
- data/vendor/node_modules/escape-string-regexp/index.js +11 -0
- data/vendor/node_modules/escape-string-regexp/package.json +41 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +57 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +68 -0
- data/vendor/node_modules/estree-walker/package.json +34 -0
- data/vendor/node_modules/estree-walker/src/estree-walker.js +51 -0
- data/vendor/node_modules/expand-brackets/index.js +163 -0
- data/vendor/node_modules/expand-brackets/package.json +62 -0
- data/vendor/node_modules/expand-range/index.js +43 -0
- data/vendor/node_modules/expand-range/package.json +73 -0
- data/vendor/node_modules/extglob/index.js +178 -0
- data/vendor/node_modules/extglob/package.json +60 -0
- data/vendor/node_modules/filename-regex/index.js +10 -0
- data/vendor/node_modules/filename-regex/package.json +50 -0
- data/vendor/node_modules/fill-range/index.js +408 -0
- data/vendor/node_modules/fill-range/package.json +61 -0
- data/vendor/node_modules/for-in/index.js +16 -0
- data/vendor/node_modules/for-in/package.json +68 -0
- data/vendor/node_modules/for-own/index.js +19 -0
- data/vendor/node_modules/for-own/package.json +70 -0
- data/vendor/node_modules/glob-base/index.js +51 -0
- data/vendor/node_modules/glob-base/package.json +52 -0
- data/vendor/node_modules/glob-parent/index.js +10 -0
- data/vendor/node_modules/glob-parent/package.json +35 -0
- data/vendor/node_modules/glob-parent/test.js +28 -0
- data/vendor/node_modules/has-flag/index.js +8 -0
- data/vendor/node_modules/has-flag/package.json +44 -0
- data/vendor/node_modules/irregular-plurals/irregular-plurals.json +146 -0
- data/vendor/node_modules/irregular-plurals/package.json +39 -0
- data/vendor/node_modules/is-buffer/index.js +21 -0
- data/vendor/node_modules/is-buffer/package.json +51 -0
- data/vendor/node_modules/is-dotfile/index.js +14 -0
- data/vendor/node_modules/is-dotfile/package.json +69 -0
- data/vendor/node_modules/is-equal-shallow/index.js +27 -0
- data/vendor/node_modules/is-equal-shallow/package.json +54 -0
- data/vendor/node_modules/is-extendable/index.js +13 -0
- data/vendor/node_modules/is-extendable/package.json +51 -0
- data/vendor/node_modules/is-extglob/index.js +11 -0
- data/vendor/node_modules/is-extglob/package.json +48 -0
- data/vendor/node_modules/is-glob/index.js +14 -0
- data/vendor/node_modules/is-glob/package.json +60 -0
- data/vendor/node_modules/is-module/index.js +11 -0
- data/vendor/node_modules/is-module/package.json +20 -0
- data/vendor/node_modules/is-number/index.js +19 -0
- data/vendor/node_modules/is-number/package.json +59 -0
- data/vendor/node_modules/is-posix-bracket/index.js +10 -0
- data/vendor/node_modules/is-posix-bracket/package.json +64 -0
- data/vendor/node_modules/is-primitive/index.js +13 -0
- data/vendor/node_modules/is-primitive/package.json +46 -0
- data/vendor/node_modules/is-reference/dist/is-reference.es.js +26 -0
- data/vendor/node_modules/is-reference/dist/is-reference.js +34 -0
- data/vendor/node_modules/is-reference/dist/types/index.d.ts +2 -0
- data/vendor/node_modules/is-reference/package.json +47 -0
- data/vendor/node_modules/isarray/index.js +5 -0
- data/vendor/node_modules/isarray/package.json +45 -0
- data/vendor/node_modules/isarray/test.js +20 -0
- data/vendor/node_modules/isobject/index.js +14 -0
- data/vendor/node_modules/isobject/package.json +67 -0
- data/vendor/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/locate-character/dist/locate-character.es.js +43 -0
- data/vendor/node_modules/locate-character/dist/locate-character.umd.js +54 -0
- data/vendor/node_modules/locate-character/dist/types/index.d.ts +17 -0
- data/vendor/node_modules/locate-character/package.json +41 -0
- data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1300 -0
- data/vendor/node_modules/magic-string/dist/magic-string.es.js +1296 -0
- data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1352 -0
- data/vendor/node_modules/magic-string/index.d.ts +83 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/dist/vlq.js +91 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/package.json +27 -0
- data/vendor/node_modules/magic-string/node_modules/vlq/src/vlq.js +78 -0
- data/vendor/node_modules/magic-string/package.json +55 -0
- data/vendor/node_modules/micromatch/index.js +431 -0
- data/vendor/node_modules/micromatch/lib/chars.js +67 -0
- data/vendor/node_modules/micromatch/lib/expand.js +304 -0
- data/vendor/node_modules/micromatch/lib/glob.js +193 -0
- data/vendor/node_modules/micromatch/lib/utils.js +149 -0
- data/vendor/node_modules/micromatch/package.json +114 -0
- data/vendor/node_modules/minimist/index.js +236 -0
- data/vendor/node_modules/minimist/package.json +45 -0
- data/vendor/node_modules/nodent-compiler/compiler.js +171 -0
- data/vendor/node_modules/nodent-compiler/lib/arboriculture.js +2694 -0
- data/vendor/node_modules/nodent-compiler/lib/output.js +934 -0
- data/vendor/node_modules/nodent-compiler/lib/parser.js +291 -0
- data/vendor/node_modules/nodent-compiler/package.json +37 -0
- data/vendor/node_modules/normalize-path/index.js +19 -0
- data/vendor/node_modules/normalize-path/package.json +78 -0
- data/vendor/node_modules/object.omit/index.js +40 -0
- data/vendor/node_modules/object.omit/package.json +67 -0
- data/vendor/node_modules/os-homedir/index.js +24 -0
- data/vendor/node_modules/os-homedir/package.json +41 -0
- data/vendor/node_modules/parse-glob/index.js +156 -0
- data/vendor/node_modules/parse-glob/package.json +62 -0
- data/vendor/node_modules/parse-ms/index.js +16 -0
- data/vendor/node_modules/parse-ms/package.json +34 -0
- data/vendor/node_modules/path-parse/index.js +93 -0
- data/vendor/node_modules/path-parse/index.min.js +1 -0
- data/vendor/node_modules/path-parse/package.json +33 -0
- data/vendor/node_modules/path-parse/test.js +77 -0
- data/vendor/node_modules/path-parse/test.min.js +1 -0
- data/vendor/node_modules/plur/index.js +20 -0
- data/vendor/node_modules/plur/package.json +42 -0
- data/vendor/node_modules/preserve/index.js +54 -0
- data/vendor/node_modules/preserve/package.json +48 -0
- data/vendor/node_modules/preserve/test.js +48 -0
- data/vendor/node_modules/pretty-ms/index.js +48 -0
- data/vendor/node_modules/pretty-ms/package.json +48 -0
- data/vendor/node_modules/randomatic/index.js +82 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/package.json +78 -0
- data/vendor/node_modules/regex-cache/index.js +68 -0
- data/vendor/node_modules/regex-cache/package.json +64 -0
- data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
- data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
- data/vendor/node_modules/repeat-element/index.js +18 -0
- data/vendor/node_modules/repeat-element/package.json +44 -0
- data/vendor/node_modules/repeat-string/index.js +70 -0
- data/vendor/node_modules/repeat-string/package.json +77 -0
- data/vendor/node_modules/require-relative/index.js +33 -0
- data/vendor/node_modules/require-relative/package.json +22 -0
- data/vendor/node_modules/resolve/index.js +8 -0
- data/vendor/node_modules/resolve/lib/async.js +203 -0
- data/vendor/node_modules/resolve/lib/caller.js +8 -0
- data/vendor/node_modules/resolve/lib/core.js +53 -0
- data/vendor/node_modules/resolve/lib/core.json +69 -0
- data/vendor/node_modules/resolve/lib/node-modules-paths.js +45 -0
- data/vendor/node_modules/resolve/lib/sync.js +93 -0
- data/vendor/node_modules/resolve/package.json +40 -0
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js +804 -0
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.es.js +800 -0
- data/vendor/node_modules/rollup-plugin-commonjs/package.json +52 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/ast-utils.js +104 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/defaultResolver.js +39 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/helpers.js +19 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/index.js +198 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/transform.js +431 -0
- data/vendor/node_modules/rollup-plugin-commonjs/src/utils.js +13 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js +218 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.es.js +214 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/package.json +51 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/src/empty.js +1 -0
- data/vendor/node_modules/rollup-plugin-node-resolve/src/index.js +205 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/package.json +33 -0
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/src/estree-walker.js +49 -0
- data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
- data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
- data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
- data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
- data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
- data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
- data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
- data/vendor/node_modules/rollup/bin/rollup +4085 -0
- data/vendor/node_modules/rollup/dist/rollup.browser.js +19829 -0
- data/vendor/node_modules/rollup/dist/rollup.es.js +23586 -0
- data/vendor/node_modules/rollup/dist/rollup.js +23597 -0
- data/vendor/node_modules/rollup/dist/typings/Chunk.d.ts +85 -0
- data/vendor/node_modules/rollup/dist/typings/ExternalModule.d.ts +30 -0
- data/vendor/node_modules/rollup/dist/typings/Graph.d.ts +47 -0
- data/vendor/node_modules/rollup/dist/typings/Module.d.ts +130 -0
- data/vendor/node_modules/rollup/dist/typings/ast/CallOptions.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/Entity.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/ExecutionPathOptions.d.ts +57 -0
- data/vendor/node_modules/rollup/dist/typings/ast/clone.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/ast/enhance.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/ast/keys.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrayExpression.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrayPattern.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ArrowFunctionExpression.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentPattern.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AssignmentProperty.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/AwaitExpression.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BinaryExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BlockStatement.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/BreakStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/CallExpression.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/CatchClause.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassBody.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassDeclaration.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ClassExpression.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ConditionalExpression.d.ts +28 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/DoWhileStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/EmptyStatement.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportAllDeclaration.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportDefaultDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportNamedDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExportSpecifier.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ExpressionStatement.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForInStatement.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForOfStatement.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ForStatement.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/FunctionDeclaration.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/FunctionExpression.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Identifier.d.ts +29 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/IfStatement.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Import.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportDeclaration.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportDefaultSpecifier.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportNamespaceSpecifier.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ImportSpecifier.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/LabeledStatement.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Literal.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/LogicalExpression.d.ts +23 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/MemberExpression.d.ts +34 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/MethodDefinition.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/NewExpression.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/NodeType.d.ts +64 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ObjectExpression.d.ts +22 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ObjectPattern.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Program.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/Property.d.ts +30 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/RestElement.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ReturnStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SequenceExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SpreadElement.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SwitchCase.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/SwitchStatement.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TaggedTemplateExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TemplateElement.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/TemplateLiteral.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ThisExpression.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/ThrowStatement.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UnaryExpression.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UnknownNode.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/UpdateExpression.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/VariableDeclaration.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/VariableDeclarator.d.ts +13 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/WhileStatement.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/YieldExpression.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/index.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/ClassNode.d.ts +17 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Expression.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/FunctionNode.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Node.d.ts +133 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/Pattern.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/nodes/shared/pureFunctions.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/BlockScope.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/CatchScope.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/FunctionScope.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/GlobalScope.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ModuleScope.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ParameterScope.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/ReturnValueScope.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/scopes/Scope.d.ts +42 -0
- data/vendor/node_modules/rollup/dist/typings/ast/utils/extractNames.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/ast/values.d.ts +31 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ArgumentsVariable.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ExportDefaultVariable.d.ts +16 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ExternalVariable.d.ts +12 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/GlobalVariable.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/LocalVariable.d.ts +21 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/NamespaceVariable.d.ts +20 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ParameterVariable.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ReplaceableInitializationVariable.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/ThisVariable.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/Variable.d.ts +43 -0
- data/vendor/node_modules/rollup/dist/typings/ast/variables/VariableReassignmentTracker.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/amd.d.ts +11 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/cjs.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/es.d.ts +9 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/iife.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/index.d.ts +15 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/esModuleExport.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getExportBlock.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getGlobalNameMaker.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/getInteropBlock.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/sanitize.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/setupNamespace.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/trimEmptyImports.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/shared/warnOnBuiltins.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/system.d.ts +8 -0
- data/vendor/node_modules/rollup/dist/typings/finalisers/umd.d.ts +10 -0
- data/vendor/node_modules/rollup/dist/typings/node-entry.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/rollup/index.d.ts +167 -0
- data/vendor/node_modules/rollup/dist/typings/utils/callIfFunction.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/collapseSourcemaps.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/utils/commondir.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/defaults.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/deprecateOptions.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/ensureArray.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/utils/entryHashing.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/error.d.ts +18 -0
- data/vendor/node_modules/rollup/dist/typings/utils/first-sync.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/first.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/flushTime.d.ts +5 -0
- data/vendor/node_modules/rollup/dist/typings/utils/fs.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getCodeFrame.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getExportMode.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/getIndentString.d.ts +4 -0
- data/vendor/node_modules/rollup/dist/typings/utils/identifierHelpers.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/mergeOptions.d.ts +19 -0
- data/vendor/node_modules/rollup/dist/typings/utils/object.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/utils/path.d.ts +6 -0
- data/vendor/node_modules/rollup/dist/typings/utils/promise.d.ts +2 -0
- data/vendor/node_modules/rollup/dist/typings/utils/relativeId.d.ts +1 -0
- data/vendor/node_modules/rollup/dist/typings/utils/renderHelpers.d.ts +26 -0
- data/vendor/node_modules/rollup/dist/typings/utils/sourceMappingURL.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/utils/timers.d.ts +7 -0
- data/vendor/node_modules/rollup/dist/typings/utils/transform.d.ts +25 -0
- data/vendor/node_modules/rollup/dist/typings/utils/transformBundle.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/watch/chokidar.d.ts +3 -0
- data/vendor/node_modules/rollup/dist/typings/watch/fileWatchers.d.ts +14 -0
- data/vendor/node_modules/rollup/dist/typings/watch/index.d.ts +47 -0
- data/vendor/node_modules/rollup/package.json +122 -0
- data/vendor/node_modules/rollup/typings/package.json.d.ts +3 -0
- data/vendor/node_modules/signal-exit/index.js +157 -0
- data/vendor/node_modules/signal-exit/package.json +38 -0
- data/vendor/node_modules/signal-exit/signals.js +53 -0
- data/vendor/node_modules/source-map/dist/source-map.debug.js +3091 -0
- data/vendor/node_modules/source-map/dist/source-map.js +3090 -0
- data/vendor/node_modules/source-map/dist/source-map.min.js +2 -0
- data/vendor/node_modules/source-map/lib/array-set.js +121 -0
- data/vendor/node_modules/source-map/lib/base64-vlq.js +140 -0
- data/vendor/node_modules/source-map/lib/base64.js +67 -0
- data/vendor/node_modules/source-map/lib/binary-search.js +111 -0
- data/vendor/node_modules/source-map/lib/mapping-list.js +79 -0
- data/vendor/node_modules/source-map/lib/quick-sort.js +114 -0
- data/vendor/node_modules/source-map/lib/source-map-consumer.js +1082 -0
- data/vendor/node_modules/source-map/lib/source-map-generator.js +416 -0
- data/vendor/node_modules/source-map/lib/source-node.js +413 -0
- data/vendor/node_modules/source-map/lib/util.js +417 -0
- data/vendor/node_modules/source-map/package.json +72 -0
- data/vendor/node_modules/source-map/source-map.js +8 -0
- data/vendor/node_modules/sourcemap-codec/dist/sourcemap-codec.es.js +129 -0
- data/vendor/node_modules/sourcemap-codec/dist/sourcemap-codec.umd.js +140 -0
- data/vendor/node_modules/sourcemap-codec/dist/types/sourcemap-codec.d.ts +5 -0
- data/vendor/node_modules/sourcemap-codec/package.json +52 -0
- data/vendor/node_modules/supports-color/browser.js +5 -0
- data/vendor/node_modules/supports-color/index.js +135 -0
- data/vendor/node_modules/supports-color/package.json +53 -0
- data/vendor/node_modules/time-zone/index.js +10 -0
- data/vendor/node_modules/time-zone/package.json +35 -0
- data/vendor/node_modules/vlq/dist/types/vlq.d.ts +2 -0
- data/vendor/node_modules/vlq/dist/vlq.es.js +64 -0
- data/vendor/node_modules/vlq/dist/vlq.js +75 -0
- data/vendor/node_modules/vlq/package.json +30 -0
- data/vendor/package.json +15 -0
- data/vendor/yarn.lock +453 -0
- metadata +641 -0
@@ -0,0 +1,185 @@
|
|
1
|
+
import Node from '../Node.js';
|
2
|
+
import checkConst from '../../utils/checkConst.js';
|
3
|
+
import destructure from '../../utils/destructure.js';
|
4
|
+
|
5
|
+
export default class AssignmentExpression extends Node {
|
6
|
+
initialise(transforms) {
|
7
|
+
if (this.left.type === 'Identifier') {
|
8
|
+
const declaration = this.findScope(false).findDeclaration(this.left.name);
|
9
|
+
// special case – https://gitlab.com/Rich-Harris/buble/issues/11
|
10
|
+
const statement = declaration && declaration.node.ancestor(3);
|
11
|
+
if (
|
12
|
+
statement &&
|
13
|
+
statement.type === 'ForStatement' &&
|
14
|
+
statement.body.contains(this)
|
15
|
+
) {
|
16
|
+
statement.reassigned[this.left.name] = true;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
super.initialise(transforms);
|
21
|
+
}
|
22
|
+
|
23
|
+
transpile(code, transforms) {
|
24
|
+
if (this.left.type === 'Identifier') {
|
25
|
+
// Do this check after everything has been initialized to find
|
26
|
+
// shadowing declarations after this expression
|
27
|
+
checkConst(this.left, this.findScope(false));
|
28
|
+
}
|
29
|
+
|
30
|
+
if (this.operator === '**=' && transforms.exponentiation) {
|
31
|
+
this.transpileExponentiation(code, transforms);
|
32
|
+
} else if (/Pattern/.test(this.left.type) && transforms.destructuring) {
|
33
|
+
this.transpileDestructuring(code, transforms);
|
34
|
+
}
|
35
|
+
|
36
|
+
super.transpile(code, transforms);
|
37
|
+
}
|
38
|
+
|
39
|
+
transpileDestructuring(code) {
|
40
|
+
const writeScope = this.findScope(true);
|
41
|
+
const lookupScope = this.findScope(false);
|
42
|
+
const assign = writeScope.createDeclaration('assign');
|
43
|
+
code.appendRight(this.left.end, `(${assign}`);
|
44
|
+
|
45
|
+
code.appendLeft(this.right.end, ', ');
|
46
|
+
const statementGenerators = [];
|
47
|
+
destructure(
|
48
|
+
code,
|
49
|
+
id => writeScope.createDeclaration(id),
|
50
|
+
node => {
|
51
|
+
const name = lookupScope.resolveName(node.name);
|
52
|
+
checkConst(node, lookupScope);
|
53
|
+
return name;
|
54
|
+
},
|
55
|
+
this.left,
|
56
|
+
assign,
|
57
|
+
true,
|
58
|
+
statementGenerators
|
59
|
+
);
|
60
|
+
|
61
|
+
let suffix = ', ';
|
62
|
+
statementGenerators.forEach((fn, j) => {
|
63
|
+
if (j === statementGenerators.length - 1) {
|
64
|
+
suffix = '';
|
65
|
+
}
|
66
|
+
|
67
|
+
fn(this.end, '', suffix);
|
68
|
+
});
|
69
|
+
|
70
|
+
if (this.unparenthesizedParent().type === 'ExpressionStatement') {
|
71
|
+
// no rvalue needed for expression statement
|
72
|
+
code.appendRight(this.end, `)`);
|
73
|
+
} else {
|
74
|
+
// destructuring is part of an expression - need an rvalue
|
75
|
+
code.appendRight(this.end, `, ${assign})`);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
transpileExponentiation(code) {
|
80
|
+
const scope = this.findScope(false);
|
81
|
+
|
82
|
+
// first, the easy part – `**=` -> `=`
|
83
|
+
let charIndex = this.left.end;
|
84
|
+
while (code.original[charIndex] !== '*') charIndex += 1;
|
85
|
+
code.remove(charIndex, charIndex + 2);
|
86
|
+
|
87
|
+
// how we do the next part depends on a number of factors – whether
|
88
|
+
// this is a top-level statement, and whether we're updating a
|
89
|
+
// simple or complex reference
|
90
|
+
let base;
|
91
|
+
|
92
|
+
const left = this.left.unparenthesize();
|
93
|
+
|
94
|
+
if (left.type === 'Identifier') {
|
95
|
+
base = scope.resolveName(left.name);
|
96
|
+
} else if (left.type === 'MemberExpression') {
|
97
|
+
let object;
|
98
|
+
let needsObjectVar = false;
|
99
|
+
let property;
|
100
|
+
let needsPropertyVar = false;
|
101
|
+
|
102
|
+
const statement = this.findNearest(/(?:Statement|Declaration)$/);
|
103
|
+
const i0 = statement.getIndentation();
|
104
|
+
|
105
|
+
if (left.property.type === 'Identifier') {
|
106
|
+
property = left.computed
|
107
|
+
? scope.resolveName(left.property.name)
|
108
|
+
: left.property.name;
|
109
|
+
} else {
|
110
|
+
property = scope.createDeclaration('property');
|
111
|
+
needsPropertyVar = true;
|
112
|
+
}
|
113
|
+
|
114
|
+
if (left.object.type === 'Identifier') {
|
115
|
+
object = scope.resolveName(left.object.name);
|
116
|
+
} else {
|
117
|
+
object = scope.createDeclaration('object');
|
118
|
+
needsObjectVar = true;
|
119
|
+
}
|
120
|
+
|
121
|
+
if (left.start === statement.start) {
|
122
|
+
if (needsObjectVar && needsPropertyVar) {
|
123
|
+
code.prependRight(statement.start, `${object} = `);
|
124
|
+
code.overwrite(
|
125
|
+
left.object.end,
|
126
|
+
left.property.start,
|
127
|
+
`;\n${i0}${property} = `
|
128
|
+
);
|
129
|
+
code.overwrite(
|
130
|
+
left.property.end,
|
131
|
+
left.end,
|
132
|
+
`;\n${i0}${object}[${property}]`
|
133
|
+
);
|
134
|
+
} else if (needsObjectVar) {
|
135
|
+
code.prependRight(statement.start, `${object} = `);
|
136
|
+
code.appendLeft(left.object.end, `;\n${i0}`);
|
137
|
+
code.appendLeft(left.object.end, object);
|
138
|
+
} else if (needsPropertyVar) {
|
139
|
+
code.prependRight(left.property.start, `${property} = `);
|
140
|
+
code.appendLeft(left.property.end, `;\n${i0}`);
|
141
|
+
code.move(left.property.start, left.property.end, this.start);
|
142
|
+
|
143
|
+
code.appendLeft(left.object.end, `[${property}]`);
|
144
|
+
code.remove(left.object.end, left.property.start);
|
145
|
+
code.remove(left.property.end, left.end);
|
146
|
+
}
|
147
|
+
} else {
|
148
|
+
if (needsObjectVar && needsPropertyVar) {
|
149
|
+
code.prependRight(left.start, `( ${object} = `);
|
150
|
+
code.overwrite(
|
151
|
+
left.object.end,
|
152
|
+
left.property.start,
|
153
|
+
`, ${property} = `
|
154
|
+
);
|
155
|
+
code.overwrite(
|
156
|
+
left.property.end,
|
157
|
+
left.end,
|
158
|
+
`, ${object}[${property}]`
|
159
|
+
);
|
160
|
+
} else if (needsObjectVar) {
|
161
|
+
code.prependRight(left.start, `( ${object} = `);
|
162
|
+
code.appendLeft(left.object.end, `, ${object}`);
|
163
|
+
} else if (needsPropertyVar) {
|
164
|
+
code.prependRight(left.property.start, `( ${property} = `);
|
165
|
+
code.appendLeft(left.property.end, `, `);
|
166
|
+
code.move(left.property.start, left.property.end, left.start);
|
167
|
+
|
168
|
+
code.overwrite(left.object.end, left.property.start, `[${property}]`);
|
169
|
+
code.remove(left.property.end, left.end);
|
170
|
+
}
|
171
|
+
|
172
|
+
if (needsPropertyVar) {
|
173
|
+
code.appendLeft(this.end, ` )`);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
base =
|
178
|
+
object +
|
179
|
+
(left.computed || needsPropertyVar ? `[${property}]` : `.${property}`);
|
180
|
+
}
|
181
|
+
|
182
|
+
code.prependRight(this.right.start, `Math.pow( ${base}, `);
|
183
|
+
code.appendLeft(this.right.end, ` )`);
|
184
|
+
}
|
185
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import Node from '../Node.js';
|
2
|
+
|
3
|
+
export default class BinaryExpression extends Node {
|
4
|
+
transpile(code, transforms) {
|
5
|
+
if (this.operator === '**' && transforms.exponentiation) {
|
6
|
+
code.prependRight(this.start, `Math.pow( `);
|
7
|
+
code.overwrite(this.left.end, this.right.start, `, `);
|
8
|
+
code.appendLeft(this.end, ` )`);
|
9
|
+
}
|
10
|
+
super.transpile(code, transforms);
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import Node from '../Node.js';
|
2
|
+
import CompileError from '../../utils/CompileError.js';
|
3
|
+
import { loopStatement } from '../../utils/patterns.js';
|
4
|
+
|
5
|
+
export default class BreakStatement extends Node {
|
6
|
+
initialise() {
|
7
|
+
const loop = this.findNearest(loopStatement);
|
8
|
+
const switchCase = this.findNearest('SwitchCase');
|
9
|
+
|
10
|
+
if (loop && (!switchCase || loop.depth > switchCase.depth)) {
|
11
|
+
loop.canBreak = true;
|
12
|
+
this.loop = loop;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
transpile(code) {
|
17
|
+
if (this.loop && this.loop.shouldRewriteAsFunction) {
|
18
|
+
if (this.label)
|
19
|
+
throw new CompileError(
|
20
|
+
'Labels are not currently supported in a loop with locally-scoped variables',
|
21
|
+
this
|
22
|
+
);
|
23
|
+
code.overwrite(this.start, this.start + 5, `return 'break'`);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import Node from '../Node.js';
|
2
|
+
import spread, { isArguments } from '../../utils/spread.js';
|
3
|
+
import removeTrailingComma from '../../utils/removeTrailingComma.js';
|
4
|
+
|
5
|
+
export default class CallExpression extends Node {
|
6
|
+
initialise(transforms) {
|
7
|
+
if (transforms.spreadRest && this.arguments.length > 1) {
|
8
|
+
const lexicalBoundary = this.findLexicalBoundary();
|
9
|
+
|
10
|
+
let i = this.arguments.length;
|
11
|
+
while (i--) {
|
12
|
+
const arg = this.arguments[i];
|
13
|
+
if (arg.type === 'SpreadElement' && isArguments(arg.argument)) {
|
14
|
+
this.argumentsArrayAlias = lexicalBoundary.getArgumentsArrayAlias();
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
super.initialise(transforms);
|
20
|
+
}
|
21
|
+
|
22
|
+
transpile(code, transforms) {
|
23
|
+
if (transforms.spreadRest && this.arguments.length) {
|
24
|
+
let hasSpreadElements = false;
|
25
|
+
let context;
|
26
|
+
|
27
|
+
const firstArgument = this.arguments[0];
|
28
|
+
|
29
|
+
if (this.arguments.length === 1) {
|
30
|
+
if (firstArgument.type === 'SpreadElement') {
|
31
|
+
code.remove(firstArgument.start, firstArgument.argument.start);
|
32
|
+
hasSpreadElements = true;
|
33
|
+
}
|
34
|
+
} else {
|
35
|
+
hasSpreadElements = spread(
|
36
|
+
code,
|
37
|
+
this.arguments,
|
38
|
+
firstArgument.start,
|
39
|
+
this.argumentsArrayAlias
|
40
|
+
);
|
41
|
+
}
|
42
|
+
|
43
|
+
if (hasSpreadElements) {
|
44
|
+
// we need to handle super() and super.method() differently
|
45
|
+
// due to its instance
|
46
|
+
let _super = null;
|
47
|
+
if (this.callee.type === 'Super') {
|
48
|
+
_super = this.callee;
|
49
|
+
} else if (
|
50
|
+
this.callee.type === 'MemberExpression' &&
|
51
|
+
this.callee.object.type === 'Super'
|
52
|
+
) {
|
53
|
+
_super = this.callee.object;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (!_super && this.callee.type === 'MemberExpression') {
|
57
|
+
if (this.callee.object.type === 'Identifier') {
|
58
|
+
context = this.callee.object.name;
|
59
|
+
} else {
|
60
|
+
context = this.findScope(true).createDeclaration('ref');
|
61
|
+
const callExpression = this.callee.object;
|
62
|
+
code.prependRight(callExpression.start, `(${context} = `);
|
63
|
+
code.appendLeft(callExpression.end, `)`);
|
64
|
+
}
|
65
|
+
} else {
|
66
|
+
context = 'void 0';
|
67
|
+
}
|
68
|
+
|
69
|
+
code.appendLeft(this.callee.end, '.apply');
|
70
|
+
|
71
|
+
if (_super) {
|
72
|
+
_super.noCall = true; // bit hacky...
|
73
|
+
|
74
|
+
if (this.arguments.length > 1) {
|
75
|
+
if (firstArgument.type !== 'SpreadElement') {
|
76
|
+
code.prependRight(firstArgument.start, `[ `);
|
77
|
+
}
|
78
|
+
|
79
|
+
code.appendLeft(
|
80
|
+
this.arguments[this.arguments.length - 1].end,
|
81
|
+
' )'
|
82
|
+
);
|
83
|
+
}
|
84
|
+
} else if (this.arguments.length === 1) {
|
85
|
+
code.prependRight(firstArgument.start, `${context}, `);
|
86
|
+
} else {
|
87
|
+
if (firstArgument.type === 'SpreadElement') {
|
88
|
+
code.appendLeft(firstArgument.start, `${context}, `);
|
89
|
+
} else {
|
90
|
+
code.appendLeft(firstArgument.start, `${context}, [ `);
|
91
|
+
}
|
92
|
+
|
93
|
+
code.appendLeft(this.arguments[this.arguments.length - 1].end, ' )');
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
if (transforms.trailingFunctionCommas && this.arguments.length) {
|
99
|
+
removeTrailingComma(code, this.arguments[this.arguments.length - 1].end);
|
100
|
+
}
|
101
|
+
|
102
|
+
super.transpile(code, transforms);
|
103
|
+
}
|
104
|
+
}
|
@@ -0,0 +1,237 @@
|
|
1
|
+
import Node from '../Node.js';
|
2
|
+
import { findIndex } from '../../utils/array.js';
|
3
|
+
import reserved from '../../utils/reserved.js';
|
4
|
+
|
5
|
+
// TODO this code is pretty wild, tidy it up
|
6
|
+
export default class ClassBody extends Node {
|
7
|
+
transpile(code, transforms, inFunctionExpression, superName) {
|
8
|
+
if (transforms.classes) {
|
9
|
+
const name = this.parent.name;
|
10
|
+
|
11
|
+
const indentStr = code.getIndentString();
|
12
|
+
const i0 =
|
13
|
+
this.getIndentation() + (inFunctionExpression ? indentStr : '');
|
14
|
+
const i1 = i0 + indentStr;
|
15
|
+
|
16
|
+
const constructorIndex = findIndex(
|
17
|
+
this.body,
|
18
|
+
node => node.kind === 'constructor'
|
19
|
+
);
|
20
|
+
const constructor = this.body[constructorIndex];
|
21
|
+
|
22
|
+
let introBlock = '';
|
23
|
+
let outroBlock = '';
|
24
|
+
|
25
|
+
if (this.body.length) {
|
26
|
+
code.remove(this.start, this.body[0].start);
|
27
|
+
code.remove(this.body[this.body.length - 1].end, this.end);
|
28
|
+
} else {
|
29
|
+
code.remove(this.start, this.end);
|
30
|
+
}
|
31
|
+
|
32
|
+
if (constructor) {
|
33
|
+
constructor.value.body.isConstructorBody = true;
|
34
|
+
|
35
|
+
const previousMethod = this.body[constructorIndex - 1];
|
36
|
+
const nextMethod = this.body[constructorIndex + 1];
|
37
|
+
|
38
|
+
// ensure constructor is first
|
39
|
+
if (constructorIndex > 0) {
|
40
|
+
code.remove(previousMethod.end, constructor.start);
|
41
|
+
code.move(
|
42
|
+
constructor.start,
|
43
|
+
nextMethod ? nextMethod.start : this.end - 1,
|
44
|
+
this.body[0].start
|
45
|
+
);
|
46
|
+
}
|
47
|
+
|
48
|
+
if (!inFunctionExpression) code.appendLeft(constructor.end, ';');
|
49
|
+
}
|
50
|
+
|
51
|
+
let namedFunctions =
|
52
|
+
this.program.options.namedFunctionExpressions !== false;
|
53
|
+
let namedConstructor =
|
54
|
+
namedFunctions ||
|
55
|
+
this.parent.superClass ||
|
56
|
+
this.parent.type !== 'ClassDeclaration';
|
57
|
+
if (this.parent.superClass) {
|
58
|
+
let inheritanceBlock = `if ( ${superName} ) ${name}.__proto__ = ${
|
59
|
+
superName
|
60
|
+
};\n${i0}${name}.prototype = Object.create( ${superName} && ${
|
61
|
+
superName
|
62
|
+
}.prototype );\n${i0}${name}.prototype.constructor = ${name};`;
|
63
|
+
|
64
|
+
if (constructor) {
|
65
|
+
introBlock += `\n\n${i0}` + inheritanceBlock;
|
66
|
+
} else {
|
67
|
+
const fn =
|
68
|
+
`function ${name} () {` +
|
69
|
+
(superName
|
70
|
+
? `\n${i1}${superName}.apply(this, arguments);\n${i0}}`
|
71
|
+
: `}`) +
|
72
|
+
(inFunctionExpression ? '' : ';') +
|
73
|
+
(this.body.length ? `\n\n${i0}` : '');
|
74
|
+
|
75
|
+
inheritanceBlock = fn + inheritanceBlock;
|
76
|
+
introBlock += inheritanceBlock + `\n\n${i0}`;
|
77
|
+
}
|
78
|
+
} else if (!constructor) {
|
79
|
+
let fn = 'function ' + (namedConstructor ? name + ' ' : '') + '() {}';
|
80
|
+
if (this.parent.type === 'ClassDeclaration') fn += ';';
|
81
|
+
if (this.body.length) fn += `\n\n${i0}`;
|
82
|
+
|
83
|
+
introBlock += fn;
|
84
|
+
}
|
85
|
+
|
86
|
+
const scope = this.findScope(false);
|
87
|
+
|
88
|
+
let prototypeGettersAndSetters = [];
|
89
|
+
let staticGettersAndSetters = [];
|
90
|
+
let prototypeAccessors;
|
91
|
+
let staticAccessors;
|
92
|
+
|
93
|
+
this.body.forEach((method, i) => {
|
94
|
+
if (method.kind === 'constructor') {
|
95
|
+
let constructorName = namedConstructor ? ' ' + name : '';
|
96
|
+
code.overwrite(
|
97
|
+
method.key.start,
|
98
|
+
method.key.end,
|
99
|
+
`function${constructorName}`
|
100
|
+
);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (method.static) {
|
105
|
+
const len = code.original[method.start + 6] == ' ' ? 7 : 6;
|
106
|
+
code.remove(method.start, method.start + len);
|
107
|
+
}
|
108
|
+
|
109
|
+
const isAccessor = method.kind !== 'method';
|
110
|
+
let lhs;
|
111
|
+
|
112
|
+
let methodName = method.key.name;
|
113
|
+
if (
|
114
|
+
reserved[methodName] ||
|
115
|
+
method.value.body.scope.references[methodName]
|
116
|
+
) {
|
117
|
+
methodName = scope.createIdentifier(methodName);
|
118
|
+
}
|
119
|
+
|
120
|
+
// when method name is a string or a number let's pretend it's a computed method
|
121
|
+
|
122
|
+
let fake_computed = false;
|
123
|
+
if (!method.computed && method.key.type === 'Literal') {
|
124
|
+
fake_computed = true;
|
125
|
+
method.computed = true;
|
126
|
+
}
|
127
|
+
|
128
|
+
if (isAccessor) {
|
129
|
+
if (method.computed) {
|
130
|
+
throw new Error(
|
131
|
+
'Computed accessor properties are not currently supported'
|
132
|
+
);
|
133
|
+
}
|
134
|
+
|
135
|
+
code.remove(method.start, method.key.start);
|
136
|
+
|
137
|
+
if (method.static) {
|
138
|
+
if (!~staticGettersAndSetters.indexOf(method.key.name))
|
139
|
+
staticGettersAndSetters.push(method.key.name);
|
140
|
+
if (!staticAccessors)
|
141
|
+
staticAccessors = scope.createIdentifier('staticAccessors');
|
142
|
+
|
143
|
+
lhs = `${staticAccessors}`;
|
144
|
+
} else {
|
145
|
+
if (!~prototypeGettersAndSetters.indexOf(method.key.name))
|
146
|
+
prototypeGettersAndSetters.push(method.key.name);
|
147
|
+
if (!prototypeAccessors)
|
148
|
+
prototypeAccessors = scope.createIdentifier('prototypeAccessors');
|
149
|
+
|
150
|
+
lhs = `${prototypeAccessors}`;
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
lhs = method.static ? `${name}` : `${name}.prototype`;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (!method.computed) lhs += '.';
|
157
|
+
|
158
|
+
const insertNewlines =
|
159
|
+
(constructorIndex > 0 && i === constructorIndex + 1) ||
|
160
|
+
(i === 0 && constructorIndex === this.body.length - 1);
|
161
|
+
|
162
|
+
if (insertNewlines) lhs = `\n\n${i0}${lhs}`;
|
163
|
+
|
164
|
+
let c = method.key.end;
|
165
|
+
if (method.computed) {
|
166
|
+
if (fake_computed) {
|
167
|
+
code.prependRight(method.key.start, '[');
|
168
|
+
code.appendLeft(method.key.end, ']');
|
169
|
+
} else {
|
170
|
+
while (code.original[c] !== ']') c += 1;
|
171
|
+
c += 1;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
const funcName =
|
176
|
+
method.computed || isAccessor || !namedFunctions
|
177
|
+
? ''
|
178
|
+
: `${methodName} `;
|
179
|
+
const rhs =
|
180
|
+
(isAccessor ? `.${method.kind}` : '') +
|
181
|
+
` = function` +
|
182
|
+
(method.value.generator ? '* ' : ' ') +
|
183
|
+
funcName;
|
184
|
+
code.remove(c, method.value.start);
|
185
|
+
code.prependRight(method.value.start, rhs);
|
186
|
+
code.appendLeft(method.end, ';');
|
187
|
+
|
188
|
+
if (method.value.generator) code.remove(method.start, method.key.start);
|
189
|
+
|
190
|
+
code.prependRight(method.start, lhs);
|
191
|
+
});
|
192
|
+
|
193
|
+
if (prototypeGettersAndSetters.length || staticGettersAndSetters.length) {
|
194
|
+
let intro = [];
|
195
|
+
let outro = [];
|
196
|
+
|
197
|
+
if (prototypeGettersAndSetters.length) {
|
198
|
+
intro.push(
|
199
|
+
`var ${prototypeAccessors} = { ${prototypeGettersAndSetters
|
200
|
+
.map(name => `${name}: { configurable: true }`)
|
201
|
+
.join(',')} };`
|
202
|
+
);
|
203
|
+
outro.push(
|
204
|
+
`Object.defineProperties( ${name}.prototype, ${
|
205
|
+
prototypeAccessors
|
206
|
+
} );`
|
207
|
+
);
|
208
|
+
}
|
209
|
+
|
210
|
+
if (staticGettersAndSetters.length) {
|
211
|
+
intro.push(
|
212
|
+
`var ${staticAccessors} = { ${staticGettersAndSetters
|
213
|
+
.map(name => `${name}: { configurable: true }`)
|
214
|
+
.join(',')} };`
|
215
|
+
);
|
216
|
+
outro.push(`Object.defineProperties( ${name}, ${staticAccessors} );`);
|
217
|
+
}
|
218
|
+
|
219
|
+
if (constructor) introBlock += `\n\n${i0}`;
|
220
|
+
introBlock += intro.join(`\n${i0}`);
|
221
|
+
if (!constructor) introBlock += `\n\n${i0}`;
|
222
|
+
|
223
|
+
outroBlock += `\n\n${i0}` + outro.join(`\n${i0}`);
|
224
|
+
}
|
225
|
+
|
226
|
+
if (constructor) {
|
227
|
+
code.appendLeft(constructor.end, introBlock);
|
228
|
+
} else {
|
229
|
+
code.prependRight(this.start, introBlock);
|
230
|
+
}
|
231
|
+
|
232
|
+
code.appendLeft(this.end, outroBlock);
|
233
|
+
}
|
234
|
+
|
235
|
+
super.transpile(code, transforms);
|
236
|
+
}
|
237
|
+
}
|