added AST_NaN (output as 0/0)
This commit is contained in:
@@ -661,6 +661,11 @@ var AST_Null = DEFNODE("Null", null, {
|
|||||||
value: null
|
value: null
|
||||||
}, AST_Atom);
|
}, AST_Atom);
|
||||||
|
|
||||||
|
var AST_NaN = DEFNODE("NaN", null, {
|
||||||
|
$documentation: "The impossible value",
|
||||||
|
value: 0/0
|
||||||
|
}, AST_Atom);
|
||||||
|
|
||||||
var AST_Undefined = DEFNODE("Undefined", null, {
|
var AST_Undefined = DEFNODE("Undefined", null, {
|
||||||
$documentation: "The `undefined` value",
|
$documentation: "The `undefined` value",
|
||||||
value: (function(){}())
|
value: (function(){}())
|
||||||
|
|||||||
@@ -526,9 +526,9 @@ function Compressor(options, false_by_default) {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "number":
|
case "number":
|
||||||
ast = make_node(AST_Number, this, {
|
ast = make_node(isNaN(val) ? AST_NaN : AST_Number, this, {
|
||||||
value: val
|
value: val
|
||||||
});
|
}).optimize(compressor);
|
||||||
break;
|
break;
|
||||||
case "boolean":
|
case "boolean":
|
||||||
ast = make_node(val ? AST_True : AST_False, this);
|
ast = make_node(val ? AST_True : AST_False, this);
|
||||||
@@ -1501,8 +1501,11 @@ function Compressor(options, false_by_default) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
AST_SymbolRef.DEFMETHOD("optimize", function(compressor){
|
AST_SymbolRef.DEFMETHOD("optimize", function(compressor){
|
||||||
if (this.name == "undefined" && this.undeclared()) {
|
if (this.undeclared()) switch (this.name) {
|
||||||
|
case "undefined":
|
||||||
return make_node(AST_Undefined, this).optimize(compressor);
|
return make_node(AST_Undefined, this).optimize(compressor);
|
||||||
|
case "NaN":
|
||||||
|
return make_node(AST_NaN, this).optimize(compressor);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -894,6 +894,9 @@ function OutputStream(options) {
|
|||||||
output.print("void 0");
|
output.print("void 0");
|
||||||
//output.print("[][0]");
|
//output.print("[][0]");
|
||||||
});
|
});
|
||||||
|
DEFPRINT(AST_NaN, function(self, output){
|
||||||
|
output.print("0/0");
|
||||||
|
});
|
||||||
DEFPRINT(AST_This, function(self, output){
|
DEFPRINT(AST_This, function(self, output){
|
||||||
output.print("this");
|
output.print("this");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user