upgrade to babel 5
This commit is contained in:
parent
2952d94e60
commit
cfffaf6cdb
5
.babelrc
5
.babelrc
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"experimental": true,
|
"stage": 0,
|
||||||
"playground": true,
|
"loose": ["all"],
|
||||||
"loose": true,
|
|
||||||
"blacklist": ["es6.tailCall"]
|
"blacklist": ["es6.tailCall"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
"user-home": "^1.1.1"
|
"user-home": "^1.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel": "4.7.13",
|
"babel": "5.1.13",
|
||||||
"browserify": "^9.0.8",
|
"browserify": "^9.0.8",
|
||||||
"chai": "^2.2.0",
|
"chai": "^2.2.0",
|
||||||
"eslint": "^0.18.0",
|
"eslint": "^0.18.0",
|
||||||
|
|||||||
3
src/acorn/index.js
Normal file
3
src/acorn/index.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./src/index";
|
||||||
|
import "./plugins/flow";
|
||||||
|
import "./plugins/jsx";
|
||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "acorn",
|
"name": "acorn",
|
||||||
"description": "ECMAScript parser",
|
"description": "ECMAScript parser",
|
||||||
"homepage": "https://github.com/marijnh/acorn",
|
"homepage": "https://github.com/marijnh/acorn",
|
||||||
"main": "src/index.js",
|
"main": "index.js",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var acorn = require("..")
|
var acorn = require("../src/index")
|
||||||
|
|
||||||
var pp = acorn.Parser.prototype
|
var pp = acorn.Parser.prototype
|
||||||
var tt = acorn.tokTypes
|
var tt = acorn.tokTypes
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var acorn = require("..")
|
var acorn = require("../src/index")
|
||||||
|
|
||||||
var tt = acorn.tokTypes;
|
var tt = acorn.tokTypes;
|
||||||
var tc = acorn.tokContexts;
|
var tc = acorn.tokContexts;
|
||||||
|
|||||||
@ -38,9 +38,6 @@ export {isIdentifierChar, isIdentifierStart} from "./identifier"
|
|||||||
export {Token} from "./tokenize"
|
export {Token} from "./tokenize"
|
||||||
export {isNewLine, lineBreak, lineBreakG} from "./whitespace"
|
export {isNewLine, lineBreak, lineBreakG} from "./whitespace"
|
||||||
|
|
||||||
import "../plugins/flow";
|
|
||||||
import "../plugins/jsx";
|
|
||||||
|
|
||||||
export const version = "1.0.0"
|
export const version = "1.0.0"
|
||||||
|
|
||||||
// The main exported interface (under `self.acorn` when in the
|
// The main exported interface (under `self.acorn` when in the
|
||||||
|
|||||||
@ -11,7 +11,7 @@ transform.run = function (code, opts = {}) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
transform.load = function (url, callback, opts = {}, hold) {
|
transform.load = function (url, callback, opts = {}, hold) {
|
||||||
opts.filename ||= url;
|
opts.filename = opts.filename || url;
|
||||||
|
|
||||||
var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
|
var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
|
||||||
xhr.open("GET", url, true);
|
xhr.open("GET", url, true);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export default class Buffer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeLast ||= false;
|
removeLast = removeLast || false;
|
||||||
|
|
||||||
if (isNumber(i)) {
|
if (isNumber(i)) {
|
||||||
i = Math.min(2, i);
|
i = Math.min(2, i);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import * as t from "../types";
|
|||||||
|
|
||||||
class CodeGenerator {
|
class CodeGenerator {
|
||||||
constructor(ast, opts, code) {
|
constructor(ast, opts, code) {
|
||||||
opts ||= {};
|
opts = opts || {};
|
||||||
|
|
||||||
this.comments = ast.comments || [];
|
this.comments = ast.comments || [];
|
||||||
this.tokens = ast.tokens || [];
|
this.tokens = ast.tokens || [];
|
||||||
|
|||||||
@ -16,7 +16,7 @@ function crawl(node, state = {}) {
|
|||||||
} else if (t.isFunction(node)) {
|
} else if (t.isFunction(node)) {
|
||||||
state.hasFunction = true;
|
state.hasFunction = true;
|
||||||
} else if (t.isIdentifier(node)) {
|
} else if (t.isIdentifier(node)) {
|
||||||
state.hasHelper ||= isHelper(node.callee);
|
state.hasHelper = state.hasHelper || isHelper(node.callee);
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export default function (loc, opts = {}) {
|
|||||||
var json;
|
var json;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = jsons[content] ||= JSON.parse(stripJsonComments(content));
|
json = jsons[content] = jsons[content] || JSON.parse(stripJsonComments(content));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
err.message = `${file}: ${err.message}`;
|
err.message = `${file}: ${err.message}`;
|
||||||
throw err;
|
throw err;
|
||||||
|
|||||||
@ -134,7 +134,7 @@ export default class File {
|
|||||||
if (optionParser) val = optionParser(key, val);
|
if (optionParser) val = optionParser(key, val);
|
||||||
|
|
||||||
if (option.alias) {
|
if (option.alias) {
|
||||||
opts[option.alias] ||= val;
|
opts[option.alias] = opts[option.alias] || val;
|
||||||
} else {
|
} else {
|
||||||
opts[key] = val;
|
opts[key] = val;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ export default class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addImport(source: string, name?: string, type?: string): Object {
|
addImport(source: string, name?: string, type?: string): Object {
|
||||||
name ||= source;
|
name = name || source;
|
||||||
var id = this.dynamicImportIds[name];
|
var id = this.dynamicImportIds[name];
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
@ -361,7 +361,7 @@ export default class File {
|
|||||||
declar._blockHoist = 3;
|
declar._blockHoist = 3;
|
||||||
|
|
||||||
if (type) {
|
if (type) {
|
||||||
var modules = this.dynamicImportTypes[type] ||= [];
|
var modules = this.dynamicImportTypes[type] = this.dynamicImportTypes[type] || [];
|
||||||
modules.push(declar);
|
modules.push(declar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ export default class File {
|
|||||||
attachAuxiliaryComment(node: Object): Object {
|
attachAuxiliaryComment(node: Object): Object {
|
||||||
var comment = this.opts.auxiliaryComment;
|
var comment = this.opts.auxiliaryComment;
|
||||||
if (comment) {
|
if (comment) {
|
||||||
node.leadingComments ||= [];
|
node.leadingComments = node.leadingComments || [];
|
||||||
node.leadingComments.push({
|
node.leadingComments.push({
|
||||||
type: "Line",
|
type: "Line",
|
||||||
value: " " + comment
|
value: " " + comment
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export function push(mutatorMap, node, kind, file) {
|
|||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
map._inherits ||= [];
|
map._inherits = map._inherits || [];
|
||||||
map._inherits.push(node);
|
map._inherits.push(node);
|
||||||
|
|
||||||
map._key = node.key;
|
map._key = node.key;
|
||||||
@ -25,7 +25,7 @@ export function push(mutatorMap, node, kind, file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node.decorators) {
|
if (node.decorators) {
|
||||||
var decorators = map.decorators ||= t.arrayExpression([]);
|
var decorators = map.decorators = map.decorators || t.arrayExpression([]);
|
||||||
decorators.elements = decorators.elements.concat(node.decorators.map(dec => dec.expression));
|
decorators.elements = decorators.elements.concat(node.decorators.map(dec => dec.expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ var referenceVisitor = {
|
|||||||
enter(node, parent, scope, state) {
|
enter(node, parent, scope, state) {
|
||||||
var name = state.id.name;
|
var name = state.id.name;
|
||||||
if (t.isReferencedIdentifier(node, parent, { name: name }) && scope.bindingIdentifierEquals(name, state.id)) {
|
if (t.isReferencedIdentifier(node, parent, { name: name }) && scope.bindingIdentifierEquals(name, state.id)) {
|
||||||
return state.ref ||= scope.generateUidIdentifier(name);
|
return state.ref = state.ref || scope.generateUidIdentifier(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -218,7 +218,7 @@ export default class ReplaceSupers {
|
|||||||
return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
|
return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
|
||||||
} else {
|
} else {
|
||||||
// super.age += 2; -> var _ref = super.age; super.age = _ref + 2;
|
// super.age += 2; -> var _ref = super.age; super.age = _ref + 2;
|
||||||
ref ||= path.scope.generateUidIdentifier("ref");
|
ref = ref || path.scope.generateUidIdentifier("ref");
|
||||||
return [
|
return [
|
||||||
t.variableDeclaration("var", [
|
t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(ref, node.left)
|
t.variableDeclarator(ref, node.left)
|
||||||
|
|||||||
@ -60,7 +60,7 @@ import rawTransformers from "./transformers";
|
|||||||
each(rawTransformers, function (transformer, key) {
|
each(rawTransformers, function (transformer, key) {
|
||||||
var namespace = key.split(".")[0];
|
var namespace = key.split(".")[0];
|
||||||
|
|
||||||
transform.namespaces[namespace] ||= [];
|
transform.namespaces[namespace] = transform.namespaces[namespace] || [];
|
||||||
transform.namespaces[namespace].push(key);
|
transform.namespaces[namespace].push(key);
|
||||||
transform.transformerNamespaces[key] = namespace;
|
transform.transformerNamespaces[key] = namespace;
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ export default class DefaultFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addExport(name, exported) {
|
_addExport(name, exported) {
|
||||||
var info = this.localExports[name] ||= {
|
var info = this.localExports[name] = this.localExports[name] || {
|
||||||
binding: this.scope.getBindingIdentifier(name),
|
binding: this.scope.getBindingIdentifier(name),
|
||||||
exported: []
|
exported: []
|
||||||
};
|
};
|
||||||
|
|||||||
@ -114,7 +114,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
|||||||
uid = this.scope.generateUidBasedOnNode(node, "import");
|
uid = this.scope.generateUidBasedOnNode(node, "import");
|
||||||
}
|
}
|
||||||
|
|
||||||
uid ||= node.specifiers[0].local;
|
uid = uid || node.specifiers[0].local;
|
||||||
|
|
||||||
var declar = t.variableDeclaration("var", [
|
var declar = t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(uid, call)
|
t.variableDeclarator(uid, call)
|
||||||
|
|||||||
@ -77,11 +77,11 @@ var runnerSettersVisitor = {
|
|||||||
|
|
||||||
export default class SystemFormatter extends AMDFormatter {
|
export default class SystemFormatter extends AMDFormatter {
|
||||||
constructor(file) {
|
constructor(file) {
|
||||||
|
super(file);
|
||||||
|
|
||||||
this.exportIdentifier = file.scope.generateUidIdentifier("export");
|
this.exportIdentifier = file.scope.generateUidIdentifier("export");
|
||||||
this.noInteropRequireExport = true;
|
this.noInteropRequireExport = true;
|
||||||
this.noInteropRequireImport = true;
|
this.noInteropRequireImport = true;
|
||||||
|
|
||||||
DefaultFormatter.apply(this, arguments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addImportSource(node, exportNode) {
|
_addImportSource(node, exportNode) {
|
||||||
|
|||||||
@ -39,7 +39,7 @@ export default class Transformer {
|
|||||||
//
|
//
|
||||||
|
|
||||||
this.handlers = this.normalize(transformer);
|
this.handlers = this.normalize(transformer);
|
||||||
this.opts ||= {};
|
this.opts = this.opts || {};
|
||||||
this.key = transformerKey;
|
this.key = transformerKey;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -14,7 +14,7 @@ function isLet(node, parent) {
|
|||||||
if (isLetInitable(node, parent)) {
|
if (isLetInitable(node, parent)) {
|
||||||
for (var i = 0; i < node.declarations.length; i++) {
|
for (var i = 0; i < node.declarations.length; i++) {
|
||||||
var declar = node.declarations[i];
|
var declar = node.declarations[i];
|
||||||
declar.init ||= t.identifier("undefined");
|
declar.init = declar.init || t.identifier("undefined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ class BlockScoping {
|
|||||||
for (var i = 0; i < cases.length; i++) {
|
for (var i = 0; i < cases.length; i++) {
|
||||||
var caseConsequent = cases[i].consequent[0];
|
var caseConsequent = cases[i].consequent[0];
|
||||||
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
|
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
|
||||||
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
|
caseConsequent.label = this.loopLabel = this.loopLabel || this.file.scope.generateUidIdentifier("loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -558,11 +558,11 @@ class ClassTransformer {
|
|||||||
var body;
|
var body;
|
||||||
var target;
|
var target;
|
||||||
if (node.static) {
|
if (node.static) {
|
||||||
initializers = this.staticInitializersId ||= this.scope.generateUidIdentifier("staticInitializers");
|
initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
|
||||||
body = this.staticPropBody;
|
body = this.staticPropBody;
|
||||||
target = this.classRef;
|
target = this.classRef;
|
||||||
} else {
|
} else {
|
||||||
initializers = this.instanceInitializersId ||= this.scope.generateUidIdentifier("instanceInitializers");
|
initializers = this.instanceInitializersId = this.instanceInitializersId || this.scope.generateUidIdentifier("instanceInitializers");
|
||||||
body = this.instancePropBody;
|
body = this.instancePropBody;
|
||||||
target = t.thisExpression();
|
target = t.thisExpression();
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@ class ClassTransformer {
|
|||||||
])
|
])
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
node.value ||= t.identifier("undefined");
|
node.value = node.value || t.identifier("undefined");
|
||||||
|
|
||||||
if (node.static) {
|
if (node.static) {
|
||||||
// can just be added to the static map
|
// can just be added to the static map
|
||||||
|
|||||||
@ -200,7 +200,7 @@ export function VariableDeclaration(node, parent, scope, file) {
|
|||||||
|
|
||||||
for (i = 0; i < nodes.length; i++) {
|
for (i = 0; i < nodes.length; i++) {
|
||||||
node = nodes[i];
|
node = nodes[i];
|
||||||
declar ||= t.variableDeclaration(node.kind, []);
|
declar = declar || t.variableDeclaration(node.kind, []);
|
||||||
|
|
||||||
if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
|
if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
|
||||||
throw file.errorWithNode(node, messages.get("invalidParentForThisNode"));
|
throw file.errorWithNode(node, messages.get("invalidParentForThisNode"));
|
||||||
|
|||||||
@ -32,7 +32,7 @@ function Property(path, node, scope, getObjectRef, file) {
|
|||||||
|
|
||||||
export function ObjectExpression(node, parent, scope, file) {
|
export function ObjectExpression(node, parent, scope, file) {
|
||||||
var objectRef;
|
var objectRef;
|
||||||
var getObjectRef = () => objectRef ||= scope.generateUidIdentifier("obj");
|
var getObjectRef = () => objectRef = objectRef || scope.generateUidIdentifier("obj");
|
||||||
|
|
||||||
var propPaths = this.get("properties");
|
var propPaths = this.get("properties");
|
||||||
for (var i = 0; i < node.properties.length; i++) {
|
for (var i = 0; i < node.properties.length; i++) {
|
||||||
|
|||||||
@ -101,23 +101,23 @@ class TailCallTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getArgumentsId() {
|
getArgumentsId() {
|
||||||
return this.argumentsId ||= this.scope.generateUidIdentifier("arguments");
|
return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
getThisId() {
|
getThisId() {
|
||||||
return this.thisId ||= this.scope.generateUidIdentifier("this");
|
return this.thisId = this.thisId || this.scope.generateUidIdentifier("this");
|
||||||
}
|
}
|
||||||
|
|
||||||
getLeftId() {
|
getLeftId() {
|
||||||
return this.leftId ||= this.scope.generateUidIdentifier("left");
|
return this.leftId = this.leftId || this.scope.generateUidIdentifier("left");
|
||||||
}
|
}
|
||||||
|
|
||||||
getFunctionId() {
|
getFunctionId() {
|
||||||
return this.functionId ||= this.scope.generateUidIdentifier("function");
|
return this.functionId = this.functionId || this.scope.generateUidIdentifier("function");
|
||||||
}
|
}
|
||||||
|
|
||||||
getAgainId() {
|
getAgainId() {
|
||||||
return this.againId ||= this.scope.generateUidIdentifier("again");
|
return this.againId = this.againId || this.scope.generateUidIdentifier("again");
|
||||||
}
|
}
|
||||||
|
|
||||||
getParams() {
|
getParams() {
|
||||||
|
|||||||
@ -52,11 +52,11 @@ function aliasFunction(getBody, path, scope) {
|
|||||||
|
|
||||||
var state = {
|
var state = {
|
||||||
getArgumentsId() {
|
getArgumentsId() {
|
||||||
return argumentsId ||= scope.generateUidIdentifier("arguments");
|
return argumentsId = argumentsId || scope.generateUidIdentifier("arguments");
|
||||||
},
|
},
|
||||||
|
|
||||||
getThisId() {
|
getThisId() {
|
||||||
return thisId ||= scope.generateUidIdentifier("this");
|
return thisId = thisId || scope.generateUidIdentifier("this");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ function aliasFunction(getBody, path, scope) {
|
|||||||
var body;
|
var body;
|
||||||
|
|
||||||
var pushDeclaration = function (id, init) {
|
var pushDeclaration = function (id, init) {
|
||||||
body ||= getBody();
|
body = body || getBody();
|
||||||
body.unshift(t.variableDeclaration("var", [
|
body.unshift(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(id, init)
|
t.variableDeclarator(id, init)
|
||||||
]));
|
]));
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export function MethodDefinition(node) {
|
|||||||
var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
|
var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
|
||||||
|
|
||||||
// get ["constructor"]() {}
|
// get ["constructor"]() {}
|
||||||
isConstructor ||= t.isLiteral(node.key, { value: "constructor" });
|
isConstructor = isConstructor || t.isLiteral(node.key, { value: "constructor" });
|
||||||
|
|
||||||
if (isConstructor) {
|
if (isConstructor) {
|
||||||
throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
|
throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
|
||||||
|
|||||||
@ -122,7 +122,8 @@ traverse.explode = function (obj) {
|
|||||||
var aliases = t.FLIPPED_ALIAS_KEYS[type];
|
var aliases = t.FLIPPED_ALIAS_KEYS[type];
|
||||||
if (aliases) {
|
if (aliases) {
|
||||||
for (var i = 0; i < aliases.length; i++) {
|
for (var i = 0; i < aliases.length; i++) {
|
||||||
obj[aliases[i]] ||= fns;
|
var alias = aliases[i];
|
||||||
|
obj[alias] = obj[alias] || fns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export default class TraversalPath {
|
|||||||
|
|
||||||
static get(parentPath: TraversalPath, context?: TraversalContext, parent, container, key, file?: File) {
|
static get(parentPath: TraversalPath, context?: TraversalContext, parent, container, key, file?: File) {
|
||||||
var targetNode = container[key];
|
var targetNode = container[key];
|
||||||
var paths = container._paths ||= [];
|
var paths = container._paths = container._paths || [];
|
||||||
var path;
|
var path;
|
||||||
|
|
||||||
for (var i = 0; i < paths.length; i++) {
|
for (var i = 0; i < paths.length; i++) {
|
||||||
@ -613,7 +613,7 @@ export default class TraversalPath {
|
|||||||
var match = prop.isnt("computed") && key.isIdentifier({ name: targetName });
|
var match = prop.isnt("computed") && key.isIdentifier({ name: targetName });
|
||||||
|
|
||||||
// { "foo": "obj" } or { ["foo"]: "obj" }
|
// { "foo": "obj" } or { ["foo"]: "obj" }
|
||||||
match ||= key.isLiteral({ value: targetName });
|
match = match || key.isLiteral({ value: targetName });
|
||||||
|
|
||||||
if (match) return prop.get("value");
|
if (match) return prop.get("value");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -242,8 +242,8 @@ export default class Scope {
|
|||||||
if (kind === "hoisted" && local.kind === "let") return;
|
if (kind === "hoisted" && local.kind === "let") return;
|
||||||
|
|
||||||
var duplicate = false;
|
var duplicate = false;
|
||||||
duplicate ||= kind === "let" || kind === "const" || local.kind === "let" || local.kind === "const" || local.kind === "module";
|
if (!duplicate) duplicate = kind === "let" || kind === "const" || local.kind === "let" || local.kind === "const" || local.kind === "module";
|
||||||
duplicate ||= local.kind === "param" && (kind === "let" || kind === "const");
|
if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const");
|
||||||
|
|
||||||
if (duplicate) {
|
if (duplicate) {
|
||||||
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
|
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
|
||||||
@ -255,7 +255,7 @@ export default class Scope {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rename(oldName: string, newName: string, block?) {
|
rename(oldName: string, newName: string, block?) {
|
||||||
newName ||= this.generateUidIdentifier(oldName).name;
|
newName = newName || this.generateUidIdentifier(oldName).name;
|
||||||
|
|
||||||
var info = this.getBinding(oldName);
|
var info = this.getBinding(oldName);
|
||||||
if (!info) return;
|
if (!info) return;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ function registerType(type: string, skipAliasCheck?: boolean) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
t[`assert${type}`] = function (node, opts) {
|
t[`assert${type}`] = function (node, opts) {
|
||||||
opts ||= {};
|
opts = opts || {};
|
||||||
if (!is(node, opts)) {
|
if (!is(node, opts)) {
|
||||||
throw new Error(`Expected type ${JSON.stringify(type)} with option ${JSON.stringify(opts)}`);
|
throw new Error(`Expected type ${JSON.stringify(type)} with option ${JSON.stringify(opts)}`);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ each(t.VISITOR_KEYS, function (keys, type) {
|
|||||||
|
|
||||||
each(t.ALIAS_KEYS, function (aliases, type) {
|
each(t.ALIAS_KEYS, function (aliases, type) {
|
||||||
each(aliases, function (alias) {
|
each(aliases, function (alias) {
|
||||||
var types = t.FLIPPED_ALIAS_KEYS[alias] ||= [];
|
var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || [];
|
||||||
types.push(type);
|
types.push(type);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user