[Pkg-javascript-commits] [uglifyjs] 05/26: Small fixes for AST conversion.

Jonas Smedegaard dr at jones.dk
Tue May 19 00:02:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag v2.4.16
in repository uglifyjs.

commit 05ba26c7c8b96bddeb7b97ef42b5c03283b8e72e
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Sat Aug 2 13:18:27 2014 +0300

    Small fixes for AST conversion.
---
 lib/mozilla-ast.js | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index d157730..0d2259d 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -282,7 +282,7 @@
             type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
             operator: M.operator,
             prefix: M instanceof AST_UnaryPrefix,
-            argument: to_moz(M.argument)
+            argument: to_moz(M.expression)
         };
     });
 
@@ -335,9 +335,21 @@
     });
 
     def_to_moz(AST_Constant, function To_Moz_Literal(M) {
+        var value = M.value;
+        if (typeof value === 'number' && (value < 0 || (value === 0 && 1 / value < 0))) {
+            return {
+                type: "UnaryExpression",
+                operator: "-",
+                prefix: true,
+                argument: {
+                    type: "Literal",
+                    value: -value
+                }
+            };
+        }
         return {
             type: "Literal",
-            value: M.value
+            value: value
         };
     });
 
@@ -422,8 +434,8 @@
         moz_to_me += "\n})\n}";
         me_to_moz += "\n}\n}";
 
-        moz_to_me = parse(moz_to_me).print_to_string({ beautify: true });
-        me_to_moz = parse(me_to_moz).print_to_string({ beautify: true });
+        //moz_to_me = parse(moz_to_me).print_to_string({ beautify: true });
+        //me_to_moz = parse(me_to_moz).print_to_string({ beautify: true });
         //console.log(moz_to_me);
 
         moz_to_me = new Function("my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list