Remove AST_ObjectComputedKeyVal
This commit is contained in:
committed by
Richard van Velzen
parent
b7bb706150
commit
7e80a979a7
@@ -401,9 +401,7 @@ var AST_ArrowParametersOrSeq = DEFNODE("ArrowParametersOrSeq", "expressions", {
|
||||
default: default_seen_above,
|
||||
names: ex.properties.map(to_fun_args)
|
||||
});
|
||||
} else if (ex instanceof AST_ObjectKeyVal ||
|
||||
ex instanceof AST_ObjectComputedKeyVal
|
||||
) {
|
||||
} else if (ex instanceof AST_ObjectKeyVal) {
|
||||
if (ex.key instanceof AST_SymbolRef) {
|
||||
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);
|
||||
|
||||
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", {
|
||||
$propdoc: {
|
||||
quote: "[string|undefined] the original quote character, if any",
|
||||
|
||||
@@ -1280,7 +1280,7 @@ merge(Compressor.prototype, {
|
||||
return false;
|
||||
});
|
||||
def(AST_ObjectProperty, function(compressor){
|
||||
if (this instanceof AST_ObjectComputedKeyVal &&
|
||||
if (this.key instanceof AST_ObjectKeyVal &&
|
||||
this.key.has_side_effects(compressor))
|
||||
return true;
|
||||
return this.value.has_side_effects(compressor);
|
||||
|
||||
@@ -1508,7 +1508,13 @@ function OutputStream(options) {
|
||||
) {
|
||||
self.print_property_name(self.key, self.quote, output);
|
||||
} 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();
|
||||
self.value.print(output);
|
||||
}
|
||||
@@ -1559,19 +1565,6 @@ function OutputStream(options) {
|
||||
}
|
||||
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){
|
||||
var def = this.definition();
|
||||
output.print_name(def ? def.mangled_name || def.name : this.name);
|
||||
|
||||
10
lib/parse.js
10
lib/parse.js
@@ -1507,14 +1507,6 @@ function parse($TEXT, options) {
|
||||
name: property_token,
|
||||
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 {
|
||||
expect(":");
|
||||
elements.push(new AST_ObjectKeyVal({
|
||||
@@ -1989,7 +1981,7 @@ function parse($TEXT, options) {
|
||||
|
||||
if (type == "punc" && start.value == "[") {
|
||||
expect(":");
|
||||
a.push(new AST_ObjectComputedKeyVal({
|
||||
a.push(new AST_ObjectKeyVal({
|
||||
start: start,
|
||||
key: name,
|
||||
value: expression(false),
|
||||
|
||||
Reference in New Issue
Block a user