[Pkg-javascript-commits] [node-acorn-jsx] 268/484: Add basic ES6 support in util/walk.js
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 69cadaa1e9d3064634bb9b0be63c1f780816fd81
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Thu Aug 14 13:23:03 2014 +0200
Add basic ES6 support in util/walk.js
---
acorn_loose.js | 5 +++--
util/walk.js | 33 ++++++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/acorn_loose.js b/acorn_loose.js
index af0e97a..de29599 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -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();
diff --git a/util/walk.js b/util/walk.js
index f8c697c..04268f2 100644
--- a/util/walk.js
+++ b/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.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list