[Pkg-mozext-commits] [adblock-plus] 175/464: Renamed script for modules into abprewrite-module.js, abprewrite.js doesn't wrap the code in a module
David Prévot
taffit at moszumanska.debian.org
Tue Jul 22 20:44:14 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 1a76cc95200242fe05ac6d2071d4757dcc9d999f
Author: Wladimir Palant <trev at adblockplus.org>
Date: Tue Dec 6 09:04:21 2011 +0100
Renamed script for modules into abprewrite-module.js, abprewrite.js doesn't wrap the code in a module
--HG--
rename : scripts/abprewrite.js => scripts/abprewrite-module.js
---
scripts/abprewrite-module.js | 7 +++
scripts/abprewrite.js | 105 ++++++++++++++++++++++---------------------
2 files changed, 61 insertions(+), 51 deletions(-)
diff --git a/scripts/abprewrite-module.js b/scripts/abprewrite-module.js
new file mode 100644
index 0000000..1139014
--- /dev/null
+++ b/scripts/abprewrite-module.js
@@ -0,0 +1,7 @@
+// This script rewrites AST to be compatible with JavaScript 1.5 and decompiles
+// the modified tree then
+
+var isModule = true;
+
+include("decompile.js");
+include("abprewrite.js");
diff --git a/scripts/abprewrite.js b/scripts/abprewrite.js
index 4208d87..8ec6248 100644
--- a/scripts/abprewrite.js
+++ b/scripts/abprewrite.js
@@ -460,63 +460,66 @@ let modifier =
}));
}
- // Add patch function call at the end of the module:
- // if (typeof _patchFunc44 != "undefined")
- // (eval("(" + _patchFunc44.toString()) + ")()");
- let patchFuncName = "_patchFunc" + this._tempVarCount++;
- stmt.sourceElements.push(new Node({
- type: "IfStatement",
- cond: new BinaryExpression("!=", new UnaryExpression("typeof", new IdentifierExpression(patchFuncName)), "undefined"),
- body: new ExpressionStatement(new Node({
- type: "CallExpression",
- precedence: 2,
- func: new IdentifierExpression("eval"),
- arguments: [new BinaryExpression("+", new BinaryExpression("+", "(", new Node({
+ if (typeof isModule == "boolean" && isModule)
+ {
+ // Add patch function call at the end of the module:
+ // if (typeof _patchFunc44 != "undefined")
+ // (eval("(" + _patchFunc44.toString()) + ")()");
+ let patchFuncName = "_patchFunc" + this._tempVarCount++;
+ stmt.sourceElements.push(new Node({
+ type: "IfStatement",
+ cond: new BinaryExpression("!=", new UnaryExpression("typeof", new IdentifierExpression(patchFuncName)), "undefined"),
+ body: new ExpressionStatement(new Node({
type: "CallExpression",
precedence: 2,
- arguments: [],
- func: new MemberExpression(patchFuncName, "toString", true),
- })), ")()")],
- }))
- }));
-
- // Add exported symbols at the end of the module:
- // window.exportedSymbol1 = exportedSymbol1;
- // window.exportedSymbol2 = exportedSymbol2;
- // window.exportedSymbol3 = exportedSymbol3;
- if (this._exportedSymbols.length > 0)
- {
- for each (let symbol in this._exportedSymbols)
+ func: new IdentifierExpression("eval"),
+ arguments: [new BinaryExpression("+", new BinaryExpression("+", "(", new Node({
+ type: "CallExpression",
+ precedence: 2,
+ arguments: [],
+ func: new MemberExpression(patchFuncName, "toString", true),
+ })), ")()")],
+ }))
+ }));
+
+ // Add exported symbols at the end of the module:
+ // window.exportedSymbol1 = exportedSymbol1;
+ // window.exportedSymbol2 = exportedSymbol2;
+ // window.exportedSymbol3 = exportedSymbol3;
+ if (this._exportedSymbols.length > 0)
{
- stmt.sourceElements.push(new ExpressionStatement(new Node({
- type: "AssignmentExpression",
- precedence: 16,
- operator: "",
- lhs: new MemberExpression("window", symbol, true),
- rhs: new IdentifierExpression(symbol),
- })));
+ for each (let symbol in this._exportedSymbols)
+ {
+ stmt.sourceElements.push(new ExpressionStatement(new Node({
+ type: "AssignmentExpression",
+ precedence: 16,
+ operator: "",
+ lhs: new MemberExpression("window", symbol, true),
+ rhs: new IdentifierExpression(symbol),
+ })));
+ }
}
- }
- // Wrap the entire module into a function to give it an independent scope:
- // (function(_patchFunc44) {
- // ...
- // })(window.ModuleNamePatch);
- stmt.sourceElements = [new ExpressionStatement(new Node({
- type: "CallExpression",
- precedence: 2,
- arguments: [new MemberExpression("window", this._filename + "Patch", true)],
- func: new Node({
- type: "FunctionDeclaration",
- precedence: Infinity,
- name: "",
- arguments: [new IdentifierExpression(patchFuncName)],
- body: new Node({
- type: "BlockStatement",
- statements: stmt.sourceElements
+ // Wrap the entire module into a function to give it an independent scope:
+ // (function(_patchFunc44) {
+ // ...
+ // })(window.ModuleNamePatch);
+ stmt.sourceElements = [new ExpressionStatement(new Node({
+ type: "CallExpression",
+ precedence: 2,
+ arguments: [new MemberExpression("window", this._filename + "Patch", true)],
+ func: new Node({
+ type: "FunctionDeclaration",
+ precedence: Infinity,
+ name: "",
+ arguments: [new IdentifierExpression(patchFuncName)],
+ body: new Node({
+ type: "BlockStatement",
+ statements: stmt.sourceElements
+ })
})
- })
- }))];
+ }))];
+ }
},
visitVarStatement: function(stmt)
--
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