Add basic ES6 support in util/walk.js
This commit is contained in:
parent
372e1d42f3
commit
69cadaa1e9
@ -693,7 +693,8 @@
|
||||
while (!closes(tt.braceR, propIndent, line)) {
|
||||
var name = parsePropertyName();
|
||||
if (!name) { if (isDummy(parseExpression(true))) next(); eat(tt.comma); continue; }
|
||||
var prop = {key: name}, isGetSet = false, kind;
|
||||
var prop = startNode(), isGetSet = false, kind;
|
||||
prop.key = name;
|
||||
if (eat(tt.colon)) {
|
||||
prop.value = parseExpression(true);
|
||||
kind = prop.kind = "init";
|
||||
@ -709,7 +710,7 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
node.properties.push(prop);
|
||||
node.properties.push(finishNode(prop, "Property"));
|
||||
eat(tt.comma);
|
||||
}
|
||||
popCx();
|
||||
|
||||
33
util/walk.js
33
util/walk.js
@ -197,10 +197,10 @@
|
||||
c(cs.consequent[j], st, "Statement");
|
||||
}
|
||||
};
|
||||
base.ReturnStatement = function(node, st, c) {
|
||||
base.ReturnStatement = base.YieldExpression = function(node, st, c) {
|
||||
if (node.argument) c(node.argument, st, "Expression");
|
||||
};
|
||||
base.ThrowStatement = function(node, st, c) {
|
||||
base.ThrowStatement = base.SpreadElement = function(node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.TryStatement = function(node, st, c) {
|
||||
@ -219,7 +219,7 @@
|
||||
if (node.update) c(node.update, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInStatement = function(node, st, c) {
|
||||
base.ForInStatement = base.ForOfStatement = function(node, st, c) {
|
||||
c(node.left, st, "ForInit");
|
||||
c(node.right, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
@ -257,10 +257,10 @@
|
||||
};
|
||||
base.ObjectExpression = function(node, st, c) {
|
||||
for (var i = 0; i < node.properties.length; ++i)
|
||||
c(node.properties[i].value, st, "Expression");
|
||||
c(node.properties[i], st);
|
||||
};
|
||||
base.FunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = function(node, st, c) {
|
||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = base.TemplateLiteral = function(node, st, c) {
|
||||
for (var i = 0; i < node.expressions.length; ++i)
|
||||
c(node.expressions[i], st, "Expression");
|
||||
};
|
||||
@ -285,7 +285,26 @@
|
||||
c(node.object, st, "Expression");
|
||||
if (node.computed) c(node.property, st, "Expression");
|
||||
};
|
||||
base.Identifier = base.Literal = ignore;
|
||||
base.Identifier = base.Literal = base.ExportDeclaration = base.ImportDeclaration = ignore;
|
||||
|
||||
base.TaggedTemplateExpression = function(node, st, c) {
|
||||
c(node.tag, st, "Expression");
|
||||
c(node.quasi, st);
|
||||
};
|
||||
base.ClassDeclaration = base.ClassExpression = function(node, st, c) {
|
||||
if (node.superClass) c(node.superClass, st, "Expression");
|
||||
for (var i = 0; i < node.body.body.length; i++)
|
||||
c(node.body.body[i], st);
|
||||
};
|
||||
base.MethodDefinition = base.Property = function(node, st, c) {
|
||||
if (node.computed) c(node.key, st, "Expression");
|
||||
c(node.value, st, "Expression");
|
||||
};
|
||||
base.ComprehensionExpression = function(node, st, c) {
|
||||
for (var i = 0; i < node.blocks.length; i++)
|
||||
c(node.blocks[i].right, st, "Expression");
|
||||
c(node.body, st, "Expression");
|
||||
};
|
||||
|
||||
// A custom walker that keeps track of the scope chain and the
|
||||
// variables defined in it.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user