aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-06-23 12:54:38 -0400
committerRichard van Velzen <rvanvelzen1@gmail.com>2016-06-30 21:44:12 +0200
commit335b72df03fb6593d4bac8ddcde7d1b128eb3c4e (patch)
treeaa1759d78036e14db6aec30ecbbd121a674611a0 /lib
parent3a7d53f3cfa81fc8df3cd61c9adf0ce6c28ecd30 (diff)
downloadtracifyjs-335b72df03fb6593d4bac8ddcde7d1b128eb3c4e.tar.gz
tracifyjs-335b72df03fb6593d4bac8ddcde7d1b128eb3c4e.zip
Fix spidermonkey AST (ESTree) export and import, Array holes
Fixes: #1156 #1161 Also add test to exercise Uglify after spidermonkey export/import of itself.
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js2
-rw-r--r--lib/mozilla-ast.js17
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 4152bd06..527b8e62 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -190,7 +190,7 @@ merge(Compressor.prototype, {
if ((1 / val) < 0) {
return make_node(AST_UnaryPrefix, orig, {
operator: "-",
- expression: make_node(AST_Number, null, { value: -val })
+ expression: make_node(AST_Number, orig, { value: -val })
});
}
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index c1b2b683..34332215 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -94,6 +94,15 @@
return new AST_ObjectGetter(args);
}
},
+ ArrayExpression: function(M) {
+ return new AST_Array({
+ start : my_start_token(M),
+ end : my_end_token(M),
+ elements : M.elements.map(function(elem){
+ return elem === null ? new AST_Hole() : from_moz(elem);
+ })
+ });
+ },
ObjectExpression: function(M) {
return new AST_Object({
start : my_start_token(M),
@@ -206,7 +215,6 @@
map("CatchClause", AST_Catch, "param>argname, body%body");
map("ThisExpression", AST_This);
- map("ArrayExpression", AST_Array, "elements@elements");
map("FunctionExpression", AST_Function, "id>name, params@argnames, body%body");
map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
@@ -302,6 +310,13 @@
};
});
+ def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
+ return {
+ type: "ArrayExpression",
+ elements: M.elements.map(to_moz)
+ };
+ });
+
def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
return {
type: "ObjectExpression",