()
| 2925 | } |
| 2926 | |
| 2927 | parseFunctionExpression(): Node.AsyncFunctionExpression | Node.FunctionExpression { |
| 2928 | const node = this.createNode(); |
| 2929 | |
| 2930 | const isAsync = this.matchContextualKeyword('async'); |
| 2931 | if (isAsync) { |
| 2932 | this.nextToken(); |
| 2933 | } |
| 2934 | |
| 2935 | this.expectKeyword('function'); |
| 2936 | |
| 2937 | const isGenerator = isAsync ? false : this.match('*'); |
| 2938 | if (isGenerator) { |
| 2939 | this.nextToken(); |
| 2940 | } |
| 2941 | |
| 2942 | let message; |
| 2943 | let id: Node.Identifier | null = null; |
| 2944 | let firstRestricted; |
| 2945 | |
| 2946 | const previousAllowAwait = this.context.await; |
| 2947 | const previousAllowYield = this.context.allowYield; |
| 2948 | this.context.await = isAsync; |
| 2949 | this.context.allowYield = !isGenerator; |
| 2950 | |
| 2951 | if (!this.match('(')) { |
| 2952 | const token = this.lookahead; |
| 2953 | id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseIdentifierName() : this.parseVariableIdentifier(); |
| 2954 | if (this.context.strict) { |
| 2955 | if (this.scanner.isRestrictedWord(token.value as string)) { |
| 2956 | this.tolerateUnexpectedToken(token, Messages.StrictFunctionName); |
| 2957 | } |
| 2958 | } else { |
| 2959 | if (this.scanner.isRestrictedWord(token.value as string)) { |
| 2960 | firstRestricted = token; |
| 2961 | message = Messages.StrictFunctionName; |
| 2962 | } else if (this.scanner.isStrictModeReservedWord(token.value as string)) { |
| 2963 | firstRestricted = token; |
| 2964 | message = Messages.StrictReservedWord; |
| 2965 | } |
| 2966 | } |
| 2967 | } |
| 2968 | |
| 2969 | const formalParameters = this.parseFormalParameters(firstRestricted); |
| 2970 | const params = formalParameters.params; |
| 2971 | const stricted = formalParameters.stricted; |
| 2972 | firstRestricted = formalParameters.firstRestricted; |
| 2973 | if (formalParameters.message) { |
| 2974 | message = formalParameters.message; |
| 2975 | } |
| 2976 | |
| 2977 | const previousStrict = this.context.strict; |
| 2978 | const previousAllowStrictDirective = this.context.allowStrictDirective; |
| 2979 | this.context.allowStrictDirective = formalParameters.simple; |
| 2980 | const body = this.parseFunctionSourceElements(); |
| 2981 | if (this.context.strict && firstRestricted) { |
| 2982 | this.throwUnexpectedToken(firstRestricted, message); |
| 2983 | } |
| 2984 | if (this.context.strict && stricted) { |
no test coverage detected