Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: utils/astml.js

Issue 29350140: Issue 4353 - Remove non standard for each syntax (Closed)
Patch Set: Created Aug. 24, 2016, 11:08 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: utils/astml.js
diff --git a/utils/astml.js b/utils/astml.js
index 0065a87c0e9ce7f05a2fba56b2c62570b83b5ee3..d8f4952640f4c90822ba6ae243c50c49b98de35a 100644
--- a/utils/astml.js
+++ b/utils/astml.js
@@ -107,10 +107,10 @@ function walkAST(ast, visitor) {
if (cback in visitor)
deep = visitor[cback](node);
if (!deep) {
- for each (let part in info) {
+ for (let part of info) {
let piece = node[part];
if (piece instanceof Array) {
- [astVisitor(x) for each (x in piece)];
+ piece.map(astVisitor);
} else if (piece) {
astVisitor(piece);
}
@@ -343,14 +343,14 @@ function convertTOK_LB(pn) {
function convertTOK_RB(pn) {
let ast = shellNode(pn, "ArrayLiteral");
ast.precedence = 0;
- ast.members = [parseToAst(x) for each (x in pn.kids)];
+ ast.members = pn.kids.map(parseToAst);
return ast;
}
/* Returns a list */
function convertTOK_LC(pn) {
let ast = shellNode(pn, "BlockStatement");
- ast.statements = [parseToAst(x) for each (x in pn.kids)];
+ ast.statements = pn.kinds.map(parseToAst);
if (ast.statements.length == 0) {
return shellNode(pn, "EmptyStatement");
}
@@ -359,14 +359,14 @@ function convertTOK_LC(pn) {
function convertTOK_RC(pn) {
let ast = shellNode(pn, "ObjectLiteral");
- ast.setters = [parseToAst(x) for each (x in pn.kids)];
+ ast.setters = pn.kids.map(parseToAst);
return ast;
}
function convertTOK_LP(pn) {
if (pn.op != JSOP_CALL && pn.op != JSOP_APPLY) {
let ast = shellNode(pn, "LetStatement");
- ast.variables = [parseToAst(x) for each (x in pn.kids)];
+ ast.variables = pn.kids.map(parseToAst);
return ast;
}
let ast = shellNode(pn, "CallExpression");
@@ -543,8 +543,8 @@ function convertTOK_VAR(pn) {
ast.vartype = "const";
else
ast.vartype = "var";
- ast.variables = [parseToAst(x) for each (x in pn.kids)];
- for each (let x in ast.variables) {
+ ast.variables = pn.kids.map(parseToAst);
+ for (let x of ast.variables) {
if (x.type == "LetStatement")
return x;
if (x.type == "IdentifierExpression")
@@ -679,5 +679,5 @@ function convertTOK_FORHEAD(pn) {
}
function convertTOK_RESERVED(pn) {
- return [parseToAst(x) for each (x in pn.kids)];
+ return pn.kids.map(parseToAst);
}
« scripts/decompile.js ('K') | « scripts/findInterfaces.js ('k') | utils/cleanast.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld