deduplicate AST_Super & AST_This logic

This commit is contained in:
alexlamsl 2017-10-17 01:15:18 +08:00
parent a89f126db6
commit cb4229fe5a
3 changed files with 2 additions and 8 deletions

View File

@ -1042,7 +1042,7 @@ var AST_This = DEFNODE("This", null, {
var AST_Super = DEFNODE("Super", null, { var AST_Super = DEFNODE("Super", null, {
$documentation: "The `super` symbol", $documentation: "The `super` symbol",
}, AST_Symbol); }, AST_This);
var AST_Constant = DEFNODE("Constant", null, { var AST_Constant = DEFNODE("Constant", null, {
$documentation: "Base class for all constants", $documentation: "Base class for all constants",

View File

@ -610,7 +610,6 @@ merge(Compressor.prototype, {
} }
function is_lhs_read_only(lhs) { function is_lhs_read_only(lhs) {
if (lhs instanceof AST_Super) return true;
if (lhs instanceof AST_This) return true; if (lhs instanceof AST_This) return true;
if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda; if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
if (lhs instanceof AST_PropAccess) { if (lhs instanceof AST_PropAccess) {
@ -2143,7 +2142,6 @@ merge(Compressor.prototype, {
def(AST_EmptyStatement, return_false); def(AST_EmptyStatement, return_false);
def(AST_Constant, return_false); def(AST_Constant, return_false);
def(AST_Super, return_false);
def(AST_This, return_false); def(AST_This, return_false);
def(AST_Call, function(compressor){ def(AST_Call, function(compressor){
@ -2838,7 +2836,6 @@ merge(Compressor.prototype, {
def(AST_Node, return_this); def(AST_Node, return_this);
def(AST_Constant, return_null); def(AST_Constant, return_null);
def(AST_Super, return_null);
def(AST_This, return_null); def(AST_This, return_null);
def(AST_Call, function(compressor, first_in_statement){ def(AST_Call, function(compressor, first_in_statement){
if (!this.is_expr_pure(compressor)) { if (!this.is_expr_pure(compressor)) {
@ -4832,7 +4829,7 @@ merge(Compressor.prototype, {
var has_special_symbol = false; var has_special_symbol = false;
self.walk(new TreeWalker(function(node) { self.walk(new TreeWalker(function(node) {
if (has_special_symbol) return true; if (has_special_symbol) return true;
if (node instanceof AST_Super || node instanceof AST_This) { if (node instanceof AST_This) {
has_special_symbol = true; has_special_symbol = true;
return true; return true;
} }

View File

@ -1685,9 +1685,6 @@ function OutputStream(options) {
DEFPRINT(AST_Symbol, function (self, output) { DEFPRINT(AST_Symbol, function (self, output) {
self._do_print(output); self._do_print(output);
}); });
DEFPRINT(AST_SymbolDeclaration, function(self, output){
self._do_print(output);
});
DEFPRINT(AST_Hole, noop); DEFPRINT(AST_Hole, noop);
DEFPRINT(AST_This, function(self, output){ DEFPRINT(AST_This, function(self, output){
output.print("this"); output.print("this");