Small fixes for AST conversion.

This commit is contained in:
Ingvar Stepanyan
2014-08-02 13:18:27 +03:00
parent 87b72364a4
commit 05ba26c7c8

View File

@@ -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 + ")")(