|
972 | 972 | return result; |
973 | 973 | }; |
974 | 974 |
|
975 | | - CodeGenerator.prototype.generatePropertyKey = function (expr, computed, value) { |
| 975 | + CodeGenerator.prototype.generatePropertyKey = function (expr, computed) { |
976 | 976 | var result = []; |
977 | 977 |
|
978 | 978 | if (computed) { |
979 | 979 | result.push('['); |
980 | 980 | } |
981 | 981 |
|
982 | | - if (value.type === 'AssignmentPattern') { |
983 | | - result.push(this.AssignmentPattern(value, Precedence.Sequence, E_TTT)); |
984 | | - } else { |
985 | | - result.push(this.generateExpression(expr, Precedence.Sequence, E_TTT)); |
986 | | - } |
| 982 | + result.push(this.generateExpression(expr, Precedence.Sequence, E_TTT)); |
987 | 983 |
|
988 | 984 | if (computed) { |
989 | 985 | result.push(']'); |
|
2110 | 2106 | } |
2111 | 2107 | if (expr.kind === 'get' || expr.kind === 'set') { |
2112 | 2108 | fragment = [ |
2113 | | - join(expr.kind, this.generatePropertyKey(expr.key, expr.computed, expr.value)), |
| 2109 | + join(expr.kind, this.generatePropertyKey(expr.key, expr.computed)), |
2114 | 2110 | this.generateFunctionBody(expr.value) |
2115 | 2111 | ]; |
2116 | 2112 | } else { |
2117 | 2113 | fragment = [ |
2118 | 2114 | generateMethodPrefix(expr), |
2119 | | - this.generatePropertyKey(expr.key, expr.computed, expr.value), |
| 2115 | + this.generatePropertyKey(expr.key, expr.computed), |
2120 | 2116 | this.generateFunctionBody(expr.value) |
2121 | 2117 | ]; |
2122 | 2118 | } |
|
2127 | 2123 | if (expr.kind === 'get' || expr.kind === 'set') { |
2128 | 2124 | return [ |
2129 | 2125 | expr.kind, noEmptySpace(), |
2130 | | - this.generatePropertyKey(expr.key, expr.computed, expr.value), |
| 2126 | + this.generatePropertyKey(expr.key, expr.computed), |
2131 | 2127 | this.generateFunctionBody(expr.value) |
2132 | 2128 | ]; |
2133 | 2129 | } |
2134 | 2130 |
|
2135 | 2131 | if (expr.shorthand) { |
2136 | | - return this.generatePropertyKey(expr.key, expr.computed, expr.value); |
| 2132 | + if (expr.value.type === "AssignmentPattern") { |
| 2133 | + return this.AssignmentPattern(expr.value, Precedence.Sequence, E_TTT); |
| 2134 | + } |
| 2135 | + return this.generatePropertyKey(expr.key, expr.computed); |
2137 | 2136 | } |
2138 | 2137 |
|
2139 | 2138 | if (expr.method) { |
2140 | 2139 | return [ |
2141 | 2140 | generateMethodPrefix(expr), |
2142 | | - this.generatePropertyKey(expr.key, expr.computed, expr.value), |
| 2141 | + this.generatePropertyKey(expr.key, expr.computed), |
2143 | 2142 | this.generateFunctionBody(expr.value) |
2144 | 2143 | ]; |
2145 | 2144 | } |
2146 | 2145 |
|
2147 | 2146 | return [ |
2148 | | - this.generatePropertyKey(expr.key, expr.computed, expr.value), |
| 2147 | + this.generatePropertyKey(expr.key, expr.computed), |
2149 | 2148 | ':' + space, |
2150 | 2149 | this.generateExpression(expr.value, Precedence.Assignment, E_TTT) |
2151 | 2150 | ]; |
|
0 commit comments