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

Unified Diff: scripts/abprewrite.js

Issue 10000013: Update to current version of the SpiderMonkey shell, adjust for thedifferent handling of for loops… (Closed)
Patch Set: Created April 3, 2013, 11:24 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
« no previous file with comments | « autotest/abprewrite_source.js ('k') | utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/abprewrite.js
===================================================================
--- a/scripts/abprewrite.js
+++ b/scripts/abprewrite.js
@@ -350,16 +350,47 @@ function modifyForInStatement(ast)
}
// Make sure that the loop body is always wrapped in a block
ast.body = ensureBlock(ast.body);
return ast;
}
+function modifyLetStatement(ast)
+{
+ if (ast.body.type == "ForStatement" && ast.body.init == null)
+ {
+ // Convert back "for" loops written as "let" statements:
+ // let (foo = 0) for (; foo < bar; ++foo)
+ // {
+ // ...
+ // }
+ //
+ // Change into:
+ // for (let foo = 0; foo < bar; ++foo)
+ // {
+ // ...
+ // }
+ ast.body.init = {
+ type: "VariableDeclaration",
+ declarations: [],
+ kind: "let"
+ };
+ for (let i = 0; i < ast.head.length; i++)
+ {
+ ast.head[i].type = "VariableDeclarator";
+ ast.body.init.declarations.push(ast.head[i]);
+ }
+ return modifyForStatement(ast.body);
+ }
+
+ return ast;
+}
+
function modifyFunctionExpression(ast)
{
if (ast.expression)
{
// Convert expression closures:
// function() foo;
//
// Change into:
« no previous file with comments | « autotest/abprewrite_source.js ('k') | utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld