(declaration bool)
| 299 | } |
| 300 | |
| 301 | func (self *_parser) parseClass(declaration bool) *ast.ClassLiteral { |
| 302 | if declaration && !self.scope.allowLet && self.token == token.CLASS { |
| 303 | self.errorUnexpectedToken(token.CLASS) |
| 304 | } |
| 305 | |
| 306 | node := &ast.ClassLiteral{ |
| 307 | Class: self.expect(token.CLASS), |
| 308 | } |
| 309 | |
| 310 | self.tokenToBindingId() |
| 311 | var name *ast.Identifier |
| 312 | if self.token == token.IDENTIFIER { |
| 313 | name = self.parseIdentifier() |
| 314 | } else if declaration { |
| 315 | // Use expect error handling |
| 316 | self.expect(token.IDENTIFIER) |
| 317 | } |
| 318 | |
| 319 | node.Name = name |
| 320 | |
| 321 | if self.token != token.LEFT_BRACE { |
| 322 | self.expect(token.EXTENDS) |
| 323 | node.SuperClass = self.parseLeftHandSideExpressionAllowCall() |
| 324 | } |
| 325 | |
| 326 | self.expect(token.LEFT_BRACE) |
| 327 | |
| 328 | for self.token != token.RIGHT_BRACE && self.token != token.EOF { |
| 329 | if self.token == token.SEMICOLON { |
| 330 | self.next() |
| 331 | continue |
| 332 | } |
| 333 | start := self.idx |
| 334 | static := false |
| 335 | if self.token == token.STATIC { |
| 336 | switch self.peek() { |
| 337 | case token.ASSIGN, token.SEMICOLON, token.RIGHT_BRACE, token.LEFT_PARENTHESIS: |
| 338 | // treat as identifier |
| 339 | default: |
| 340 | self.next() |
| 341 | if self.token == token.LEFT_BRACE { |
| 342 | b := &ast.ClassStaticBlock{ |
| 343 | Static: start, |
| 344 | } |
| 345 | b.Block, b.DeclarationList = self.parseFunctionBlock(false, true, false) |
| 346 | b.Source = self.slice(b.Block.LeftBrace, b.Block.Idx1()) |
| 347 | node.Body = append(node.Body, b) |
| 348 | continue |
| 349 | } |
| 350 | static = true |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | var kind ast.PropertyKind |
| 355 | var async bool |
| 356 | methodBodyStart := self.idx |
| 357 | if self.literal == "get" || self.literal == "set" { |
| 358 | if tok := self.peek(); tok != token.SEMICOLON && tok != token.LEFT_PARENTHESIS { |
no test coverage detected