Fix computed getters + cleanup AST
This commit is contained in:
@@ -449,7 +449,7 @@ var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator",
|
||||
$documentation: "Base class for functions",
|
||||
$propdoc: {
|
||||
is_generator: "is generatorFn or not",
|
||||
name: "[AST_SymbolDeclaration?] the name of this function",
|
||||
name: "[AST_SymbolDeclaration?|AST_Node] the name of this function or computed expression",
|
||||
argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion*] array of function arguments, destructurings, or expanding arguments",
|
||||
uses_arguments: "[boolean/S] tells whether this function accesses the arguments array"
|
||||
},
|
||||
@@ -996,7 +996,7 @@ var AST_Object = DEFNODE("Object", "properties", {
|
||||
var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
|
||||
$documentation: "Base class for literal object properties",
|
||||
$propdoc: {
|
||||
key: "[string] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",
|
||||
key: "[string|AST_Node] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",
|
||||
value: "[AST_Node] property value. For setters and getters this is an AST_Function."
|
||||
},
|
||||
_walk: function(visitor) {
|
||||
|
||||
@@ -1457,7 +1457,13 @@ function OutputStream(options) {
|
||||
}
|
||||
output.print("set");
|
||||
output.space();
|
||||
self.key.print(output);
|
||||
if (self.key instanceof AST_SymbolMethod) {
|
||||
self.key.print(output);
|
||||
} else {
|
||||
output.with_square(function() {
|
||||
self.key.print(output);
|
||||
});
|
||||
}
|
||||
self.value._do_print(output, true);
|
||||
});
|
||||
DEFPRINT(AST_ObjectGetter, function(self, output){
|
||||
@@ -1467,7 +1473,13 @@ function OutputStream(options) {
|
||||
}
|
||||
output.print("get");
|
||||
output.space();
|
||||
self.key.print(output);
|
||||
if (self.key instanceof AST_SymbolMethod) {
|
||||
self.key.print(output);
|
||||
} else {
|
||||
output.with_square(function() {
|
||||
self.key.print(output);
|
||||
});
|
||||
}
|
||||
self.value._do_print(output, true);
|
||||
});
|
||||
DEFPRINT(AST_ObjectComputedKeyVal, function(self, output) {
|
||||
@@ -1493,15 +1505,6 @@ function OutputStream(options) {
|
||||
self.default.print(output)
|
||||
}
|
||||
});
|
||||
DEFPRINT(AST_SymbolMethod, function(self, output) {
|
||||
if (self.name instanceof AST_Node) {
|
||||
output.with_square(function() {
|
||||
self.name.print(output);
|
||||
});
|
||||
} else {
|
||||
self._do_print(output);
|
||||
}
|
||||
});
|
||||
DEFPRINT(AST_Undefined, function(self, output){
|
||||
output.print("void 0");
|
||||
});
|
||||
|
||||
@@ -240,24 +240,5 @@ getter_setter_with_computed_value: {
|
||||
}
|
||||
}
|
||||
}
|
||||
expect: {
|
||||
class C {
|
||||
get ['a']() {
|
||||
return 'A';
|
||||
}
|
||||
set ['a'](value) {
|
||||
do_something(a);
|
||||
}
|
||||
}
|
||||
var x = {
|
||||
get [a.b]() {
|
||||
return 42;
|
||||
}
|
||||
};
|
||||
class MyArray extends Array {
|
||||
get [Symbol.species]() {
|
||||
return Array;
|
||||
}
|
||||
}
|
||||
}
|
||||
expect_exact: 'class C{get["a"](){return"A"}set["a"](value){do_something(a)}}var x={get[a.b](){return 42}};class MyArray extends Array{get[Symbol.species](){return Array}}'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user