support shorthand key-symbol output (#4768)
This commit is contained in:
@@ -1607,7 +1607,14 @@ function OutputStream(options) {
|
||||
output.space();
|
||||
} : noop);
|
||||
});
|
||||
DEFPRINT(AST_DestructuredKeyVal, print_key_value);
|
||||
DEFPRINT(AST_DestructuredKeyVal, function(output) {
|
||||
var self = this;
|
||||
var key = print_property_key(self, output);
|
||||
var value = self.value;
|
||||
if (key && value instanceof AST_SymbolDeclaration && key == get_symbol_name(value)) return;
|
||||
output.colon();
|
||||
value.print(output);
|
||||
});
|
||||
DEFPRINT(AST_DestructuredObject, function(output) {
|
||||
var props = this.properties, len = props.length, rest = this.rest;
|
||||
if (len || rest) output.with_block(function() {
|
||||
@@ -1670,20 +1677,19 @@ function OutputStream(options) {
|
||||
output.print_string(key, quote);
|
||||
} else {
|
||||
output.print_name(key);
|
||||
return key;
|
||||
}
|
||||
} else {
|
||||
output.print_string(key, quote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function print_key_value(output) {
|
||||
DEFPRINT(AST_ObjectKeyVal, function(output) {
|
||||
var self = this;
|
||||
print_property_key(self, output);
|
||||
output.colon();
|
||||
self.value.print(output);
|
||||
}
|
||||
DEFPRINT(AST_ObjectKeyVal, print_key_value);
|
||||
});
|
||||
DEFPRINT(AST_ObjectMethod, function(output) {
|
||||
print_method(this, output);
|
||||
});
|
||||
@@ -1702,32 +1708,36 @@ function OutputStream(options) {
|
||||
}
|
||||
DEFPRINT(AST_ObjectGetter, print_accessor("get"));
|
||||
DEFPRINT(AST_ObjectSetter, print_accessor("set"));
|
||||
function print_symbol(self, output) {
|
||||
var def = self.definition();
|
||||
output.print_name(def && def.mangled_name || self.name);
|
||||
function get_symbol_name(sym) {
|
||||
var def = sym.definition();
|
||||
return def && def.mangled_name || sym.name;
|
||||
}
|
||||
DEFPRINT(AST_Symbol, function(output) {
|
||||
print_symbol(this, output);
|
||||
output.print_name(get_symbol_name(this));
|
||||
});
|
||||
DEFPRINT(AST_SymbolExport, function(output) {
|
||||
var self = this;
|
||||
print_symbol(self, output);
|
||||
if (self.alias) {
|
||||
var name = get_symbol_name(self);
|
||||
output.print_name(name);
|
||||
var alias = self.alias;
|
||||
if (alias != name) {
|
||||
output.space();
|
||||
output.print("as");
|
||||
output.space();
|
||||
output.print_name(self.alias);
|
||||
output.print_name(alias);
|
||||
}
|
||||
});
|
||||
DEFPRINT(AST_SymbolImport, function(output) {
|
||||
var self = this;
|
||||
if (self.key) {
|
||||
output.print_name(self.key);
|
||||
var name = get_symbol_name(self);
|
||||
var key = self.key;
|
||||
if (key && key != name) {
|
||||
output.print_name(key);
|
||||
output.space();
|
||||
output.print("as");
|
||||
output.space();
|
||||
}
|
||||
print_symbol(self, output);
|
||||
output.print_name(name);
|
||||
});
|
||||
DEFPRINT(AST_Hole, noop);
|
||||
DEFPRINT(AST_Template, function(output) {
|
||||
|
||||
Reference in New Issue
Block a user