Improve support for binding pattern

Including improvements for parameters, variable assignment and
catch parameter.
This commit is contained in:
Anthony Van de Gejuchte
2016-08-20 22:32:29 +02:00
parent 1db50c3b16
commit 13ed445607
14 changed files with 727 additions and 312 deletions

View File

@@ -595,6 +595,10 @@ function OutputStream(options) {
|| p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
|| p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
|| p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
|| (p instanceof AST_SymbolConst && p.default === this) // const { xCover = (0, function() {}) }
|| (p instanceof AST_SymbolLet && p.default === this) // let { xCover = (0, function() {}) }
|| (p instanceof AST_SymbolVar && p.default === this) // var { xCover = (0, function() {}) }
|| (p instanceof AST_SymbolCatch && p.default === this) // } catch (xCover = (0, function() {}) ) {
|| p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
* ==> 20 (side effect, set a := 10 and b := 20) */
|| p instanceof AST_Arrow // x => (x, x)
@@ -1451,6 +1455,12 @@ function OutputStream(options) {
self.print_property_name(self.key, self.quote, output);
output.colon();
self.value.print(output);
if (self.default) {
output.space();
output.print('=');
output.space();
self.default.print(output);
}
});
AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, self, output) {
if (self.static) {
@@ -1498,6 +1508,12 @@ function OutputStream(options) {
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();