[Pkg-mozext-commits] [adblock-plus] 115/464: Fixed wrong rewriting of for each loops where loop body isn't a block statement
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 22a4f7e871c0ac6c529596f575e8983aa30f4a9e
Author: Wladimir Palant <trev at adblockplus.org>
Date: Thu Dec 9 18:43:00 2010 +0100
Fixed wrong rewriting of for each loops where loop body isn't a block statement
---
scripts/abprewrite.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/abprewrite.js b/scripts/abprewrite.js
index 0f9063c..937558a 100644
--- a/scripts/abprewrite.js
+++ b/scripts/abprewrite.js
@@ -314,10 +314,16 @@ let modifier =
let loopVar = stmt.itervar.variables[0].name;
let loopIndex = "_loopIndex" + this._tempVarCount++;
- if (!stmt.body || !stmt.body.type == "BlockStatement")
- throw "Unexpected: loop body isn't a block statement";
- if (!stmt.body.statements)
- stmt.body.statements = [];
+ if (stmt.body.type != "BlockStatement")
+ {
+ let oldBody = stmt.body;
+ stmt.body = new Node({
+ type: "BlockStatement",
+ statements: []
+ });
+ if (oldBody)
+ stmt.body.statements.push(oldBody);
+ }
stmt.body.statements.unshift(new VarStatement(loopVar, new MemberExpression(stmt.iterrange, new IdentifierExpression(loopIndex))));
return [new Node({
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list