[Pkg-mozext-commits] [adblock-plus] 293/464: Fixed decompiling of "a + (b + c)" - parentheses need to be kept in case we aren't dealing with numbers

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:26 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 0f1cefc476d93a0840c512bcef71fd7d38ea8aae
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Aug 27 20:17:45 2012 +0200

    Fixed decompiling of "a + (b + c)" - parentheses need to be kept in case we aren't dealing with numbers
---
 scripts/astDecompile.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/astDecompile.js b/scripts/astDecompile.js
index 088d73a..bcf91da 100644
--- a/scripts/astDecompile.js
+++ b/scripts/astDecompile.js
@@ -203,8 +203,8 @@ function getPrecedence(expr) {
   return 19;
 }
 
-function decompileExpr(expr, par) {
-  if (getPrecedence(expr) < getPrecedence(par))
+function decompileExpr(expr, par, forceParen) {
+  if (getPrecedence(expr) < getPrecedence(par) || (forceParen && getPrecedence(expr) == getPrecedence(par)))
     return "(" + decompileAST(expr) + ")";
   else
     return decompileAST(expr);
@@ -250,11 +250,11 @@ function decompileUnaryExpression(ast) {
 
 function decompileBinaryExpression(ast) {
   return decompileExpr(ast.left, ast) + " " + ast.operator +
-    " " + decompileExpr(ast.right, ast);
+    " " + decompileExpr(ast.right, ast, true);
 }
 
 function decompileAssignmentExpression(ast) {
-  return decompileExpr(ast.left, ast) + " " + ast.operator +
+  return decompileExpr(ast.left, ast, true) + " " + ast.operator +
     " " + decompileExpr(ast.right, ast);
 }
 
@@ -269,7 +269,7 @@ function decompileUpdateExpression(ast) {
 
 function decompileLogicalExpression(ast) {
   return decompileExpr(ast.left, ast) + " " + ast.operator +
-    " " + decompileExpr(ast.right, ast);
+    " " + decompileExpr(ast.right, ast, true);
 }
 
 function decompileConditionalExpression(ast) {

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