Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/@babel/parser/lib/index.js
r0c6b92a r79a0317 421 421 } 422 422 const Errors = Object.assign({}, ParseErrorEnum(ModuleErrors), ParseErrorEnum(StandardErrors), ParseErrorEnum(StrictModeErrors), ParseErrorEnum`pipelineOperator`(PipelineOperatorErrors)); 423 function createDefaultOptions() { 424 return { 425 sourceType: "script", 426 sourceFilename: undefined, 427 startIndex: 0, 428 startColumn: 0, 429 startLine: 1, 430 allowAwaitOutsideFunction: false, 431 allowReturnOutsideFunction: false, 432 allowNewTargetOutsideFunction: false, 433 allowImportExportEverywhere: false, 434 allowSuperOutsideMethod: false, 435 allowUndeclaredExports: false, 436 plugins: [], 437 strictMode: null, 438 ranges: false, 439 tokens: false, 440 createImportExpressions: false, 441 createParenthesizedExpressions: false, 442 errorRecovery: false, 443 attachComment: true, 444 annexB: true 445 }; 446 } 447 function getOptions(opts) { 448 const options = createDefaultOptions(); 449 if (opts == null) { 450 return options; 451 } 452 if (opts.annexB != null && opts.annexB !== false) { 453 throw new Error("The `annexB` option can only be set to `false`."); 454 } 455 for (const key of Object.keys(options)) { 456 if (opts[key] != null) options[key] = opts[key]; 457 } 458 if (options.startLine === 1) { 459 if (opts.startIndex == null && options.startColumn > 0) { 460 options.startIndex = options.startColumn; 461 } else if (opts.startColumn == null && options.startIndex > 0) { 462 options.startColumn = options.startIndex; 463 } 464 } else if (opts.startColumn == null || opts.startIndex == null) { 465 if (opts.startIndex != null) { 466 throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`."); 467 } 468 } 469 return options; 470 } 423 471 const { 424 472 defineProperty … … 440 488 parse() { 441 489 const file = toESTreeLocation(super.parse()); 442 if (this.option s.tokens) {490 if (this.optionFlags & 128) { 443 491 file.tokens = file.tokens.map(toESTreeLocation); 444 492 } … … 529 577 delete node.directives; 530 578 } 531 pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {532 this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);533 if (method.typeParameters) {534 method.value.typeParameters = method.typeParameters;535 delete method.typeParameters;536 }537 classBody.body.push(method);538 }539 579 parsePrivateName() { 540 580 const node = super.parsePrivateName(); … … 587 627 delete funcNode.kind; 588 628 node.value = funcNode; 629 const { 630 typeParameters 631 } = node; 632 if (typeParameters) { 633 delete node.typeParameters; 634 funcNode.typeParameters = typeParameters; 635 funcNode.start = typeParameters.start; 636 funcNode.loc.start = typeParameters.loc.start; 637 } 589 638 if (type === "ClassPrivateMethod") { 590 639 node.computed = false; … … 603 652 } 604 653 } 605 propertyNode.type = "PropertyDefinition"; 654 { 655 propertyNode.type = "PropertyDefinition"; 656 } 606 657 return propertyNode; 607 658 } … … 613 664 } 614 665 } 615 propertyNode.type = "PropertyDefinition"; 666 { 667 propertyNode.type = "PropertyDefinition"; 668 } 616 669 propertyNode.computed = false; 617 670 return propertyNode; … … 1735 1788 adjustInnerComments(node, node.specifiers, commentWS); 1736 1789 break; 1790 case "TSEnumDeclaration": 1791 { 1792 adjustInnerComments(node, node.members, commentWS); 1793 } 1794 break; 1795 case "TSEnumBody": 1796 adjustInnerComments(node, node.members, commentWS); 1797 break; 1737 1798 default: 1738 1799 { … … 2314 2375 this.errorHandlers_readInt = { 2315 2376 invalidDigit: (pos, lineStart, curLine, radix) => { 2316 if (! this.options.errorRecovery) return false;2377 if (!(this.optionFlags & 1024)) return false; 2317 2378 this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), { 2318 2379 radix … … 2355 2416 next() { 2356 2417 this.checkKeywordEscapes(); 2357 if (this.option s.tokens) {2418 if (this.optionFlags & 128) { 2358 2419 this.pushToken(new Token(this.state)); 2359 2420 } … … 2471 2532 loc: new SourceLocation(startLoc, this.state.curPosition()) 2472 2533 }; 2473 if (this.option s.tokens) this.pushToken(comment);2534 if (this.optionFlags & 128) this.pushToken(comment); 2474 2535 return comment; 2475 2536 } … … 2494 2555 loc: new SourceLocation(startLoc, this.state.curPosition()) 2495 2556 }; 2496 if (this.option s.tokens) this.pushToken(comment);2557 if (this.optionFlags & 128) this.pushToken(comment); 2497 2558 return comment; 2498 2559 } 2499 2560 skipSpace() { 2500 2561 const spaceStart = this.state.pos; 2501 const comments = [];2562 const comments = this.optionFlags & 2048 ? [] : null; 2502 2563 loop: while (this.state.pos < this.length) { 2503 2564 const ch = this.input.charCodeAt(this.state.pos); … … 2526 2587 if (comment !== undefined) { 2527 2588 this.addComment(comment); 2528 if (this.options.attachComment)comments.push(comment);2589 comments == null || comments.push(comment); 2529 2590 } 2530 2591 break; … … 2535 2596 if (comment !== undefined) { 2536 2597 this.addComment(comment); 2537 if (this.options.attachComment)comments.push(comment);2598 comments == null || comments.push(comment); 2538 2599 } 2539 2600 break; … … 2546 2607 if (isWhitespace(ch)) { 2547 2608 ++this.state.pos; 2548 } else if (ch === 45 && !this.inModule && this.option s.annexB) {2609 } else if (ch === 45 && !this.inModule && this.optionFlags & 4096) { 2549 2610 const pos = this.state.pos; 2550 2611 if (this.input.charCodeAt(pos + 1) === 45 && this.input.charCodeAt(pos + 2) === 62 && (spaceStart === 0 || this.state.lineStart > spaceStart)) { … … 2552 2613 if (comment !== undefined) { 2553 2614 this.addComment(comment); 2554 if (this.options.attachComment)comments.push(comment);2615 comments == null || comments.push(comment); 2555 2616 } 2556 2617 } else { 2557 2618 break loop; 2558 2619 } 2559 } else if (ch === 60 && !this.inModule && this.option s.annexB) {2620 } else if (ch === 60 && !this.inModule && this.optionFlags & 4096) { 2560 2621 const pos = this.state.pos; 2561 2622 if (this.input.charCodeAt(pos + 1) === 33 && this.input.charCodeAt(pos + 2) === 45 && this.input.charCodeAt(pos + 3) === 45) { … … 2563 2624 if (comment !== undefined) { 2564 2625 this.addComment(comment); 2565 if (this.options.attachComment)comments.push(comment);2626 comments == null || comments.push(comment); 2566 2627 } 2567 2628 } else { … … 2573 2634 } 2574 2635 } 2575 if ( comments.length> 0) {2636 if ((comments == null ? void 0 : comments.length) > 0) { 2576 2637 const end = this.state.pos; 2577 2638 const commentWhitespace = { … … 3265 3326 const loc = at instanceof Position ? at : at.loc.start; 3266 3327 const error = toParseError(loc, details); 3267 if (! this.options.errorRecovery) throw error;3328 if (!(this.optionFlags & 1024)) throw error; 3268 3329 if (!this.isLookahead) this.state.errors.push(error); 3269 3330 return error; … … 3749 3810 this.end = 0; 3750 3811 this.loc = new SourceLocation(loc); 3751 if ( parser != null && parser.options.ranges) this.range = [pos, 0];3812 if ((parser == null ? void 0 : parser.optionFlags) & 64) this.range = [pos, 0]; 3752 3813 if (parser != null && parser.filename) this.loc.filename = parser.filename; 3753 3814 } … … 3837 3898 node.end = endLoc.index; 3838 3899 node.loc.end = endLoc; 3839 if (this.options.ranges) node.range[1] = endLoc.index; 3840 if (this.options.attachComment) this.processComment(node); 3900 if (this.optionFlags & 64) node.range[1] = endLoc.index; 3901 if (this.optionFlags & 2048) { 3902 this.processComment(node); 3903 } 3841 3904 return node; 3842 3905 } … … 3844 3907 node.start = startLoc.index; 3845 3908 node.loc.start = startLoc; 3846 if (this.option s.ranges) node.range[0] = startLoc.index;3909 if (this.optionFlags & 64) node.range[0] = startLoc.index; 3847 3910 } 3848 3911 resetEndLocation(node, endLoc = this.state.lastTokEndLoc) { 3849 3912 node.end = endLoc.index; 3850 3913 node.loc.end = endLoc; 3851 if (this.option s.ranges) node.range[1] = endLoc.index;3914 if (this.optionFlags & 64) node.range[1] = endLoc.index; 3852 3915 } 3853 3916 resetStartLocationFromNode(node, locationNode) { … … 4357 4420 return this.finishNode(node, "TypeParameterDeclaration"); 4358 4421 } 4422 flowInTopLevelContext(cb) { 4423 if (this.curContext() !== types.brace) { 4424 const oldContext = this.state.context; 4425 this.state.context = [oldContext[0]]; 4426 try { 4427 return cb(); 4428 } finally { 4429 this.state.context = oldContext; 4430 } 4431 } else { 4432 return cb(); 4433 } 4434 } 4435 flowParseTypeParameterInstantiationInExpression() { 4436 if (this.reScan_lt() !== 47) return; 4437 return this.flowParseTypeParameterInstantiation(); 4438 } 4359 4439 flowParseTypeParameterInstantiation() { 4360 4440 const node = this.startNode(); 4361 4441 const oldInType = this.state.inType; 4442 this.state.inType = true; 4362 4443 node.params = []; 4363 this.state.inType = true; 4364 this.expect(47); 4365 const oldNoAnonFunctionType = this.state.noAnonFunctionType; 4366 this.state.noAnonFunctionType = false; 4367 while (!this.match(48)) { 4368 node.params.push(this.flowParseType()); 4369 if (!this.match(48)) { 4370 this.expect(12); 4371 } 4372 } 4373 this.state.noAnonFunctionType = oldNoAnonFunctionType; 4444 this.flowInTopLevelContext(() => { 4445 this.expect(47); 4446 const oldNoAnonFunctionType = this.state.noAnonFunctionType; 4447 this.state.noAnonFunctionType = false; 4448 while (!this.match(48)) { 4449 node.params.push(this.flowParseType()); 4450 if (!this.match(48)) { 4451 this.expect(12); 4452 } 4453 } 4454 this.state.noAnonFunctionType = oldNoAnonFunctionType; 4455 }); 4456 this.state.inType = oldInType; 4457 if (!this.state.inType && this.curContext() === types.brace) { 4458 this.reScan_lt_gt(); 4459 } 4374 4460 this.expect(48); 4375 this.state.inType = oldInType;4376 4461 return this.finishNode(node, "TypeParameterInstantiation"); 4377 4462 } 4378 4463 flowParseTypeParameterInstantiationCallOrNew() { 4464 if (this.reScan_lt() !== 47) return; 4379 4465 const node = this.startNode(); 4380 4466 const oldInType = this.state.inType; … … 5430 5516 parseClassSuper(node) { 5431 5517 super.parseClassSuper(node); 5432 if (node.superClass && this.match(47)) { 5433 node.superTypeParameters = this.flowParseTypeParameterInstantiation(); 5518 if (node.superClass && (this.match(47) || this.match(51))) { 5519 { 5520 node.superTypeParameters = this.flowParseTypeParameterInstantiationInExpression(); 5521 } 5434 5522 } 5435 5523 if (this.isContextual(113)) { … … 5762 5850 const node = this.startNodeAt(startLoc); 5763 5851 node.callee = base; 5764 node.typeArguments = this.flowParseTypeParameterInstantiation ();5852 node.typeArguments = this.flowParseTypeParameterInstantiationInExpression(); 5765 5853 this.expect(10); 5766 5854 node.arguments = this.parseCallExpressionArguments(11); 5767 5855 node.optional = true; 5768 5856 return this.finishCallExpression(node, true); 5769 } else if (!noCalls && this.shouldParseTypes() && this.match(47)) {5857 } else if (!noCalls && this.shouldParseTypes() && (this.match(47) || this.match(51))) { 5770 5858 const node = this.startNodeAt(startLoc); 5771 5859 node.callee = base; … … 6196 6284 return this.finishNode(node, "EnumDeclaration"); 6197 6285 } 6286 jsxParseOpeningElementAfterName(node) { 6287 if (this.shouldParseTypes()) { 6288 if (this.match(47) || this.match(51)) { 6289 node.typeArguments = this.flowParseTypeParameterInstantiationInExpression(); 6290 } 6291 } 6292 return super.jsxParseOpeningElementAfterName(node); 6293 } 6198 6294 isLookaheadToken_lt() { 6199 6295 const next = this.nextTokenStart(); … … 6203 6299 } 6204 6300 return false; 6301 } 6302 reScan_lt_gt() { 6303 const { 6304 type 6305 } = this.state; 6306 if (type === 47) { 6307 this.state.pos -= 1; 6308 this.readToken_lt(); 6309 } else if (type === 48) { 6310 this.state.pos -= 1; 6311 this.readToken_gt(); 6312 } 6313 } 6314 reScan_lt() { 6315 const { 6316 type 6317 } = this.state; 6318 if (type === 51) { 6319 this.state.pos -= 2; 6320 this.finishOp(47, 1); 6321 return 47; 6322 } 6323 return type; 6205 6324 } 6206 6325 maybeUnwrapTypeCastExpression(node) { … … 7715 7834 if (!this.match(134)) { 7716 7835 this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc); 7717 } 7718 node.argument = super.parseExprAtom(); 7836 { 7837 node.argument = super.parseExprAtom(); 7838 } 7839 } else { 7840 { 7841 node.argument = this.parseStringLiteral(this.state.value); 7842 } 7843 } 7719 7844 if (this.eat(12) && !this.match(11)) { 7720 7845 node.options = super.parseMaybeAssignAllowIn(); … … 7728 7853 } 7729 7854 if (this.match(47)) { 7730 node.typeParameters = this.tsParseTypeArguments(); 7855 { 7856 node.typeParameters = this.tsParseTypeArguments(); 7857 } 7731 7858 } 7732 7859 return this.finishNode(node, "TSImportType"); … … 7746 7873 node.typeName = this.tsParseEntityName(); 7747 7874 if (!this.hasPrecedingLineBreak() && this.match(47)) { 7748 node.typeParameters = this.tsParseTypeArguments(); 7875 { 7876 node.typeParameters = this.tsParseTypeArguments(); 7877 } 7749 7878 } 7750 7879 return this.finishNode(node, "TSTypeReference"); … … 7772 7901 } 7773 7902 if (!this.hasPrecedingLineBreak() && this.match(47)) { 7774 node.typeParameters = this.tsParseTypeArguments(); 7903 { 7904 node.typeParameters = this.tsParseTypeArguments(); 7905 } 7775 7906 } 7776 7907 return this.finishNode(node, "TSTypeQuery"); … … 8459 8590 const node = this.startNode(); 8460 8591 node.expression = this.tsParseEntityName(); 8461 if (this.match(47)) { 8462 node.typeParameters = this.tsParseTypeArguments(); 8463 } 8464 return this.finishNode(node, "TSExpressionWithTypeArguments"); 8592 { 8593 if (this.match(47)) { 8594 node.typeParameters = this.tsParseTypeArguments(); 8595 } 8596 return this.finishNode(node, "TSExpressionWithTypeArguments"); 8597 } 8465 8598 }); 8466 8599 if (!delimitedList.length) { … … 8507 8640 return this.finishNode(node, "TSTypeAliasDeclaration"); 8508 8641 } 8509 tsInNoContext(cb) { 8510 const oldContext = this.state.context; 8511 this.state.context = [oldContext[0]]; 8512 try { 8642 tsInTopLevelContext(cb) { 8643 if (this.curContext() !== types.brace) { 8644 const oldContext = this.state.context; 8645 this.state.context = [oldContext[0]]; 8646 try { 8647 return cb(); 8648 } finally { 8649 this.state.context = oldContext; 8650 } 8651 } else { 8513 8652 return cb(); 8514 } finally {8515 this.state.context = oldContext;8516 8653 } 8517 8654 } … … 8574 8711 node.id = this.parseIdentifier(); 8575 8712 this.checkIdentifier(node.id, node.const ? 8971 : 8459); 8713 { 8714 this.expect(5); 8715 node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this)); 8716 this.expect(8); 8717 } 8718 return this.finishNode(node, "TSEnumDeclaration"); 8719 } 8720 tsParseEnumBody() { 8721 const node = this.startNode(); 8576 8722 this.expect(5); 8577 8723 node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this)); 8578 8724 this.expect(8); 8579 return this.finishNode(node, "TSEnum Declaration");8725 return this.finishNode(node, "TSEnumBody"); 8580 8726 } 8581 8727 tsParseModuleBlock() { … … 8608 8754 if (this.isContextual(112)) { 8609 8755 node.kind = "global"; 8610 node.global = true; 8756 { 8757 node.global = true; 8758 } 8611 8759 node.id = this.parseIdentifier(); 8612 8760 } else if (this.match(134)) { … … 8746 8894 const mod = node; 8747 8895 mod.kind = "global"; 8748 mod.global = true; 8896 { 8897 node.global = true; 8898 } 8749 8899 mod.id = expr; 8750 8900 mod.body = this.tsParseModuleBlock(); … … 8818 8968 tsParseTypeArguments() { 8819 8969 const node = this.startNode(); 8820 node.params = this.tsInType(() => this.tsIn NoContext(() => {8970 node.params = this.tsInType(() => this.tsInTopLevelContext(() => { 8821 8971 this.expect(47); 8822 8972 return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this)); … … 8963 9113 if (tokenIsTemplate(this.state.type)) { 8964 9114 const result = super.parseTaggedTemplateExpression(base, startLoc, state); 8965 result.typeParameters = typeArguments; 9115 { 9116 result.typeParameters = typeArguments; 9117 } 8966 9118 return result; 8967 9119 } … … 8971 9123 node.arguments = this.parseCallExpressionArguments(11); 8972 9124 this.tsCheckForInvalidTypeCasts(node.arguments); 8973 node.typeParameters = typeArguments; 9125 { 9126 node.typeParameters = typeArguments; 9127 } 8974 9128 if (state.optionalChainMember) { 8975 9129 node.optional = isOptionalCall; … … 8983 9137 const node = this.startNodeAt(startLoc); 8984 9138 node.expression = base; 8985 node.typeParameters = typeArguments; 9139 { 9140 node.typeParameters = typeArguments; 9141 } 8986 9142 return this.finishNode(node, "TSInstantiationExpression"); 8987 9143 }); … … 9005 9161 } = node; 9006 9162 if (callee.type === "TSInstantiationExpression" && !((_callee$extra = callee.extra) != null && _callee$extra.parenthesized)) { 9007 node.typeParameters = callee.typeParameters; 9163 { 9164 node.typeParameters = callee.typeParameters; 9165 } 9008 9166 node.callee = callee.expression; 9009 9167 } … … 9385 9543 super.parseClassSuper(node); 9386 9544 if (node.superClass && (this.match(47) || this.match(51))) { 9387 node.superTypeParameters = this.tsParseTypeArgumentsInExpression(); 9545 { 9546 node.superTypeParameters = this.tsParseTypeArgumentsInExpression(); 9547 } 9388 9548 } 9389 9549 if (this.eatContextual(113)) { … … 9595 9755 return super.parseBindingAtom(); 9596 9756 } 9597 parseMaybeDecoratorArguments(expr ) {9757 parseMaybeDecoratorArguments(expr, startLoc) { 9598 9758 if (this.match(47) || this.match(51)) { 9599 9759 const typeArguments = this.tsParseTypeArgumentsInExpression(); 9600 9760 if (this.match(10)) { 9601 const call = super.parseMaybeDecoratorArguments(expr); 9602 call.typeParameters = typeArguments; 9761 const call = super.parseMaybeDecoratorArguments(expr, startLoc); 9762 { 9763 call.typeParameters = typeArguments; 9764 } 9603 9765 return call; 9604 9766 } 9605 9767 this.unexpected(null, 10); 9606 9768 } 9607 return super.parseMaybeDecoratorArguments(expr );9769 return super.parseMaybeDecoratorArguments(expr, startLoc); 9608 9770 } 9609 9771 checkCommaAfterRest(close) { … … 9692 9854 if (this.match(47) || this.match(51)) { 9693 9855 const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArgumentsInExpression()); 9694 if (typeArguments) node.typeParameters = typeArguments; 9856 if (typeArguments) { 9857 { 9858 node.typeParameters = typeArguments; 9859 } 9860 } 9695 9861 } 9696 9862 return super.jsxParseOpeningElementAfterName(node); … … 9752 9918 const method = super.parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope); 9753 9919 if (method.abstract) { 9754 const hasBody = this.hasPlugin("estree") ? !!method.value.body : !!method.body; 9755 if (hasBody) { 9920 const hasEstreePlugin = this.hasPlugin("estree"); 9921 const methodFn = hasEstreePlugin ? method.value : method; 9922 if (methodFn.body) { 9756 9923 const { 9757 9924 key … … 10233 10400 }; 10234 10401 const mixinPluginNames = Object.keys(mixinPlugins); 10235 function createDefaultOptions() {10236 return {10237 sourceType: "script",10238 sourceFilename: undefined,10239 startIndex: 0,10240 startColumn: 0,10241 startLine: 1,10242 allowAwaitOutsideFunction: false,10243 allowReturnOutsideFunction: false,10244 allowNewTargetOutsideFunction: false,10245 allowImportExportEverywhere: false,10246 allowSuperOutsideMethod: false,10247 allowUndeclaredExports: false,10248 plugins: [],10249 strictMode: null,10250 ranges: false,10251 tokens: false,10252 createImportExpressions: false,10253 createParenthesizedExpressions: false,10254 errorRecovery: false,10255 attachComment: true,10256 annexB: true10257 };10258 }10259 function getOptions(opts) {10260 const options = createDefaultOptions();10261 if (opts == null) {10262 return options;10263 }10264 if (opts.annexB != null && opts.annexB !== false) {10265 throw new Error("The `annexB` option can only be set to `false`.");10266 }10267 for (const key of Object.keys(options)) {10268 if (opts[key] != null) options[key] = opts[key];10269 }10270 if (options.startLine === 1) {10271 if (opts.startIndex == null && options.startColumn > 0) {10272 options.startIndex = options.startColumn;10273 } else if (opts.startColumn == null && options.startIndex > 0) {10274 options.startColumn = options.startIndex;10275 }10276 } else if (opts.startColumn == null || opts.startIndex == null) {10277 if (opts.startIndex != null) {10278 throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");10279 }10280 }10281 return options;10282 }10283 10402 class ExpressionParser extends LValParser { 10284 10403 checkProto(prop, isRecord, protoRef, refExpressionErrors) { … … 10318 10437 expr.comments = this.comments; 10319 10438 expr.errors = this.state.errors; 10320 if (this.option s.tokens) {10439 if (this.optionFlags & 128) { 10321 10440 expr.tokens = this.tokens; 10322 10441 } … … 10823 10942 } 10824 10943 if (this.match(10)) { 10825 if (this.option s.createImportExpressions) {10944 if (this.optionFlags & 256) { 10826 10945 return this.parseImportCall(node); 10827 10946 } else { … … 11065 11184 const node = this.startNode(); 11066 11185 this.next(); 11067 if (this.match(10) && !this.scope.allowDirectSuper && ! this.options.allowSuperOutsideMethod) {11186 if (this.match(10) && !this.scope.allowDirectSuper && !(this.optionFlags & 16)) { 11068 11187 this.raise(Errors.SuperNotAllowed, node); 11069 } else if (!this.scope.allowSuper && ! this.options.allowSuperOutsideMethod) {11188 } else if (!this.scope.allowSuper && !(this.optionFlags & 16)) { 11070 11189 this.raise(Errors.UnexpectedSuper, node); 11071 11190 } … … 11120 11239 } else if (this.isContextual(105) || this.isContextual(97)) { 11121 11240 const isSource = this.isContextual(105); 11122 if (!isSource) this.unexpected();11123 11241 this.expectPlugin(isSource ? "sourcePhaseImports" : "deferredImportEvaluation"); 11124 if (! this.options.createImportExpressions) {11242 if (!(this.optionFlags & 256)) { 11125 11243 throw this.raise(Errors.DynamicImportPhaseRequiresImportExpressions, this.state.startLoc, { 11126 11244 phase: this.state.value … … 11242 11360 } 11243 11361 wrapParenthesis(startLoc, expression) { 11244 if (! this.options.createParenthesizedExpressions) {11362 if (!(this.optionFlags & 512)) { 11245 11363 this.addExtra(expression, "parenthesized", true); 11246 11364 this.addExtra(expression, "parenStart", startLoc.index); … … 11270 11388 this.next(); 11271 11389 const metaProp = this.parseMetaProperty(node, meta, "target"); 11272 if (!this.scope.inNonArrowFunction && !this.scope.inClass && ! this.options.allowNewTargetOutsideFunction) {11390 if (!this.scope.inNonArrowFunction && !this.scope.inClass && !(this.optionFlags & 4)) { 11273 11391 this.raise(Errors.UnexpectedNewTarget, metaProp); 11274 11392 } … … 11785 11903 } 11786 11904 recordAwaitIfAllowed() { 11787 const isAwaitAllowed = this.prodParam.hasAwait || this.option s.allowAwaitOutsideFunction&& !this.scope.inFunction;11905 const isAwaitAllowed = this.prodParam.hasAwait || this.optionFlags & 1 && !this.scope.inFunction; 11788 11906 if (isAwaitAllowed && !this.scope.inFunction) { 11789 11907 this.state.hasTopLevelAwait = true; … … 11797 11915 this.raise(Errors.ObsoleteAwaitStar, node); 11798 11916 } 11799 if (!this.scope.inFunction && ! this.options.allowAwaitOutsideFunction) {11917 if (!this.scope.inFunction && !(this.optionFlags & 1)) { 11800 11918 if (this.isAmbiguousAwait()) { 11801 11919 this.ambiguousScriptDifferentAst = true; … … 12121 12239 file.program = this.parseProgram(program); 12122 12240 file.comments = this.comments; 12123 if (this.option s.tokens) {12241 if (this.optionFlags & 128) { 12124 12242 file.tokens = babel7CompatTokens(this.tokens, this.input, this.startIndex); 12125 12243 } … … 12131 12249 this.parseBlockBody(program, true, true, end); 12132 12250 if (this.inModule) { 12133 if (! this.options.allowUndeclaredExports&& this.scope.undefinedExports.size > 0) {12251 if (!(this.optionFlags & 32) && this.scope.undefinedExports.size > 0) { 12134 12252 for (const [localName, at] of Array.from(this.scope.undefinedExports)) { 12135 12253 this.raise(Errors.ModuleExportUndefined, at, { … … 12357 12475 case 82: 12358 12476 { 12359 if (! this.options.allowImportExportEverywhere&& !topLevel) {12477 if (!(this.optionFlags & 8) && !topLevel) { 12360 12478 this.raise(Errors.UnexpectedImportExport, this.state.startLoc); 12361 12479 } … … 12396 12514 } 12397 12515 assertModuleNodeAllowed(node) { 12398 if (! this.options.allowImportExportEverywhere&& !this.inModule) {12516 if (!(this.optionFlags & 8) && !this.inModule) { 12399 12517 this.raise(Errors.ImportOutsideModule, node); 12400 12518 } … … 12406 12524 maybeTakeDecorators(maybeDecorators, classNode, exportNode) { 12407 12525 if (maybeDecorators) { 12408 if (classNode.decorators && classNode.decorators.length > 0) { 12526 var _classNode$decorators; 12527 if ((_classNode$decorators = classNode.decorators) != null && _classNode$decorators.length) { 12409 12528 if (typeof this.getPluginOption("decorators", "decoratorsBeforeExport") !== "boolean") { 12410 12529 this.raise(Errors.DecoratorsBeforeAfterExport, classNode.decorators[0]); … … 12453 12572 expr = this.wrapParenthesis(startLoc, expr); 12454 12573 const paramsStartLoc = this.state.startLoc; 12455 node.expression = this.parseMaybeDecoratorArguments(expr );12574 node.expression = this.parseMaybeDecoratorArguments(expr, startLoc); 12456 12575 if (this.getPluginOption("decorators", "allowCallParenthesized") === false && node.expression !== expr) { 12457 12576 this.raise(Errors.DecoratorArgumentsOutsideParentheses, paramsStartLoc); … … 12471 12590 expr = this.finishNode(node, "MemberExpression"); 12472 12591 } 12473 node.expression = this.parseMaybeDecoratorArguments(expr );12592 node.expression = this.parseMaybeDecoratorArguments(expr, startLoc); 12474 12593 } 12475 12594 } else { … … 12478 12597 return this.finishNode(node, "Decorator"); 12479 12598 } 12480 parseMaybeDecoratorArguments(expr ) {12599 parseMaybeDecoratorArguments(expr, startLoc) { 12481 12600 if (this.eat(10)) { 12482 const node = this.startNodeAt Node(expr);12601 const node = this.startNodeAt(startLoc); 12483 12602 node.callee = expr; 12484 12603 node.arguments = this.parseCallExpressionArguments(11); … … 12627 12746 } 12628 12747 parseReturnStatement(node) { 12629 if (!this.prodParam.hasReturn && ! this.options.allowReturnOutsideFunction) {12748 if (!this.prodParam.hasReturn && !(this.optionFlags & 2)) { 12630 12749 this.raise(Errors.IllegalReturn, this.state.startLoc); 12631 12750 } … … 13917 14036 this.filename = options.sourceFilename; 13918 14037 this.startIndex = options.startIndex; 14038 let optionFlags = 0; 14039 if (options.allowAwaitOutsideFunction) { 14040 optionFlags |= 1; 14041 } 14042 if (options.allowReturnOutsideFunction) { 14043 optionFlags |= 2; 14044 } 14045 if (options.allowImportExportEverywhere) { 14046 optionFlags |= 8; 14047 } 14048 if (options.allowSuperOutsideMethod) { 14049 optionFlags |= 16; 14050 } 14051 if (options.allowUndeclaredExports) { 14052 optionFlags |= 32; 14053 } 14054 if (options.allowNewTargetOutsideFunction) { 14055 optionFlags |= 4; 14056 } 14057 if (options.ranges) { 14058 optionFlags |= 64; 14059 } 14060 if (options.tokens) { 14061 optionFlags |= 128; 14062 } 14063 if (options.createImportExpressions) { 14064 optionFlags |= 256; 14065 } 14066 if (options.createParenthesizedExpressions) { 14067 optionFlags |= 512; 14068 } 14069 if (options.errorRecovery) { 14070 optionFlags |= 1024; 14071 } 14072 if (options.attachComment) { 14073 optionFlags |= 2048; 14074 } 14075 if (options.annexB) { 14076 optionFlags |= 4096; 14077 } 14078 this.optionFlags = optionFlags; 13919 14079 } 13920 14080 getScopeHandler() {
Note:
See TracChangeset
for help on using the changeset viewer.