()
| 4025 | private static final int METHOD_ENTRY = 8; |
| 4026 | |
| 4027 | private ObjectLiteral objectLiteral() throws IOException { |
| 4028 | int pos = ts.tokenBeg, lineno = lineNumber(), column = columnNumber(); |
| 4029 | int afterComma = -1; |
| 4030 | List<AbstractObjectProperty> elems = new ArrayList<>(); |
| 4031 | Set<String> getterNames = null; |
| 4032 | Set<String> setterNames = null; |
| 4033 | if (this.inUseStrictDirective) { |
| 4034 | getterNames = new HashSet<>(); |
| 4035 | setterNames = new HashSet<>(); |
| 4036 | } |
| 4037 | Comment objJsdocNode = getAndResetJsDoc(); |
| 4038 | boolean objectLiteralDestructuringDefault = false; |
| 4039 | commaLoop: |
| 4040 | for (; ; ) { |
| 4041 | String propertyName = null; |
| 4042 | int entryKind = PROP_ENTRY; |
| 4043 | int tt = peekToken(); |
| 4044 | Comment jsdocNode = getAndResetJsDoc(); |
| 4045 | if (tt == Token.COMMENT) { |
| 4046 | consumeToken(); |
| 4047 | tt = peekUntilNonComment(tt); |
| 4048 | } |
| 4049 | if (tt == Token.RC) { |
| 4050 | if (afterComma != -1) warnTrailingComma(pos, elems, afterComma); |
| 4051 | break commaLoop; |
| 4052 | } |
| 4053 | AstNode pname = objliteralProperty(); |
| 4054 | if (pname == null) { |
| 4055 | reportError("msg.bad.prop"); |
| 4056 | } else if (pname instanceof Spread) { |
| 4057 | AstNode spreadExpr = ((Spread) pname).getExpression(); |
| 4058 | if (spreadExpr instanceof Name || spreadExpr instanceof StringLiteral) { |
| 4059 | // For complicated reasons, parsing a name does not advance the token |
| 4060 | spreadExpr.setLineColumnNumber(lineNumber(), columnNumber()); |
| 4061 | } |
| 4062 | |
| 4063 | SpreadObjectProperty spreadObjectProperty = |
| 4064 | new SpreadObjectProperty((Spread) pname); |
| 4065 | elems.add(spreadObjectProperty); |
| 4066 | } else { |
| 4067 | propertyName = ts.getString(); |
| 4068 | int ppos = ts.tokenBeg; |
| 4069 | consumeToken(); |
| 4070 | if (pname instanceof Name || pname instanceof StringLiteral) { |
| 4071 | // For complicated reasons, parsing a name does not advance the token |
| 4072 | pname.setLineColumnNumber(lineNumber(), columnNumber()); |
| 4073 | } else if (pname instanceof GeneratorMethodDefinition) { |
| 4074 | // Same as above |
| 4075 | ((GeneratorMethodDefinition) pname) |
| 4076 | .getMethodName() |
| 4077 | .setLineColumnNumber(lineNumber(), columnNumber()); |
| 4078 | } |
| 4079 | |
| 4080 | // This code path needs to handle both destructuring object |
| 4081 | // literals like: |
| 4082 | // var {get, b} = {get: 1, b: 2}; |
| 4083 | // and getters like: |
| 4084 | // var x = {get 1() { return 2; }; |
no test coverage detected