| 1633 | } |
| 1634 | |
| 1635 | parseFunctionOrFunctionSent( |
| 1636 | this: Parser, |
| 1637 | ): N.FunctionExpression | N.MetaProperty { |
| 1638 | const node = this.startNode<N.FunctionExpression | N.MetaProperty>(); |
| 1639 | |
| 1640 | // We do not do parseIdentifier here because when parseFunctionOrFunctionSent |
| 1641 | // is called we already know that the current token is a "name" with the value "function" |
| 1642 | // This will improve perf a tiny little bit as we do not do validation but more importantly |
| 1643 | // here is that parseIdentifier will remove an item from the expression stack |
| 1644 | // if "function" or "class" is parsed as identifier (in objects e.g.), which should not happen here. |
| 1645 | this.next(); // eat `function` |
| 1646 | |
| 1647 | if (this.prodParam.hasYield && this.match(tt.dot)) { |
| 1648 | const meta = this.createIdentifier( |
| 1649 | this.startNodeAtNode<N.Identifier>(node), |
| 1650 | "function", |
| 1651 | ); |
| 1652 | this.next(); // eat `.` |
| 1653 | // https://github.com/tc39/proposal-function.sent#syntax-1 |
| 1654 | if (this.match(tt._sent)) { |
| 1655 | this.expectPlugin("functionSent"); |
| 1656 | } else if (!this.hasPlugin("functionSent")) { |
| 1657 | // The code wasn't `function.sent` but just `function.`, so a simple error is less confusing. |
| 1658 | this.unexpected(); |
| 1659 | } |
| 1660 | return this.parseMetaProperty( |
| 1661 | node as Undone<N.MetaProperty>, |
| 1662 | meta, |
| 1663 | "sent", |
| 1664 | ); |
| 1665 | } |
| 1666 | return this.parseFunction(node as Undone<N.FunctionExpression>); |
| 1667 | } |
| 1668 | |
| 1669 | parseMetaProperty( |
| 1670 | node: Undone<N.MetaProperty>, |