Remove AST_ObjectComputedKeyVal

This commit is contained in:
Anthony Van de Gejuchte
2016-10-18 16:18:34 +02:00
committed by Richard van Velzen
parent b7bb706150
commit 7e80a979a7
4 changed files with 10 additions and 31 deletions

View File

@@ -401,9 +401,7 @@ var AST_ArrowParametersOrSeq = DEFNODE("ArrowParametersOrSeq", "expressions", {
default: default_seen_above, default: default_seen_above,
names: ex.properties.map(to_fun_args) names: ex.properties.map(to_fun_args)
}); });
} else if (ex instanceof AST_ObjectKeyVal || } else if (ex instanceof AST_ObjectKeyVal) {
ex instanceof AST_ObjectComputedKeyVal
) {
if (ex.key instanceof AST_SymbolRef) { if (ex.key instanceof AST_SymbolRef) {
ex.key = to_fun_args(ex.key, 0, [ex.key], ex.default); ex.key = to_fun_args(ex.key, 0, [ex.key], ex.default);
} }
@@ -1014,10 +1012,6 @@ var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote default", {
} }
}, AST_ObjectProperty); }, AST_ObjectProperty);
var AST_ObjectComputedKeyVal = DEFNODE("ObjectComputedKeyVal", null, {
$documentation: "An object property whose key is computed. Like `[Symbol.iterator]: function...` or `[routes.homepage]: renderHomepage`",
}, AST_ObjectProperty);
var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", { var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
$propdoc: { $propdoc: {
quote: "[string|undefined] the original quote character, if any", quote: "[string|undefined] the original quote character, if any",

View File

@@ -1280,7 +1280,7 @@ merge(Compressor.prototype, {
return false; return false;
}); });
def(AST_ObjectProperty, function(compressor){ def(AST_ObjectProperty, function(compressor){
if (this instanceof AST_ObjectComputedKeyVal && if (this.key instanceof AST_ObjectKeyVal &&
this.key.has_side_effects(compressor)) this.key.has_side_effects(compressor))
return true; return true;
return this.value.has_side_effects(compressor); return this.value.has_side_effects(compressor);

View File

@@ -1508,7 +1508,13 @@ function OutputStream(options) {
) { ) {
self.print_property_name(self.key, self.quote, output); self.print_property_name(self.key, self.quote, output);
} else { } else {
self.print_property_name(self.key, self.quote, output); if (!(self.key instanceof AST_Node) || self.key instanceof AST_Symbol) {
self.print_property_name(self.key, self.quote, output);
} else {
output.with_square(function() {
self.key.print(output);
});
}
output.colon(); output.colon();
self.value.print(output); self.value.print(output);
} }
@@ -1559,19 +1565,6 @@ function OutputStream(options) {
} }
self.value._do_print(output, true); self.value._do_print(output, true);
}); });
DEFPRINT(AST_ObjectComputedKeyVal, function(self, output) {
output.print("[");
self.key.print(output);
output.print("]:");
output.space();
self.value.print(output);
if (self.default) {
output.space();
output.print('=');
output.space();
self.default.print(output);
}
});
AST_Symbol.DEFMETHOD("_do_print", function(output){ AST_Symbol.DEFMETHOD("_do_print", function(output){
var def = this.definition(); var def = this.definition();
output.print_name(def ? def.mangled_name || def.name : this.name); output.print_name(def ? def.mangled_name || def.name : this.name);

View File

@@ -1507,14 +1507,6 @@ function parse($TEXT, options) {
name: property_token, name: property_token,
end: prev() end: prev()
})); }));
} else if (property instanceof AST_Node) {
expect(":");
elements.push(new AST_ObjectComputedKeyVal({
start: property_token,
key: property,
value: binding_element(used_parameters, symbol_type),
end: prev()
}));
} else { } else {
expect(":"); expect(":");
elements.push(new AST_ObjectKeyVal({ elements.push(new AST_ObjectKeyVal({
@@ -1989,7 +1981,7 @@ function parse($TEXT, options) {
if (type == "punc" && start.value == "[") { if (type == "punc" && start.value == "[") {
expect(":"); expect(":");
a.push(new AST_ObjectComputedKeyVal({ a.push(new AST_ObjectKeyVal({
start: start, start: start,
key: name, key: name,
value: expression(false), value: expression(false),