(AstNode property, int ptt)
| 4280 | } |
| 4281 | |
| 4282 | private ObjectProperty plainProperty(AstNode property, int ptt) throws IOException { |
| 4283 | // Support, e.g., |var {x, y} = o| as destructuring shorthand |
| 4284 | // for |var {x: x, y: y} = o|, as implemented in spidermonkey JS 1.8. |
| 4285 | int tt = peekToken(); |
| 4286 | if ((tt == Token.COMMA || tt == Token.RC) |
| 4287 | && ptt == Token.NAME |
| 4288 | && compilerEnv.getLanguageVersion() >= Context.VERSION_1_8) { |
| 4289 | if (!inDestructuringAssignment |
| 4290 | && compilerEnv.getLanguageVersion() < Context.VERSION_ES6) { |
| 4291 | reportError("msg.bad.object.init"); |
| 4292 | } |
| 4293 | AstNode nn = new Name(property.getPosition(), property.getString()); |
| 4294 | ObjectProperty pn = new ObjectProperty(); |
| 4295 | pn.setKeyAndValue(property, nn); |
| 4296 | return pn; |
| 4297 | } else if (tt == Token.ASSIGN) { |
| 4298 | /* we're in destructuring with defaults in a object literal; treat defaults as values */ |
| 4299 | ObjectProperty pn = new ObjectProperty(); |
| 4300 | consumeToken(); // consume the `=` |
| 4301 | Assignment defaultValue = new Assignment(property, assignExpr()); |
| 4302 | defaultValue.setType(Token.ASSIGN); |
| 4303 | pn.setKeyAndValue(property, defaultValue); |
| 4304 | return pn; |
| 4305 | } |
| 4306 | mustMatchToken(Token.COLON, "msg.no.colon.prop", true); |
| 4307 | ObjectProperty pn = new ObjectProperty(); |
| 4308 | pn.setKeyAndValue(property, assignExpr()); |
| 4309 | return pn; |
| 4310 | } |
| 4311 | |
| 4312 | private ObjectProperty methodDefinition( |
| 4313 | int pos, AstNode propName, int entryKind, boolean isGenerator, boolean isShorthand) |
no test coverage detected