[Pkg-javascript-commits] [uglifyjs] 35/190: Fix handling of "use asm" when no command line flags are passed to uglifyjs. SCOPE_IS_NEEDED is unconditionally true now. Refactored floating point literal parsing to be more in keeping with the AST class design.

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:10 UTC 2016


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

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit 4d2f7d83af839d78a381fc4faa79dbea3b2c8070
Author: kzc <zaxxon2011 at gmail.com>
Date:   Wed Oct 7 13:10:53 2015 -0400

    Fix handling of "use asm" when no command line flags are passed to uglifyjs. SCOPE_IS_NEEDED is unconditionally true now. Refactored floating point literal parsing to be more in keeping with the AST class design.
---
 bin/uglifyjs  |  2 +-
 lib/ast.js    |  5 +++--
 lib/output.js |  6 ++++--
 lib/parse.js  | 11 ++++++-----
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/bin/uglifyjs b/bin/uglifyjs
index 00342b8..eb970c6 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -401,7 +401,7 @@ async.eachLimit(files, 1, function (file, cb) {
         writeNameCache("props", cache);
     })();
 
-    var SCOPE_IS_NEEDED = COMPRESS || MANGLE || BEAUTIFY || ARGS.lint;
+    var SCOPE_IS_NEEDED = true;
     var TL_CACHE = readNameCache("vars");
 
     if (SCOPE_IS_NEEDED) {
diff --git a/lib/ast.js b/lib/ast.js
index c5ec816..e795284 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -864,10 +864,11 @@ var AST_String = DEFNODE("String", "value quote", {
     }
 }, AST_Constant);
 
-var AST_Number = DEFNODE("Number", "value", {
+var AST_Number = DEFNODE("Number", "value literal", {
     $documentation: "A number literal",
     $propdoc: {
-        value: "[number] the numeric value"
+        value: "[number] the numeric value",
+        literal: "[string] numeric value as string (optional)"
     }
 }, AST_Constant);
 
diff --git a/lib/output.js b/lib/output.js
index 06c1e42..c15f3b2 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -1158,8 +1158,10 @@ function OutputStream(options) {
         output.print_string(self.getValue(), self.quote);
     });
     DEFPRINT(AST_Number, function(self, output){
-        if (self.value_string !== undefined && self.scope && self.scope.has_directive('use asm')) {
-            output.print(self.value_string);
+        if (self.literal !== undefined
+            && +self.literal === self.value  /* paranoid check */
+            && self.scope && self.scope.has_directive('use asm')) {
+            output.print(self.literal);
         } else {
             output.print(make_num(self.getValue()));
         }
diff --git a/lib/parse.js b/lib/parse.js
index 830b522..1ab0358 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -335,7 +335,11 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
         if (prefix) num = prefix + num;
         var valid = parse_js_number(num);
         if (!isNaN(valid)) {
-            return token("num", valid);
+            var tok = token("num", valid);
+            if (num.indexOf('.') >= 0) {
+                tok.literal = num;
+            }
+            return tok;
         } else {
             parse_error("Invalid syntax: " + num);
         }
@@ -1148,10 +1152,7 @@ function parse($TEXT, options) {
             ret = _make_symbol(AST_SymbolRef);
             break;
           case "num":
-            ret = new AST_Number({ start: tok, end: tok, value: tok.value });
-            var value_string = $TEXT.substring(tok.pos, tok.endpos);
-            if (value_string.indexOf('.') >= 0)
-                ret.value_string = value_string;
+            ret = new AST_Number({ start: tok, end: tok, value: tok.value, literal: tok.literal });
             break;
           case "string":
             ret = new AST_String({

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