diff options
author | Ingvar Stepanyan <me@rreverser.com> | 2014-08-02 13:18:27 +0300 |
---|---|---|
committer | Ingvar Stepanyan <me@rreverser.com> | 2014-08-02 13:18:27 +0300 |
commit | 05ba26c7c8b96bddeb7b97ef42b5c03283b8e72e (patch) | |
tree | 13634409e5493e499206df088a1225ede8cda9d9 | |
parent | 87b72364a466e2dc065f88bbd0bd88c94b9e6519 (diff) | |
download | tracifyjs-05ba26c7c8b96bddeb7b97ef42b5c03283b8e72e.tar.gz tracifyjs-05ba26c7c8b96bddeb7b97ef42b5c03283b8e72e.zip |
Small fixes for AST conversion.
-rw-r--r-- | lib/mozilla-ast.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js index d1577308..0d2259de 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 + ")")( |