(token, key, computed, node)
| 2425 | // In order to avoid back tracking, it returns `null` if the position is not a MethodDefinition and the caller |
| 2426 | // is responsible to visit other options. |
| 2427 | function tryParseMethodDefinition(token, key, computed, node) { |
| 2428 | var value, options, methodNode; |
| 2429 | |
| 2430 | if (token.type === Token.Identifier) { |
| 2431 | // check for `get` and `set`; |
| 2432 | |
| 2433 | if (token.value === 'get' && lookaheadPropertyName()) { |
| 2434 | computed = match('['); |
| 2435 | key = parseObjectPropertyKey(); |
| 2436 | methodNode = new Node(); |
| 2437 | expect('('); |
| 2438 | expect(')'); |
| 2439 | value = parsePropertyFunction(methodNode, { |
| 2440 | params: [], |
| 2441 | defaults: [], |
| 2442 | stricted: null, |
| 2443 | firstRestricted: null, |
| 2444 | message: null |
| 2445 | }); |
| 2446 | return node.finishProperty('get', key, computed, value, false, false); |
| 2447 | } else if (token.value === 'set' && lookaheadPropertyName()) { |
| 2448 | computed = match('['); |
| 2449 | key = parseObjectPropertyKey(); |
| 2450 | methodNode = new Node(); |
| 2451 | expect('('); |
| 2452 | |
| 2453 | options = { |
| 2454 | params: [], |
| 2455 | defaultCount: 0, |
| 2456 | defaults: [], |
| 2457 | firstRestricted: null, |
| 2458 | paramSet: {} |
| 2459 | }; |
| 2460 | if (match(')')) { |
| 2461 | tolerateUnexpectedToken(lookahead); |
| 2462 | } else { |
| 2463 | parseParam(options); |
| 2464 | if (options.defaultCount === 0) { |
| 2465 | options.defaults = []; |
| 2466 | } |
| 2467 | } |
| 2468 | expect(')'); |
| 2469 | |
| 2470 | value = parsePropertyFunction(methodNode, options); |
| 2471 | return node.finishProperty('set', key, computed, value, false, false); |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | if (match('(')) { |
| 2476 | value = parsePropertyMethodFunction(); |
| 2477 | return node.finishProperty('init', key, computed, value, true, false); |
| 2478 | } |
| 2479 | |
| 2480 | // Not a MethodDefinition. |
| 2481 | return null; |
| 2482 | } |
| 2483 | |
| 2484 | function checkProto(key, computed, hasProto) { |
no test coverage detected