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: |