[Pkg-javascript-commits] [uglifyjs] 64/190: Fix output for "use asm" code from SpiderMonkey AST
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:13 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 08623aa6a700f62e6b096917d31b0b7a2705d281
Author: Mihai Bazon <mihai.bazon at gmail.com>
Date: Thu Nov 12 12:18:25 2015 +0200
Fix output for "use asm" code from SpiderMonkey AST
(will only work properly if the SM tree contains "raw" properties for
Literal number nodes)
---
lib/ast.js | 2 +-
lib/mozilla-ast.js | 18 ++++++++++++++----
lib/output.js | 4 ++--
lib/parse.js | 2 +-
4 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/ast.js b/lib/ast.js
index f5225d7..0ac14dc 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -85,7 +85,7 @@ function DEFNODE(type, props, methods, base) {
return ctor;
};
-var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file literal", {
+var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file raw", {
}, null);
var AST_Node = DEFNODE("Node", "start end", {
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index 2bb469f..c1b2b68 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -363,13 +363,15 @@
prefix: true,
argument: {
type: "Literal",
- value: -value
+ value: -value,
+ raw: M.start.raw
}
};
}
return {
type: "Literal",
- value: value
+ value: value,
+ raw: M.start.raw
};
});
@@ -389,6 +391,12 @@
/* -----[ tools ]----- */
+ function raw_token(moznode) {
+ if (moznode.type == "Literal") {
+ return moznode.raw != null ? moznode.raw : moznode.value + "";
+ }
+ }
+
function my_start_token(moznode) {
var loc = moznode.loc, start = loc && loc.start;
var range = moznode.range;
@@ -399,7 +407,8 @@
pos : range ? range[0] : moznode.start,
endline : start && start.line,
endcol : start && start.column,
- endpos : range ? range[0] : moznode.start
+ endpos : range ? range[0] : moznode.start,
+ raw : raw_token(moznode),
});
};
@@ -413,7 +422,8 @@
pos : range ? range[1] : moznode.end,
endline : end && end.line,
endcol : end && end.column,
- endpos : range ? range[1] : moznode.end
+ endpos : range ? range[1] : moznode.end,
+ raw : raw_token(moznode),
});
};
diff --git a/lib/output.js b/lib/output.js
index 9dadf0e..f10c918 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -1178,8 +1178,8 @@ function OutputStream(options) {
output.print_string(self.getValue(), self.quote);
});
DEFPRINT(AST_Number, function(self, output){
- if (use_asm) {
- output.print(self.start.literal);
+ if (use_asm && self.start.raw != null) {
+ output.print(self.start.raw);
} else {
output.print(make_num(self.getValue()));
}
diff --git a/lib/parse.js b/lib/parse.js
index 901d10a..de27d98 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -286,7 +286,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
file : filename
};
if (/^(?:num|string|regexp)$/i.test(type)) {
- ret.literal = $TEXT.substring(ret.pos, ret.endpos);
+ ret.raw = $TEXT.substring(ret.pos, ret.endpos);
}
if (!is_comment) {
ret.comments_before = S.comments_before;
--
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