meriyah 7.2.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -3
- package/dist/meriyah.cjs +634 -430
- package/dist/meriyah.min.mjs +1 -1
- package/dist/meriyah.mjs +634 -430
- package/dist/meriyah.umd.js +634 -430
- package/dist/meriyah.umd.min.js +1 -1
- package/dist/types/errors.d.ts +74 -70
- package/dist/types/estree.d.ts +2 -0
- package/dist/types/features.d.ts +7 -0
- package/dist/types/options.d.ts +6 -2
- package/dist/types/parser/parser.d.ts +8 -3
- package/dist/types/parser/scope.d.ts +1 -1
- package/dist/types/parser.d.ts +2 -2
- package/dist/types/token.d.ts +3 -3
- package/package.json +1 -1
- package/dist/types/utilities.d.ts +0 -1
package/dist/meriyah.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version$1 = "7.
|
|
1
|
+
var version$1 = "7.3.1";
|
|
2
2
|
var packageJson = {
|
|
3
3
|
version: version$1};
|
|
4
4
|
|
|
@@ -91,7 +91,7 @@ const CharTypes = [
|
|
|
91
91
|
0,
|
|
92
92
|
16384,
|
|
93
93
|
0,
|
|
94
|
-
|
|
94
|
+
16384,
|
|
95
95
|
0,
|
|
96
96
|
0,
|
|
97
97
|
1 | 2 | 64,
|
|
@@ -154,7 +154,7 @@ const CharTypes = [
|
|
|
154
154
|
1 | 2 | 4,
|
|
155
155
|
16384,
|
|
156
156
|
0,
|
|
157
|
-
|
|
157
|
+
16384,
|
|
158
158
|
0,
|
|
159
159
|
0
|
|
160
160
|
];
|
|
@@ -621,7 +621,7 @@ const errorMessages = {
|
|
|
621
621
|
[9]: 'Octal literals are not allowed in strict mode',
|
|
622
622
|
[8]: 'Decimal integer literals with a leading zero are forbidden in strict mode',
|
|
623
623
|
[10]: 'Expected number in radix %0',
|
|
624
|
-
[
|
|
624
|
+
[153]: 'Invalid left-hand side assignment to a destructible right-hand side',
|
|
625
625
|
[11]: 'Non-number found after exponent indicator',
|
|
626
626
|
[12]: 'Invalid BigIntLiteral',
|
|
627
627
|
[13]: 'No identifiers allowed directly after numeric literal',
|
|
@@ -645,7 +645,7 @@ const errorMessages = {
|
|
|
645
645
|
[32]: 'Yield expression not allowed in formal parameter',
|
|
646
646
|
[95]: "Unexpected token: 'escaped keyword'",
|
|
647
647
|
[33]: 'Unary expressions as the left operand of an exponentiation expression must be disambiguated with parentheses',
|
|
648
|
-
[
|
|
648
|
+
[125]: 'Async functions can only be declared at the top level or inside a block',
|
|
649
649
|
[34]: 'Unterminated regular expression',
|
|
650
650
|
[35]: 'Unexpected regular expression flag',
|
|
651
651
|
[36]: "Duplicate regular expression flag '%0'",
|
|
@@ -657,7 +657,7 @@ const errorMessages = {
|
|
|
657
657
|
[42]: 'A getter cannot be a generator',
|
|
658
658
|
[43]: 'A setter cannot be a generator',
|
|
659
659
|
[44]: 'A computed property name must be followed by a colon or paren',
|
|
660
|
-
[
|
|
660
|
+
[136]: 'Object literal keys that are strings or numbers must be a method or have a colon',
|
|
661
661
|
[46]: 'Found `* async x(){}` but this should be `async * x(){}`',
|
|
662
662
|
[45]: 'Getters and setters can not be generators',
|
|
663
663
|
[47]: "'%0' can not be generator method",
|
|
@@ -719,73 +719,77 @@ const errorMessages = {
|
|
|
719
719
|
[105]: '%0 source must be string',
|
|
720
720
|
[106]: 'Only a identifier or string can be used to indicate alias',
|
|
721
721
|
[107]: "Only '*' or '{...}' can be imported after default",
|
|
722
|
-
[108]: '
|
|
723
|
-
[109]: "
|
|
724
|
-
[110]: '
|
|
725
|
-
[111]: '
|
|
726
|
-
[112]: '
|
|
727
|
-
[113]:
|
|
728
|
-
[114]: '
|
|
729
|
-
[115]: "The
|
|
730
|
-
[116]: '
|
|
731
|
-
[117]:
|
|
732
|
-
[118]: '
|
|
733
|
-
[119]: '
|
|
734
|
-
[120]: '
|
|
735
|
-
[121]: '
|
|
736
|
-
[122]: '
|
|
737
|
-
[
|
|
738
|
-
[
|
|
739
|
-
[126]: '
|
|
740
|
-
[127]: '
|
|
741
|
-
[
|
|
742
|
-
[
|
|
743
|
-
[
|
|
744
|
-
[
|
|
745
|
-
[132]: '
|
|
746
|
-
[133]: '
|
|
747
|
-
[
|
|
748
|
-
[
|
|
749
|
-
[137]: '
|
|
750
|
-
[138]: "
|
|
751
|
-
[139]: '
|
|
752
|
-
[140]:
|
|
753
|
-
[141]: 'import()
|
|
754
|
-
[142]: '
|
|
755
|
-
[143]: '
|
|
756
|
-
[144]:
|
|
757
|
-
[145]:
|
|
758
|
-
[146]:
|
|
759
|
-
[147]: "
|
|
760
|
-
[
|
|
761
|
-
[
|
|
762
|
-
[
|
|
763
|
-
[
|
|
764
|
-
[
|
|
765
|
-
[
|
|
766
|
-
[
|
|
767
|
-
[156]: '
|
|
768
|
-
[157]:
|
|
769
|
-
[158]:
|
|
770
|
-
[159]: "
|
|
771
|
-
[160]: '
|
|
772
|
-
[161]: '
|
|
773
|
-
[162]: '
|
|
774
|
-
[163]: '
|
|
775
|
-
[164]: '
|
|
776
|
-
[165]: '
|
|
777
|
-
[166]: '
|
|
778
|
-
[167]: '
|
|
779
|
-
[168]: 'Invalid
|
|
780
|
-
[169]: '
|
|
781
|
-
[170]: '
|
|
782
|
-
[171]: '
|
|
783
|
-
[172]: '
|
|
784
|
-
[173]:
|
|
785
|
-
[174]:
|
|
786
|
-
[175]: "'
|
|
787
|
-
[176]:
|
|
788
|
-
[177]: '
|
|
722
|
+
[108]: "'import defer' must be followed by a namespace import",
|
|
723
|
+
[109]: "'import source' must be followed by a default import",
|
|
724
|
+
[110]: 'Trailing decorator may be followed by method',
|
|
725
|
+
[111]: "Decorators can't be used with a constructor",
|
|
726
|
+
[112]: 'Can not use `await` as identifier in module or async func',
|
|
727
|
+
[113]: 'Can not use `await` as identifier in module',
|
|
728
|
+
[114]: 'HTML comments are only allowed with web compatibility (Annex B)',
|
|
729
|
+
[115]: "The identifier 'let' must not be in expression position in strict mode",
|
|
730
|
+
[116]: 'Cannot assign to `eval` and `arguments` in strict mode',
|
|
731
|
+
[117]: "The left-hand side of a for-of loop may not start with 'let'",
|
|
732
|
+
[118]: 'Block body arrows can not be immediately invoked without a group',
|
|
733
|
+
[119]: 'Block body arrows can not be immediately accessed without a group',
|
|
734
|
+
[120]: 'Unexpected strict mode reserved word',
|
|
735
|
+
[121]: 'Unexpected eval or arguments in strict mode',
|
|
736
|
+
[122]: 'Decorators must not be followed by a semicolon',
|
|
737
|
+
[123]: 'Calling delete on expression not allowed in strict mode',
|
|
738
|
+
[124]: 'Pattern can not have a tail',
|
|
739
|
+
[126]: 'Can not have a `yield` expression on the left side of a ternary',
|
|
740
|
+
[127]: 'An arrow function can not have a postfix update operator',
|
|
741
|
+
[128]: 'Invalid object literal key character after generator star',
|
|
742
|
+
[129]: 'Private fields can not be deleted',
|
|
743
|
+
[131]: 'Classes may not have a field called constructor',
|
|
744
|
+
[130]: 'Classes may not have a private element named constructor',
|
|
745
|
+
[132]: 'A class field initializer or static block may not contain arguments',
|
|
746
|
+
[133]: 'Generators can only be declared at the top level or inside a block',
|
|
747
|
+
[134]: 'Async methods are a restricted production and cannot have a newline following it',
|
|
748
|
+
[135]: 'Unexpected character after object literal property name',
|
|
749
|
+
[137]: 'Invalid key token',
|
|
750
|
+
[138]: "Label '%0' has already been declared",
|
|
751
|
+
[139]: 'continue statement must be nested within an iteration statement',
|
|
752
|
+
[140]: "Undefined label '%0'",
|
|
753
|
+
[141]: 'Trailing comma is disallowed inside import(...) arguments',
|
|
754
|
+
[142]: 'Invalid binding in JSON import',
|
|
755
|
+
[143]: 'import() requires exactly one argument',
|
|
756
|
+
[144]: 'Cannot use new with import(...)',
|
|
757
|
+
[145]: '... is not allowed in import()',
|
|
758
|
+
[146]: "Expected '=>'",
|
|
759
|
+
[147]: "Duplicate binding '%0'",
|
|
760
|
+
[148]: 'Duplicate private identifier #%0',
|
|
761
|
+
[149]: "Cannot export a duplicate name '%0'",
|
|
762
|
+
[152]: 'Duplicate %0 for-binding',
|
|
763
|
+
[150]: "Exported binding '%0' needs to refer to a top-level declared variable",
|
|
764
|
+
[151]: 'Unexpected private field',
|
|
765
|
+
[155]: 'Numeric separators are not allowed at the end of numeric literals',
|
|
766
|
+
[154]: 'Only one underscore is allowed as numeric separator',
|
|
767
|
+
[156]: 'JSX value should be either an expression or a quoted JSX text',
|
|
768
|
+
[157]: 'Expected corresponding JSX closing tag for %0',
|
|
769
|
+
[158]: 'Adjacent JSX elements must be wrapped in an enclosing tag',
|
|
770
|
+
[159]: "JSX attributes must only be assigned a non-empty 'expression'",
|
|
771
|
+
[160]: "'%0' has already been declared",
|
|
772
|
+
[161]: "'%0' shadowed a catch clause binding",
|
|
773
|
+
[162]: 'Dot property must be an identifier',
|
|
774
|
+
[163]: 'Encountered invalid input after spread/rest argument',
|
|
775
|
+
[164]: 'Catch without try',
|
|
776
|
+
[165]: 'Finally without try',
|
|
777
|
+
[166]: 'Expected corresponding closing tag for JSX fragment',
|
|
778
|
+
[167]: 'Coalescing and logical operators used together in the same expression must be disambiguated with parentheses',
|
|
779
|
+
[168]: 'Invalid tagged template on optional chain',
|
|
780
|
+
[169]: 'Invalid optional chain from super property',
|
|
781
|
+
[170]: 'Invalid optional chain from new expression',
|
|
782
|
+
[171]: 'Cannot use "import.meta" outside a module',
|
|
783
|
+
[172]: 'Leading decorators must be attached to a class declaration',
|
|
784
|
+
[173]: 'An export name cannot include a lone surrogate',
|
|
785
|
+
[174]: 'A string literal cannot be used as an exported binding without `from`',
|
|
786
|
+
[175]: "Private fields can't be accessed on super",
|
|
787
|
+
[176]: "The only valid meta property for import is 'import.meta'",
|
|
788
|
+
[177]: "'import.meta' must not contain escaped characters",
|
|
789
|
+
[178]: 'cannot use "await" as identifier inside an async function',
|
|
790
|
+
[179]: 'cannot use "await" in static blocks',
|
|
791
|
+
[180]: "Unexpected token `}`. Did you mean `}` or `{'}'}`?",
|
|
792
|
+
[181]: "Unexpected token `>`. Did you mean `>` or `{'>'}`?",
|
|
789
793
|
};
|
|
790
794
|
class ParseError extends SyntaxError {
|
|
791
795
|
start;
|
|
@@ -809,10 +813,6 @@ class ParseError extends SyntaxError {
|
|
|
809
813
|
}
|
|
810
814
|
const isParseError = (error) => error instanceof ParseError;
|
|
811
815
|
|
|
812
|
-
function getOwnProperty(object, key) {
|
|
813
|
-
return Object.hasOwn(object, key) ? object[key] : undefined;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
816
|
const KeywordDescTable = [
|
|
817
817
|
'end of source',
|
|
818
818
|
'identifier', 'number', 'string', 'regular expression',
|
|
@@ -834,75 +834,82 @@ const KeywordDescTable = [
|
|
|
834
834
|
'BigIntLiteral', '??', '?.', 'WhiteSpace', 'Illegal', 'LineTerminator', 'PrivateField',
|
|
835
835
|
'Template', '@', 'target', 'meta', 'LineFeed', 'Escaped', 'JSXText'
|
|
836
836
|
];
|
|
837
|
-
const descKeywordTable =
|
|
838
|
-
this
|
|
839
|
-
function
|
|
840
|
-
if
|
|
841
|
-
return
|
|
842
|
-
var
|
|
843
|
-
else
|
|
844
|
-
for
|
|
845
|
-
new
|
|
846
|
-
in
|
|
847
|
-
typeof
|
|
848
|
-
while
|
|
849
|
-
case
|
|
850
|
-
break
|
|
851
|
-
try
|
|
852
|
-
catch
|
|
853
|
-
delete
|
|
854
|
-
throw
|
|
855
|
-
switch
|
|
856
|
-
continue
|
|
857
|
-
default
|
|
858
|
-
instanceof
|
|
859
|
-
do
|
|
860
|
-
void
|
|
861
|
-
finally
|
|
862
|
-
async
|
|
863
|
-
await
|
|
864
|
-
class
|
|
865
|
-
const
|
|
866
|
-
constructor
|
|
867
|
-
debugger
|
|
868
|
-
export
|
|
869
|
-
extends
|
|
870
|
-
false
|
|
871
|
-
from
|
|
872
|
-
get
|
|
873
|
-
implements
|
|
874
|
-
import
|
|
875
|
-
interface
|
|
876
|
-
let
|
|
877
|
-
null
|
|
878
|
-
of
|
|
879
|
-
using
|
|
880
|
-
package
|
|
881
|
-
private
|
|
882
|
-
protected
|
|
883
|
-
public
|
|
884
|
-
set
|
|
885
|
-
static
|
|
886
|
-
super
|
|
887
|
-
true
|
|
888
|
-
with
|
|
889
|
-
yield
|
|
890
|
-
enum
|
|
891
|
-
eval
|
|
892
|
-
as
|
|
893
|
-
arguments
|
|
894
|
-
target
|
|
895
|
-
meta
|
|
896
|
-
accessor
|
|
897
|
-
|
|
837
|
+
const descKeywordTable = new Map([
|
|
838
|
+
['this', 86111],
|
|
839
|
+
['function', 86104],
|
|
840
|
+
['if', 20569],
|
|
841
|
+
['return', 20572],
|
|
842
|
+
['var', 86088],
|
|
843
|
+
['else', 20563],
|
|
844
|
+
['for', 20567],
|
|
845
|
+
['new', 86107],
|
|
846
|
+
['in', 8673330],
|
|
847
|
+
['typeof', 16863275],
|
|
848
|
+
['while', 20578],
|
|
849
|
+
['case', 20556],
|
|
850
|
+
['break', 20555],
|
|
851
|
+
['try', 20577],
|
|
852
|
+
['catch', 20557],
|
|
853
|
+
['delete', 16863276],
|
|
854
|
+
['throw', 86112],
|
|
855
|
+
['switch', 86110],
|
|
856
|
+
['continue', 20559],
|
|
857
|
+
['default', 20561],
|
|
858
|
+
['instanceof', 8411187],
|
|
859
|
+
['do', 20562],
|
|
860
|
+
['void', 16863277],
|
|
861
|
+
['finally', 20566],
|
|
862
|
+
['async', 209005],
|
|
863
|
+
['await', 209006],
|
|
864
|
+
['class', 86094],
|
|
865
|
+
['const', 86090],
|
|
866
|
+
['constructor', 12399],
|
|
867
|
+
['debugger', 20560],
|
|
868
|
+
['export', 20564],
|
|
869
|
+
['extends', 20565],
|
|
870
|
+
['false', 86021],
|
|
871
|
+
['from', 209011],
|
|
872
|
+
['get', 209008],
|
|
873
|
+
['implements', 36964],
|
|
874
|
+
['import', 86106],
|
|
875
|
+
['interface', 36965],
|
|
876
|
+
['let', 241737],
|
|
877
|
+
['null', 86023],
|
|
878
|
+
['of', 471156],
|
|
879
|
+
['using', 209013],
|
|
880
|
+
['package', 36966],
|
|
881
|
+
['private', 36967],
|
|
882
|
+
['protected', 36968],
|
|
883
|
+
['public', 36969],
|
|
884
|
+
['set', 209009],
|
|
885
|
+
['static', 36970],
|
|
886
|
+
['super', 86109],
|
|
887
|
+
['true', 86022],
|
|
888
|
+
['with', 20579],
|
|
889
|
+
['yield', 241771],
|
|
890
|
+
['enum', 86134],
|
|
891
|
+
['eval', 537079927],
|
|
892
|
+
['as', 77932],
|
|
893
|
+
['arguments', 537079928],
|
|
894
|
+
['target', 209030],
|
|
895
|
+
['meta', 209031],
|
|
896
|
+
['accessor', 12402],
|
|
897
|
+
]);
|
|
898
|
+
const keywordLengths = [...descKeywordTable.keys()].map((keyword) => keyword.length);
|
|
899
|
+
const minKeywordLength = Math.min(...keywordLengths);
|
|
900
|
+
const maxKeywordLength = Math.max(...keywordLengths);
|
|
898
901
|
|
|
899
902
|
function scanIdentifier(parser, context, isValidAsKeyword) {
|
|
900
903
|
while (isIdPart[advanceChar(parser)])
|
|
901
904
|
;
|
|
902
905
|
parser.tokenValue = parser.source.slice(parser.tokenIndex, parser.index);
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
+
if (parser.currentChar === 92 || parser.currentChar > 0x7e) {
|
|
907
|
+
return scanIdentifierSlowCase(parser, context, 0, isValidAsKeyword);
|
|
908
|
+
}
|
|
909
|
+
const length = parser.index - parser.tokenIndex;
|
|
910
|
+
if (length < minKeywordLength || length > maxKeywordLength)
|
|
911
|
+
return 208897;
|
|
912
|
+
return descKeywordTable.get(parser.tokenValue) ?? 208897;
|
|
906
913
|
}
|
|
907
914
|
function scanUnicodeIdentifier(parser, context) {
|
|
908
915
|
const cookedChar = scanIdentifierUnicodeEscape(parser);
|
|
@@ -944,8 +951,8 @@ function scanIdentifierSlowCase(parser, context, hasEscape, isValidAsKeyword) {
|
|
|
944
951
|
parser.tokenValue += parser.source.slice(start, parser.index);
|
|
945
952
|
}
|
|
946
953
|
const { length } = parser.tokenValue;
|
|
947
|
-
if (isValidAsKeyword && length >=
|
|
948
|
-
const token =
|
|
954
|
+
if (isValidAsKeyword && length >= minKeywordLength && length <= maxKeywordLength) {
|
|
955
|
+
const token = descKeywordTable.get(parser.tokenValue);
|
|
949
956
|
if (token === void 0)
|
|
950
957
|
return 208897 | (hasEscape ? -2147483648 : 0);
|
|
951
958
|
if (!hasEscape)
|
|
@@ -1069,7 +1076,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1069
1076
|
while (CharTypes[char] & (64 | 4096)) {
|
|
1070
1077
|
if (char === 95) {
|
|
1071
1078
|
if (!allowSeparator)
|
|
1072
|
-
parser.report(
|
|
1079
|
+
parser.report(154);
|
|
1073
1080
|
allowSeparator = 0;
|
|
1074
1081
|
char = advanceChar(parser);
|
|
1075
1082
|
continue;
|
|
@@ -1080,7 +1087,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1080
1087
|
char = advanceChar(parser);
|
|
1081
1088
|
}
|
|
1082
1089
|
if (digits === 0 || !allowSeparator) {
|
|
1083
|
-
parser.report(digits === 0 ? 21 :
|
|
1090
|
+
parser.report(digits === 0 ? 21 : 155);
|
|
1084
1091
|
}
|
|
1085
1092
|
}
|
|
1086
1093
|
else if ((char | 32) === 111) {
|
|
@@ -1089,7 +1096,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1089
1096
|
while (CharTypes[char] & (32 | 4096)) {
|
|
1090
1097
|
if (char === 95) {
|
|
1091
1098
|
if (!allowSeparator) {
|
|
1092
|
-
parser.report(
|
|
1099
|
+
parser.report(154);
|
|
1093
1100
|
}
|
|
1094
1101
|
allowSeparator = 0;
|
|
1095
1102
|
char = advanceChar(parser);
|
|
@@ -1101,7 +1108,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1101
1108
|
char = advanceChar(parser);
|
|
1102
1109
|
}
|
|
1103
1110
|
if (digits === 0 || !allowSeparator) {
|
|
1104
|
-
parser.report(digits === 0 ? 0 :
|
|
1111
|
+
parser.report(digits === 0 ? 0 : 155);
|
|
1105
1112
|
}
|
|
1106
1113
|
}
|
|
1107
1114
|
else if ((char | 32) === 98) {
|
|
@@ -1110,7 +1117,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1110
1117
|
while (CharTypes[char] & (128 | 4096)) {
|
|
1111
1118
|
if (char === 95) {
|
|
1112
1119
|
if (!allowSeparator) {
|
|
1113
|
-
parser.report(
|
|
1120
|
+
parser.report(154);
|
|
1114
1121
|
}
|
|
1115
1122
|
allowSeparator = 0;
|
|
1116
1123
|
char = advanceChar(parser);
|
|
@@ -1122,7 +1129,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1122
1129
|
char = advanceChar(parser);
|
|
1123
1130
|
}
|
|
1124
1131
|
if (digits === 0 || !allowSeparator) {
|
|
1125
|
-
parser.report(digits === 0 ? 0 :
|
|
1132
|
+
parser.report(digits === 0 ? 0 : 155);
|
|
1126
1133
|
}
|
|
1127
1134
|
}
|
|
1128
1135
|
else if (CharTypes[char] & 32) {
|
|
@@ -1155,7 +1162,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1155
1162
|
if (char === 95) {
|
|
1156
1163
|
char = advanceChar(parser);
|
|
1157
1164
|
if (char === 95 || kind & 32) {
|
|
1158
|
-
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column },
|
|
1165
|
+
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 154);
|
|
1159
1166
|
}
|
|
1160
1167
|
allowSeparator = 1;
|
|
1161
1168
|
continue;
|
|
@@ -1166,7 +1173,7 @@ function scanNumber(parser, context, kind) {
|
|
|
1166
1173
|
--digit;
|
|
1167
1174
|
}
|
|
1168
1175
|
if (allowSeparator) {
|
|
1169
|
-
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column },
|
|
1176
|
+
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 155);
|
|
1170
1177
|
}
|
|
1171
1178
|
if (digit >= 0 && !isIdentifierStart(char) && char !== 46) {
|
|
1172
1179
|
parser.tokenValue = value;
|
|
@@ -1231,7 +1238,7 @@ function scanDecimalDigitsOrSeparator(parser, char) {
|
|
|
1231
1238
|
const { index } = parser;
|
|
1232
1239
|
char = advanceChar(parser);
|
|
1233
1240
|
if (char === 95) {
|
|
1234
|
-
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column },
|
|
1241
|
+
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 154);
|
|
1235
1242
|
}
|
|
1236
1243
|
allowSeparator = 1;
|
|
1237
1244
|
ret += parser.source.substring(start, index);
|
|
@@ -1242,7 +1249,7 @@ function scanDecimalDigitsOrSeparator(parser, char) {
|
|
|
1242
1249
|
char = advanceChar(parser);
|
|
1243
1250
|
}
|
|
1244
1251
|
if (allowSeparator) {
|
|
1245
|
-
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column },
|
|
1252
|
+
throw new ParseError(parser.currentLocation, { index: parser.index + 1, line: parser.line, column: parser.column }, 155);
|
|
1246
1253
|
}
|
|
1247
1254
|
return ret + parser.source.substring(start, parser.index);
|
|
1248
1255
|
}
|
|
@@ -1963,7 +1970,7 @@ function scanSingleToken(parser, context, state) {
|
|
|
1963
1970
|
advanceChar(parser);
|
|
1964
1971
|
if ((state & 1 || isStartOfLine) && parser.currentChar === 62) {
|
|
1965
1972
|
if (!parser.options.webcompat)
|
|
1966
|
-
parser.report(
|
|
1973
|
+
parser.report(114);
|
|
1967
1974
|
advanceChar(parser);
|
|
1968
1975
|
state = skipSingleHTMLComment(parser, source, state, context, 3, parser.tokenStart);
|
|
1969
1976
|
continue;
|
|
@@ -2192,10 +2199,10 @@ function reinterpretToPattern(parser, node) {
|
|
|
2192
2199
|
function validateBindingIdentifier(parser, context, kind, t, skipEvalArgCheck) {
|
|
2193
2200
|
if (context & 1) {
|
|
2194
2201
|
if ((t & 36864) === 36864) {
|
|
2195
|
-
parser.report(
|
|
2202
|
+
parser.report(120);
|
|
2196
2203
|
}
|
|
2197
2204
|
if (!skipEvalArgCheck && (t & 537079808) === 537079808) {
|
|
2198
|
-
parser.report(
|
|
2205
|
+
parser.report(121);
|
|
2199
2206
|
}
|
|
2200
2207
|
}
|
|
2201
2208
|
if ((t & 20480) === 20480 || t === -2147483527) {
|
|
@@ -2205,7 +2212,7 @@ function validateBindingIdentifier(parser, context, kind, t, skipEvalArgCheck) {
|
|
|
2205
2212
|
parser.report(100);
|
|
2206
2213
|
}
|
|
2207
2214
|
if (context & (2048 | 2) && t === 209006) {
|
|
2208
|
-
parser.report(
|
|
2215
|
+
parser.report(112);
|
|
2209
2216
|
}
|
|
2210
2217
|
if (context & (1024 | 1) && t === 241771) {
|
|
2211
2218
|
parser.report(97, 'yield');
|
|
@@ -2214,10 +2221,10 @@ function validateBindingIdentifier(parser, context, kind, t, skipEvalArgCheck) {
|
|
|
2214
2221
|
function validateFunctionName(parser, context, t) {
|
|
2215
2222
|
if (context & 1) {
|
|
2216
2223
|
if ((t & 36864) === 36864) {
|
|
2217
|
-
parser.report(
|
|
2224
|
+
parser.report(120);
|
|
2218
2225
|
}
|
|
2219
2226
|
if ((t & 537079808) === 537079808) {
|
|
2220
|
-
parser.report(
|
|
2227
|
+
parser.report(121);
|
|
2221
2228
|
}
|
|
2222
2229
|
if (t === -2147483526) {
|
|
2223
2230
|
parser.report(95);
|
|
@@ -2230,7 +2237,7 @@ function validateFunctionName(parser, context, t) {
|
|
|
2230
2237
|
parser.report(102);
|
|
2231
2238
|
}
|
|
2232
2239
|
if (context & (2048 | 2) && t === 209006) {
|
|
2233
|
-
parser.report(
|
|
2240
|
+
parser.report(112);
|
|
2234
2241
|
}
|
|
2235
2242
|
if (context & (1024 | 1) && t === 241771) {
|
|
2236
2243
|
parser.report(97, 'yield');
|
|
@@ -2239,7 +2246,10 @@ function validateFunctionName(parser, context, t) {
|
|
|
2239
2246
|
function isStrictReservedWord(parser, context, t) {
|
|
2240
2247
|
if (t === 209006) {
|
|
2241
2248
|
if (context & (2048 | 2))
|
|
2242
|
-
parser.report(
|
|
2249
|
+
parser.report(112);
|
|
2250
|
+
if ((parser.destructible & 128) === 0) {
|
|
2251
|
+
parser.firstAwaitLocation ??= { start: parser.tokenStart, end: parser.currentLocation };
|
|
2252
|
+
}
|
|
2243
2253
|
parser.destructible |= 128;
|
|
2244
2254
|
}
|
|
2245
2255
|
if (t === 241771 && context & 1024)
|
|
@@ -2255,7 +2265,7 @@ function isValidLabel(parser, labels, name, isIterationStatement) {
|
|
|
2255
2265
|
while (labels) {
|
|
2256
2266
|
if (labels['$' + name]) {
|
|
2257
2267
|
if (isIterationStatement)
|
|
2258
|
-
parser.report(
|
|
2268
|
+
parser.report(139);
|
|
2259
2269
|
return 1;
|
|
2260
2270
|
}
|
|
2261
2271
|
if (isIterationStatement && labels.loop)
|
|
@@ -2268,7 +2278,7 @@ function validateAndDeclareLabel(parser, labels, name) {
|
|
|
2268
2278
|
let set = labels;
|
|
2269
2279
|
while (set) {
|
|
2270
2280
|
if (set['$' + name])
|
|
2271
|
-
parser.report(
|
|
2281
|
+
parser.report(138, name);
|
|
2272
2282
|
set = set['$'];
|
|
2273
2283
|
}
|
|
2274
2284
|
labels['$' + name] = 1;
|
|
@@ -2296,14 +2306,14 @@ function isValidIdentifier(context, t) {
|
|
|
2296
2306
|
function classifyIdentifier(parser, context, t) {
|
|
2297
2307
|
if ((t & 537079808) === 537079808) {
|
|
2298
2308
|
if (context & 1)
|
|
2299
|
-
parser.report(
|
|
2309
|
+
parser.report(121);
|
|
2300
2310
|
parser.flags |= 512;
|
|
2301
2311
|
}
|
|
2302
2312
|
if (!isValidIdentifier(context, t))
|
|
2303
2313
|
parser.report(0);
|
|
2304
2314
|
}
|
|
2305
2315
|
|
|
2306
|
-
const entities = {
|
|
2316
|
+
const entities = new Map(Object.entries({
|
|
2307
2317
|
AElig: '\u00C6',
|
|
2308
2318
|
AMP: '\u0026',
|
|
2309
2319
|
Aacute: '\u00C1',
|
|
@@ -4429,8 +4439,8 @@ const entities = {
|
|
|
4429
4439
|
zscr: '\uD835\uDCCF',
|
|
4430
4440
|
zwj: '\u200D',
|
|
4431
4441
|
zwnj: '\u200C',
|
|
4432
|
-
};
|
|
4433
|
-
const decodeMap = {
|
|
4442
|
+
}));
|
|
4443
|
+
const decodeMap = new Map(Object.entries({
|
|
4434
4444
|
'0': 65533,
|
|
4435
4445
|
'128': 8364,
|
|
4436
4446
|
'130': 8218,
|
|
@@ -4459,7 +4469,7 @@ const decodeMap = {
|
|
|
4459
4469
|
'156': 339,
|
|
4460
4470
|
'158': 382,
|
|
4461
4471
|
'159': 376,
|
|
4462
|
-
};
|
|
4472
|
+
}).map(([key, value]) => [Number(key), value]));
|
|
4463
4473
|
function decodeHTMLStrict(text) {
|
|
4464
4474
|
return text.replaceAll(/&(?:[a-zA-Z]+|#[xX][\da-fA-F]+|#\d+);/g, (key) => {
|
|
4465
4475
|
if (key.charAt(1) === '#') {
|
|
@@ -4467,14 +4477,14 @@ function decodeHTMLStrict(text) {
|
|
|
4467
4477
|
const codePoint = secondChar === 'X' || secondChar === 'x' ? parseInt(key.slice(3), 16) : parseInt(key.slice(2), 10);
|
|
4468
4478
|
return decodeCodePoint(codePoint);
|
|
4469
4479
|
}
|
|
4470
|
-
return
|
|
4480
|
+
return entities.get(key.slice(1, -1)) ?? key;
|
|
4471
4481
|
});
|
|
4472
4482
|
}
|
|
4473
4483
|
function decodeCodePoint(codePoint) {
|
|
4474
4484
|
if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
|
|
4475
4485
|
return '\uFFFD';
|
|
4476
4486
|
}
|
|
4477
|
-
return String.fromCodePoint(
|
|
4487
|
+
return String.fromCodePoint(decodeMap.get(codePoint) ?? codePoint);
|
|
4478
4488
|
}
|
|
4479
4489
|
|
|
4480
4490
|
function scanJSXAttributeValue(parser, context) {
|
|
@@ -4521,6 +4531,12 @@ function nextJSXToken(parser) {
|
|
|
4521
4531
|
parser.setToken(2162700);
|
|
4522
4532
|
return;
|
|
4523
4533
|
}
|
|
4534
|
+
if (parser.currentChar === 125) {
|
|
4535
|
+
parser.report(180);
|
|
4536
|
+
}
|
|
4537
|
+
if (parser.currentChar === 62) {
|
|
4538
|
+
parser.report(181);
|
|
4539
|
+
}
|
|
4524
4540
|
let state = 0;
|
|
4525
4541
|
while (parser.index < parser.end) {
|
|
4526
4542
|
const type = CharTypes[parser.source.charCodeAt(parser.index)];
|
|
@@ -4559,6 +4575,8 @@ function rescanJSXIdentifier(parser) {
|
|
|
4559
4575
|
return parser.getToken();
|
|
4560
4576
|
}
|
|
4561
4577
|
|
|
4578
|
+
const nextFeatures = 1 | 2 | 4;
|
|
4579
|
+
|
|
4562
4580
|
function normalizeRanges(ranges) {
|
|
4563
4581
|
if (!ranges)
|
|
4564
4582
|
return undefined;
|
|
@@ -4571,17 +4589,27 @@ function normalizeRanges(ranges) {
|
|
|
4571
4589
|
};
|
|
4572
4590
|
}
|
|
4573
4591
|
function normalizeOptions(rawOptions) {
|
|
4574
|
-
|
|
4592
|
+
let { features, next, ranges, module, sourceType, globalReturn, ...restOptions } = {
|
|
4575
4593
|
validateRegex: true,
|
|
4594
|
+
features: 0,
|
|
4576
4595
|
...rawOptions,
|
|
4577
|
-
ranges: normalizeRanges(rawOptions.ranges),
|
|
4578
4596
|
};
|
|
4579
|
-
if (
|
|
4580
|
-
|
|
4597
|
+
if (next) {
|
|
4598
|
+
features |= nextFeatures;
|
|
4581
4599
|
}
|
|
4582
|
-
|
|
4583
|
-
|
|
4600
|
+
ranges = normalizeRanges(ranges);
|
|
4601
|
+
if (module && !sourceType) {
|
|
4602
|
+
sourceType = 'module';
|
|
4584
4603
|
}
|
|
4604
|
+
if (globalReturn && (!sourceType || sourceType === 'script')) {
|
|
4605
|
+
sourceType = 'commonjs';
|
|
4606
|
+
}
|
|
4607
|
+
const options = {
|
|
4608
|
+
...restOptions,
|
|
4609
|
+
ranges,
|
|
4610
|
+
features,
|
|
4611
|
+
sourceType,
|
|
4612
|
+
};
|
|
4585
4613
|
return options;
|
|
4586
4614
|
}
|
|
4587
4615
|
|
|
@@ -4602,7 +4630,7 @@ class PrivateScope {
|
|
|
4602
4630
|
const value = privateIdentifiers.get(name);
|
|
4603
4631
|
if (this.hasPrivateIdentifier(name) &&
|
|
4604
4632
|
((value & 32) !== (focusKind & 32) || value & focusKind & 768)) {
|
|
4605
|
-
this.parser.report(
|
|
4633
|
+
this.parser.report(148, name);
|
|
4606
4634
|
}
|
|
4607
4635
|
privateIdentifiers.set(name, this.hasPrivateIdentifier(name) ? value | focusKind : focusKind);
|
|
4608
4636
|
}
|
|
@@ -4663,17 +4691,17 @@ class Scope {
|
|
|
4663
4691
|
((kind & 128 && value & 68) ||
|
|
4664
4692
|
(value & 128 && kind & 68))) ;
|
|
4665
4693
|
else {
|
|
4666
|
-
parser.report(
|
|
4694
|
+
parser.report(147, name);
|
|
4667
4695
|
}
|
|
4668
4696
|
}
|
|
4669
4697
|
if (currentScope === this) {
|
|
4670
4698
|
if (value && value & 1 && kind & 1) {
|
|
4671
|
-
currentScope.recordScopeError(
|
|
4699
|
+
currentScope.recordScopeError(147, name);
|
|
4672
4700
|
}
|
|
4673
4701
|
}
|
|
4674
4702
|
if (value &&
|
|
4675
4703
|
(value & 256 || (value & 512 && !parser.options.webcompat))) {
|
|
4676
|
-
parser.report(
|
|
4704
|
+
parser.report(147, name);
|
|
4677
4705
|
}
|
|
4678
4706
|
currentScope.variableBindings.set(name, kind);
|
|
4679
4707
|
currentScope = currentScope.parent;
|
|
@@ -4682,12 +4710,12 @@ class Scope {
|
|
|
4682
4710
|
hasVariable(name) {
|
|
4683
4711
|
return this.variableBindings.has(name);
|
|
4684
4712
|
}
|
|
4685
|
-
addBlockName(context, name, kind, origin) {
|
|
4713
|
+
addBlockName(context, name, kind, origin = 0) {
|
|
4686
4714
|
const { parser } = this;
|
|
4687
4715
|
const value = this.variableBindings.get(name);
|
|
4688
4716
|
if (value && (value & 2) === 0) {
|
|
4689
4717
|
if (kind & 1) {
|
|
4690
|
-
this.recordScopeError(
|
|
4718
|
+
this.recordScopeError(147, name);
|
|
4691
4719
|
}
|
|
4692
4720
|
else if (parser.options.webcompat &&
|
|
4693
4721
|
(context & 1) === 0 &&
|
|
@@ -4695,22 +4723,22 @@ class Scope {
|
|
|
4695
4723
|
value === 64 &&
|
|
4696
4724
|
kind === 64) ;
|
|
4697
4725
|
else {
|
|
4698
|
-
parser.report(
|
|
4726
|
+
parser.report(147, name);
|
|
4699
4727
|
}
|
|
4700
4728
|
}
|
|
4701
4729
|
if (this.type & 64 &&
|
|
4702
4730
|
this.parent?.hasVariable(name) &&
|
|
4703
4731
|
(this.parent.variableBindings.get(name) & 2) === 0) {
|
|
4704
|
-
parser.report(
|
|
4732
|
+
parser.report(147, name);
|
|
4705
4733
|
}
|
|
4706
4734
|
if (this.type & 512 && value && (value & 2) === 0) {
|
|
4707
4735
|
if (kind & 1) {
|
|
4708
|
-
this.recordScopeError(
|
|
4736
|
+
this.recordScopeError(147, name);
|
|
4709
4737
|
}
|
|
4710
4738
|
}
|
|
4711
4739
|
if (this.type & 32) {
|
|
4712
4740
|
if (this.parent.variableBindings.get(name) & 768)
|
|
4713
|
-
parser.report(
|
|
4741
|
+
parser.report(161, name);
|
|
4714
4742
|
}
|
|
4715
4743
|
this.variableBindings.set(name, kind);
|
|
4716
4744
|
}
|
|
@@ -4732,7 +4760,7 @@ class Scope {
|
|
|
4732
4760
|
}
|
|
4733
4761
|
function createArrowHeadParsingScope(parser, context, value) {
|
|
4734
4762
|
const scope = parser.createScope().createChildScope(512);
|
|
4735
|
-
scope.addBlockName(context, value, 1
|
|
4763
|
+
scope.addBlockName(context, value, 1);
|
|
4736
4764
|
return scope;
|
|
4737
4765
|
}
|
|
4738
4766
|
|
|
@@ -4742,6 +4770,7 @@ class Parser {
|
|
|
4742
4770
|
options;
|
|
4743
4771
|
token = 1048576;
|
|
4744
4772
|
flags = 0;
|
|
4773
|
+
features = 0;
|
|
4745
4774
|
index = 0;
|
|
4746
4775
|
line = 1;
|
|
4747
4776
|
column = 0;
|
|
@@ -4761,12 +4790,14 @@ class Parser {
|
|
|
4761
4790
|
assignable = 0;
|
|
4762
4791
|
destructible = 0;
|
|
4763
4792
|
strictReservedRange = null;
|
|
4793
|
+
firstAwaitLocation = null;
|
|
4764
4794
|
leadingDecorators = { decorators: [] };
|
|
4765
4795
|
constructor(source, rawOptions = {}) {
|
|
4766
4796
|
this.source = source;
|
|
4767
4797
|
this.end = source.length;
|
|
4768
4798
|
this.currentChar = source.charCodeAt(0);
|
|
4769
4799
|
this.options = normalizeOptions(rawOptions);
|
|
4800
|
+
this.features = this.options.features;
|
|
4770
4801
|
if (Array.isArray(this.options.onComment)) {
|
|
4771
4802
|
this.options.onComment = pushComment(this.options.onComment, this.options);
|
|
4772
4803
|
}
|
|
@@ -4847,7 +4878,7 @@ class Parser {
|
|
|
4847
4878
|
declareUnboundVariable(name) {
|
|
4848
4879
|
const { exportedNames } = this;
|
|
4849
4880
|
if (exportedNames.has(name)) {
|
|
4850
|
-
this.report(
|
|
4881
|
+
this.report(149, name);
|
|
4851
4882
|
}
|
|
4852
4883
|
exportedNames.add(name);
|
|
4853
4884
|
}
|
|
@@ -4870,29 +4901,10 @@ class Parser {
|
|
|
4870
4901
|
return undefined;
|
|
4871
4902
|
}
|
|
4872
4903
|
cloneIdentifier(original) {
|
|
4873
|
-
return
|
|
4904
|
+
return structuredClone(original);
|
|
4874
4905
|
}
|
|
4875
4906
|
cloneStringLiteral(original) {
|
|
4876
|
-
return
|
|
4877
|
-
}
|
|
4878
|
-
cloneLocationInformation(node, original) {
|
|
4879
|
-
const { ranges } = this.options;
|
|
4880
|
-
if (ranges) {
|
|
4881
|
-
if (ranges.start)
|
|
4882
|
-
node.start = original.start;
|
|
4883
|
-
if (ranges.end)
|
|
4884
|
-
node.end = original.end;
|
|
4885
|
-
if (ranges.range)
|
|
4886
|
-
node.range = [...original.range];
|
|
4887
|
-
}
|
|
4888
|
-
if (this.options.loc) {
|
|
4889
|
-
node.loc = {
|
|
4890
|
-
...original.loc,
|
|
4891
|
-
start: { ...original.loc.start },
|
|
4892
|
-
end: { ...original.loc.end },
|
|
4893
|
-
};
|
|
4894
|
-
}
|
|
4895
|
-
return node;
|
|
4907
|
+
return structuredClone(original);
|
|
4896
4908
|
}
|
|
4897
4909
|
}
|
|
4898
4910
|
function pushComment(comments, options) {
|
|
@@ -4955,7 +4967,7 @@ function parseSource(source, rawOptions = {}, context = 0) {
|
|
|
4955
4967
|
if (scope) {
|
|
4956
4968
|
for (const name of parser.exportedBindings) {
|
|
4957
4969
|
if (!scope.hasVariable(name))
|
|
4958
|
-
parser.report(
|
|
4970
|
+
parser.report(150, name);
|
|
4959
4971
|
}
|
|
4960
4972
|
}
|
|
4961
4973
|
}
|
|
@@ -4987,7 +4999,7 @@ function parseStatementList(parser, context, scope) {
|
|
|
4987
4999
|
statements.push(parseDirective(parser, context, expr, token, tokenStart));
|
|
4988
5000
|
}
|
|
4989
5001
|
while (parser.getToken() !== 1048576) {
|
|
4990
|
-
statements.push(parseStatementListItem(parser, context, scope, undefined,
|
|
5002
|
+
statements.push(parseStatementListItem(parser, context, scope, undefined, {}, 4));
|
|
4991
5003
|
}
|
|
4992
5004
|
return statements;
|
|
4993
5005
|
}
|
|
@@ -5017,36 +5029,42 @@ function parseModuleItem(parser, context, scope) {
|
|
|
5017
5029
|
moduleItem = parseExportDeclaration(parser, context, scope);
|
|
5018
5030
|
break;
|
|
5019
5031
|
case 86106:
|
|
5032
|
+
if (parser.leadingDecorators.decorators.length) {
|
|
5033
|
+
parser.report(172);
|
|
5034
|
+
}
|
|
5020
5035
|
moduleItem = parseImportDeclaration(parser, context, scope);
|
|
5021
5036
|
break;
|
|
5022
5037
|
default:
|
|
5023
|
-
moduleItem = parseStatementListItem(parser, context, scope, undefined,
|
|
5024
|
-
}
|
|
5025
|
-
if (parser.leadingDecorators?.decorators.length) {
|
|
5026
|
-
parser.report(170);
|
|
5038
|
+
moduleItem = parseStatementListItem(parser, context, scope, undefined, {}, 4);
|
|
5027
5039
|
}
|
|
5028
5040
|
return moduleItem;
|
|
5029
5041
|
}
|
|
5030
|
-
function parseStatementListItem(parser, context, scope, privateScope,
|
|
5042
|
+
function parseStatementListItem(parser, context, scope, privateScope, labels, origin = 2) {
|
|
5031
5043
|
const start = parser.tokenStart;
|
|
5044
|
+
if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
|
|
5045
|
+
parser.report(172);
|
|
5046
|
+
}
|
|
5032
5047
|
switch (parser.getToken()) {
|
|
5033
5048
|
case 86104:
|
|
5034
|
-
return parseFunctionDeclaration(parser, context, scope, privateScope,
|
|
5049
|
+
return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 0, start, origin);
|
|
5035
5050
|
case 133:
|
|
5051
|
+
if (!(parser.features & 1)) {
|
|
5052
|
+
parser.report(30, '@');
|
|
5053
|
+
}
|
|
5036
5054
|
case 86094:
|
|
5037
5055
|
return parseClassDeclaration(parser, context, scope, privateScope, 0);
|
|
5038
5056
|
case 86090:
|
|
5039
|
-
return parseLexicalDeclaration(parser, context, scope, privateScope, 16
|
|
5057
|
+
return parseLexicalDeclaration(parser, context, scope, privateScope, 16);
|
|
5040
5058
|
case 241737:
|
|
5041
5059
|
return parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateScope, origin);
|
|
5042
5060
|
case 209013:
|
|
5043
|
-
return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope,
|
|
5061
|
+
return parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
|
|
5044
5062
|
case 209006:
|
|
5045
5063
|
if ((context & 2048 || (context & 2 && context & 8)) &&
|
|
5046
5064
|
nextTokenIsUsingOnSameLine(parser)) {
|
|
5047
|
-
return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope,
|
|
5065
|
+
return parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin);
|
|
5048
5066
|
}
|
|
5049
|
-
return parseStatement(parser, context, scope, privateScope,
|
|
5067
|
+
return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
|
|
5050
5068
|
case 20564:
|
|
5051
5069
|
parser.report(103, 'export');
|
|
5052
5070
|
case 86106:
|
|
@@ -5060,15 +5078,15 @@ function parseStatementListItem(parser, context, scope, privateScope, origin, la
|
|
|
5060
5078
|
parser.report(103, 'import');
|
|
5061
5079
|
}
|
|
5062
5080
|
case 209005:
|
|
5063
|
-
return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope,
|
|
5081
|
+
return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 1, origin);
|
|
5064
5082
|
default:
|
|
5065
|
-
return parseStatement(parser, context, scope, privateScope,
|
|
5083
|
+
return parseStatement(parser, context, scope, privateScope, labels, 1, origin);
|
|
5066
5084
|
}
|
|
5067
5085
|
}
|
|
5068
|
-
function parseStatement(parser, context, scope, privateScope,
|
|
5086
|
+
function parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin = 0) {
|
|
5069
5087
|
switch (parser.getToken()) {
|
|
5070
5088
|
case 86088:
|
|
5071
|
-
return parseVariableStatement(parser, context, scope, privateScope
|
|
5089
|
+
return parseVariableStatement(parser, context, scope, privateScope);
|
|
5072
5090
|
case 20572:
|
|
5073
5091
|
return parseReturnStatement(parser, context, privateScope);
|
|
5074
5092
|
case 20569:
|
|
@@ -5098,11 +5116,11 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
|
|
|
5098
5116
|
case 20560:
|
|
5099
5117
|
return parseDebuggerStatement(parser, context);
|
|
5100
5118
|
case 209005:
|
|
5101
|
-
return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope,
|
|
5119
|
+
return parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, 0, origin);
|
|
5102
5120
|
case 20557:
|
|
5103
|
-
parser.report(
|
|
5121
|
+
parser.report(164);
|
|
5104
5122
|
case 20566:
|
|
5105
|
-
parser.report(
|
|
5123
|
+
parser.report(165);
|
|
5106
5124
|
case 86104:
|
|
5107
5125
|
parser.report(context & 1
|
|
5108
5126
|
? 76
|
|
@@ -5112,10 +5130,10 @@ function parseStatement(parser, context, scope, privateScope, origin, labels, al
|
|
|
5112
5130
|
case 86094:
|
|
5113
5131
|
parser.report(79);
|
|
5114
5132
|
default:
|
|
5115
|
-
return parseExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5133
|
+
return parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
|
|
5116
5134
|
}
|
|
5117
5135
|
}
|
|
5118
|
-
function parseExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5136
|
+
function parseExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
|
|
5119
5137
|
const { tokenValue, tokenStart } = parser;
|
|
5120
5138
|
const token = parser.getToken();
|
|
5121
5139
|
let expr;
|
|
@@ -5130,11 +5148,11 @@ function parseExpressionOrLabelledStatement(parser, context, scope, privateScope
|
|
|
5130
5148
|
default:
|
|
5131
5149
|
expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, parser.tokenStart);
|
|
5132
5150
|
}
|
|
5133
|
-
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5151
|
+
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, expr, token, tokenValue, tokenStart, origin);
|
|
5134
5152
|
}
|
|
5135
|
-
function finishExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5153
|
+
function finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, allowFuncDecl, initialExpression, token, tokenValue, tokenStart, origin) {
|
|
5136
5154
|
if (token & 143360 && parser.getToken() === 21) {
|
|
5137
|
-
return parseLabelledStatement(parser, context, scope, privateScope,
|
|
5155
|
+
return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, initialExpression, token, allowFuncDecl, tokenStart, origin);
|
|
5138
5156
|
}
|
|
5139
5157
|
let expression = parseMemberOrUpdateExpression(parser, context, privateScope, initialExpression, 0, 0, tokenStart);
|
|
5140
5158
|
expression = parseAssignmentExpression(parser, context, privateScope, 0, 0, tokenStart, expression);
|
|
@@ -5147,7 +5165,7 @@ function parseBlock(parser, context, scope, privateScope, labels, start = parser
|
|
|
5147
5165
|
const body = [];
|
|
5148
5166
|
consume(parser, context | 32, 2162700);
|
|
5149
5167
|
while (parser.getToken() !== 1074790415) {
|
|
5150
|
-
body.push(parseStatementListItem(parser, context, scope, privateScope,
|
|
5168
|
+
body.push(parseStatementListItem(parser, context, scope, privateScope, { $: labels }));
|
|
5151
5169
|
}
|
|
5152
5170
|
consume(parser, context | 32, 1074790415);
|
|
5153
5171
|
return parser.finishNode({
|
|
@@ -5176,7 +5194,7 @@ function parseExpressionStatement(parser, context, expression, start) {
|
|
|
5176
5194
|
expression,
|
|
5177
5195
|
}, start);
|
|
5178
5196
|
}
|
|
5179
|
-
function parseLabelledStatement(parser, context, scope, privateScope,
|
|
5197
|
+
function parseLabelledStatement(parser, context, scope, privateScope, labels, value, expr, token, allowFuncDecl, start, origin) {
|
|
5180
5198
|
validateBindingIdentifier(parser, context, 0, token, 1);
|
|
5181
5199
|
validateAndDeclareLabel(parser, labels, value);
|
|
5182
5200
|
nextToken(parser, context | 32);
|
|
@@ -5184,27 +5202,27 @@ function parseLabelledStatement(parser, context, scope, privateScope, origin, la
|
|
|
5184
5202
|
(context & 1) === 0 &&
|
|
5185
5203
|
parser.options.webcompat &&
|
|
5186
5204
|
parser.getToken() === 86104
|
|
5187
|
-
? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope,
|
|
5188
|
-
: parseStatement(parser, context, scope, privateScope,
|
|
5205
|
+
? parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, parser.tokenStart, origin)
|
|
5206
|
+
: parseStatement(parser, context, scope, privateScope, labels, allowFuncDecl, origin);
|
|
5189
5207
|
return parser.finishNode({
|
|
5190
5208
|
type: 'LabeledStatement',
|
|
5191
5209
|
label: expr,
|
|
5192
5210
|
body,
|
|
5193
5211
|
}, start);
|
|
5194
5212
|
}
|
|
5195
|
-
function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope,
|
|
5213
|
+
function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, privateScope, labels, allowFuncDecl, origin) {
|
|
5196
5214
|
const { tokenValue, tokenStart: start } = parser;
|
|
5197
5215
|
const token = parser.getToken();
|
|
5198
5216
|
let expr = parseIdentifier(parser, context);
|
|
5199
5217
|
if (parser.getToken() === 21) {
|
|
5200
|
-
return parseLabelledStatement(parser, context, scope, privateScope,
|
|
5218
|
+
return parseLabelledStatement(parser, context, scope, privateScope, labels, tokenValue, expr, token, 1, start, origin);
|
|
5201
5219
|
}
|
|
5202
5220
|
const asyncNewLine = parser.flags & 1;
|
|
5203
5221
|
if (!asyncNewLine) {
|
|
5204
5222
|
if (parser.getToken() === 86104) {
|
|
5205
5223
|
if (!allowFuncDecl)
|
|
5206
|
-
parser.report(
|
|
5207
|
-
return parseFunctionDeclaration(parser, context, scope, privateScope,
|
|
5224
|
+
parser.report(125);
|
|
5225
|
+
return parseFunctionDeclaration(parser, context, scope, privateScope, 1, 0, 1, start, origin);
|
|
5208
5226
|
}
|
|
5209
5227
|
if (isValidIdentifier(context, parser.getToken())) {
|
|
5210
5228
|
expr = parseAsyncArrowAfterIdent(parser, context, privateScope, 1, start);
|
|
@@ -5214,7 +5232,7 @@ function parseAsyncArrowOrAsyncFunctionDeclaration(parser, context, scope, priva
|
|
|
5214
5232
|
}
|
|
5215
5233
|
}
|
|
5216
5234
|
if (parser.getToken() === 67174411) {
|
|
5217
|
-
expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1,
|
|
5235
|
+
expr = parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, 1, 1, asyncNewLine, start);
|
|
5218
5236
|
}
|
|
5219
5237
|
else {
|
|
5220
5238
|
if (parser.getToken() === 10) {
|
|
@@ -5300,8 +5318,8 @@ function parseConsequentOrAlternative(parser, context, scope, privateScope, labe
|
|
|
5300
5318
|
return context & 1 ||
|
|
5301
5319
|
!parser.options.webcompat ||
|
|
5302
5320
|
parser.getToken() !== 86104
|
|
5303
|
-
? parseStatement(parser, context, scope, privateScope,
|
|
5304
|
-
: parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0,
|
|
5321
|
+
? parseStatement(parser, context, scope, privateScope, { $: labels }, 0)
|
|
5322
|
+
: parseFunctionDeclaration(parser, context, scope?.createChildScope(), privateScope, 0, 0, 0, tokenStart);
|
|
5305
5323
|
}
|
|
5306
5324
|
function parseSwitchStatement(parser, context, scope, privateScope, labels) {
|
|
5307
5325
|
const start = parser.tokenStart;
|
|
@@ -5330,7 +5348,7 @@ function parseSwitchStatement(parser, context, scope, privateScope, labels) {
|
|
|
5330
5348
|
while (parser.getToken() !== 20556 &&
|
|
5331
5349
|
parser.getToken() !== 1074790415 &&
|
|
5332
5350
|
parser.getToken() !== 20561) {
|
|
5333
|
-
const statement = parseStatementListItem(parser, context | 4, scope, privateScope,
|
|
5351
|
+
const statement = parseStatementListItem(parser, context | 4, scope, privateScope, {
|
|
5334
5352
|
$: labels,
|
|
5335
5353
|
});
|
|
5336
5354
|
if (statement.type === 'VariableDeclaration' &&
|
|
@@ -5366,7 +5384,7 @@ function parseWhileStatement(parser, context, scope, privateScope, labels) {
|
|
|
5366
5384
|
}, start);
|
|
5367
5385
|
}
|
|
5368
5386
|
function parseIterationStatementBody(parser, context, scope, privateScope, labels) {
|
|
5369
|
-
return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope,
|
|
5387
|
+
return parseStatement(parser, ((context | 131072) ^ 131072) | 128, scope, privateScope, { loop: 1, $: labels }, 0);
|
|
5370
5388
|
}
|
|
5371
5389
|
function parseContinueStatement(parser, context, labels) {
|
|
5372
5390
|
if ((context & 128) === 0)
|
|
@@ -5378,7 +5396,7 @@ function parseContinueStatement(parser, context, labels) {
|
|
|
5378
5396
|
const { tokenValue } = parser;
|
|
5379
5397
|
label = parseIdentifier(parser, context | 32);
|
|
5380
5398
|
if (!isValidLabel(parser, labels, tokenValue, 1))
|
|
5381
|
-
parser.report(
|
|
5399
|
+
parser.report(140, tokenValue);
|
|
5382
5400
|
}
|
|
5383
5401
|
matchOrInsertSemicolon(parser, context | 32);
|
|
5384
5402
|
return parser.finishNode({
|
|
@@ -5394,7 +5412,7 @@ function parseBreakStatement(parser, context, labels) {
|
|
|
5394
5412
|
const { tokenValue } = parser;
|
|
5395
5413
|
label = parseIdentifier(parser, context | 32);
|
|
5396
5414
|
if (!isValidLabel(parser, labels, tokenValue, 0))
|
|
5397
|
-
parser.report(
|
|
5415
|
+
parser.report(140, tokenValue);
|
|
5398
5416
|
}
|
|
5399
5417
|
else if ((context & (4 | 128)) === 0) {
|
|
5400
5418
|
parser.report(69);
|
|
@@ -5413,7 +5431,7 @@ function parseWithStatement(parser, context, scope, privateScope, labels) {
|
|
|
5413
5431
|
consume(parser, context | 32, 67174411);
|
|
5414
5432
|
const object = parseExpressions(parser, context, privateScope, 0, 1, parser.tokenStart);
|
|
5415
5433
|
consume(parser, context | 32, 16);
|
|
5416
|
-
const body = parseStatement(parser, context, scope, privateScope,
|
|
5434
|
+
const body = parseStatement(parser, context, scope, privateScope, labels, 0, 2);
|
|
5417
5435
|
return parser.finishNode({
|
|
5418
5436
|
type: 'WithStatement',
|
|
5419
5437
|
object,
|
|
@@ -5460,7 +5478,7 @@ function parseCatchBlock(parser, context, scope, privateScope, labels, start) {
|
|
|
5460
5478
|
scope = scope?.createChildScope(4);
|
|
5461
5479
|
param = parseBindingPattern(parser, context, scope, privateScope, (parser.getToken() & 2097152) === 2097152
|
|
5462
5480
|
? 256
|
|
5463
|
-
: 512
|
|
5481
|
+
: 512);
|
|
5464
5482
|
if (parser.getToken() === 18) {
|
|
5465
5483
|
parser.report(86);
|
|
5466
5484
|
}
|
|
@@ -5509,7 +5527,7 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
|
|
|
5509
5527
|
let expr = parseIdentifier(parser, context);
|
|
5510
5528
|
if (parser.getToken() & (143360 | 2097152) &&
|
|
5511
5529
|
(parser.getToken() & 20480) !== 20480) {
|
|
5512
|
-
const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8
|
|
5530
|
+
const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 8);
|
|
5513
5531
|
matchOrInsertSemicolon(parser, context | 32);
|
|
5514
5532
|
return parser.finishNode({
|
|
5515
5533
|
type: 'VariableDeclaration',
|
|
@@ -5521,7 +5539,7 @@ function parseLetIdentOrVarDeclarationStatement(parser, context, scope, privateS
|
|
|
5521
5539
|
if (context & 1)
|
|
5522
5540
|
parser.report(85);
|
|
5523
5541
|
if (parser.getToken() === 21) {
|
|
5524
|
-
return parseLabelledStatement(parser, context, scope, privateScope,
|
|
5542
|
+
return parseLabelledStatement(parser, context, scope, privateScope, {}, tokenValue, expr, token, 0, tokenStart, origin);
|
|
5525
5543
|
}
|
|
5526
5544
|
if (parser.getToken() === 10) {
|
|
5527
5545
|
let scope = void 0;
|
|
@@ -5575,23 +5593,26 @@ function nextTokenIsUsingOnSameLine(parser) {
|
|
|
5575
5593
|
function isResourceBindingStart(token) {
|
|
5576
5594
|
return (token & 143360) === 143360 && (token & 20480) !== 20480;
|
|
5577
5595
|
}
|
|
5578
|
-
function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope,
|
|
5596
|
+
function parseUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
|
|
5579
5597
|
const { tokenStart, tokenValue } = parser;
|
|
5580
5598
|
const token = parser.getToken();
|
|
5581
5599
|
const expression = parseIdentifier(parser, context);
|
|
5582
5600
|
if ((parser.flags & 1) === 0 && isResourceBindingStart(parser.getToken())) {
|
|
5583
|
-
if (origin & 4 &&
|
|
5601
|
+
if (origin & 4 &&
|
|
5602
|
+
context & 8 &&
|
|
5603
|
+
(context & 2) === 0 &&
|
|
5604
|
+
(context & 4096) === 0) {
|
|
5584
5605
|
parser.report(30, KeywordDescTable[parser.getToken() & 255]);
|
|
5585
5606
|
}
|
|
5586
5607
|
return parseLexicalDeclaration(parser, context, scope, privateScope, 16, origin, 'using', tokenStart, 1);
|
|
5587
5608
|
}
|
|
5588
5609
|
parser.assignable = 1;
|
|
5589
|
-
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5610
|
+
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 1, expression, token, tokenValue, tokenStart, origin);
|
|
5590
5611
|
}
|
|
5591
|
-
function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope,
|
|
5612
|
+
function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope, privateScope, labels, origin) {
|
|
5592
5613
|
const start = parser.tokenStart;
|
|
5593
5614
|
if (context & 524288)
|
|
5594
|
-
parser.report(
|
|
5615
|
+
parser.report(179);
|
|
5595
5616
|
nextToken(parser, context | 32);
|
|
5596
5617
|
let argument;
|
|
5597
5618
|
if ((parser.flags & 1) === 0 && parser.getToken() === 209013) {
|
|
@@ -5612,9 +5633,9 @@ function parseAwaitUsingDeclarationOrExpressionStatement(parser, context, scope,
|
|
|
5612
5633
|
type: 'AwaitExpression',
|
|
5613
5634
|
argument,
|
|
5614
5635
|
}, start);
|
|
5615
|
-
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope,
|
|
5636
|
+
return finishExpressionOrLabelledStatement(parser, context, scope, privateScope, labels, 0, expression, 1048576, '', start, origin);
|
|
5616
5637
|
}
|
|
5617
|
-
function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
|
|
5638
|
+
function parseLexicalDeclaration(parser, context, scope, privateScope, kind, origin = 0, declarationKind, declarationStart = parser.tokenStart, keywordConsumed = 0) {
|
|
5618
5639
|
const start = declarationStart;
|
|
5619
5640
|
if (!keywordConsumed)
|
|
5620
5641
|
nextToken(parser, context);
|
|
@@ -5626,7 +5647,7 @@ function parseLexicalDeclaration(parser, context, scope, privateScope, kind, ori
|
|
|
5626
5647
|
declarations,
|
|
5627
5648
|
}, start);
|
|
5628
5649
|
}
|
|
5629
|
-
function parseVariableStatement(parser, context, scope, privateScope, origin) {
|
|
5650
|
+
function parseVariableStatement(parser, context, scope, privateScope, origin = 0) {
|
|
5630
5651
|
const start = parser.tokenStart;
|
|
5631
5652
|
nextToken(parser, context);
|
|
5632
5653
|
const declarations = parseVariableDeclarationList(parser, context, scope, privateScope, 4, origin);
|
|
@@ -5637,7 +5658,7 @@ function parseVariableStatement(parser, context, scope, privateScope, origin) {
|
|
|
5637
5658
|
declarations,
|
|
5638
5659
|
}, start);
|
|
5639
5660
|
}
|
|
5640
|
-
function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin, declarationKind) {
|
|
5661
|
+
function parseVariableDeclarationList(parser, context, scope, privateScope, kind, origin = 0, declarationKind) {
|
|
5641
5662
|
let bindingCount = 1;
|
|
5642
5663
|
const firstDeclaration = parseVariableDeclaration(parser, context, scope, privateScope, kind, origin, declarationKind);
|
|
5643
5664
|
const list = [firstDeclaration];
|
|
@@ -5648,7 +5669,7 @@ function parseVariableDeclarationList(parser, context, scope, privateScope, kind
|
|
|
5648
5669
|
if (resourceNames) {
|
|
5649
5670
|
const { name } = declaration.id;
|
|
5650
5671
|
if (resourceNames.has(name))
|
|
5651
|
-
parser.report(
|
|
5672
|
+
parser.report(147, name);
|
|
5652
5673
|
resourceNames.add(name);
|
|
5653
5674
|
}
|
|
5654
5675
|
list.push(declaration);
|
|
@@ -5668,11 +5689,14 @@ function parseVariableDeclaration(parser, context, scope, privateScope, kind, or
|
|
|
5668
5689
|
const id = parseBindingPattern(parser, context, scope, privateScope, kind, origin);
|
|
5669
5690
|
if (parser.getToken() === 1077936155) {
|
|
5670
5691
|
nextToken(parser, context | 32);
|
|
5671
|
-
init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart);
|
|
5692
|
+
init = parseExpression(parser, context, privateScope, 1, 0, parser.tokenStart, origin);
|
|
5672
5693
|
if (origin & 32) {
|
|
5673
5694
|
if (parser.getToken() === 471156 ||
|
|
5674
5695
|
(parser.getToken() === 8673330 &&
|
|
5675
|
-
(token & 2097152 ||
|
|
5696
|
+
(token & 2097152 ||
|
|
5697
|
+
(kind & 4) === 0 ||
|
|
5698
|
+
context & 1 ||
|
|
5699
|
+
!parser.options.webcompat))) {
|
|
5676
5700
|
throw new ParseError(tokenStart, parser.currentLocation, 60, parser.getToken() === 471156 ? 'of' : 'in');
|
|
5677
5701
|
}
|
|
5678
5702
|
}
|
|
@@ -5727,7 +5751,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
|
|
|
5727
5751
|
parser.assignable = 1;
|
|
5728
5752
|
init = parseMemberOrUpdateExpression(parser, context, privateScope, init, 0, 0, tokenStart);
|
|
5729
5753
|
if (parser.getToken() === 471156)
|
|
5730
|
-
parser.report(
|
|
5754
|
+
parser.report(117);
|
|
5731
5755
|
}
|
|
5732
5756
|
}
|
|
5733
5757
|
else if (token === 209013) {
|
|
@@ -5779,7 +5803,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
|
|
|
5779
5803
|
if (resourceNames) {
|
|
5780
5804
|
const { name } = declaration.id;
|
|
5781
5805
|
if (resourceNames.has(name))
|
|
5782
|
-
parser.report(
|
|
5806
|
+
parser.report(147, name);
|
|
5783
5807
|
resourceNames.add(name);
|
|
5784
5808
|
}
|
|
5785
5809
|
declarations.push(declaration);
|
|
@@ -5824,7 +5848,7 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
|
|
|
5824
5848
|
else if (token === 209006 &&
|
|
5825
5849
|
(context & 2048 || (context & 2 && context & 8))) {
|
|
5826
5850
|
if (context & 524288)
|
|
5827
|
-
parser.report(
|
|
5851
|
+
parser.report(179);
|
|
5828
5852
|
nextToken(parser, context | 32);
|
|
5829
5853
|
let awaitArgument;
|
|
5830
5854
|
if ((parser.flags & 1) === 0 && parser.getToken() === 209013) {
|
|
@@ -5942,16 +5966,18 @@ function parseForStatement(parser, context, scope, privateScope, labels) {
|
|
|
5942
5966
|
}
|
|
5943
5967
|
function parseRestrictedIdentifier(parser, context, scope) {
|
|
5944
5968
|
if (!isValidIdentifier(context, parser.getToken()))
|
|
5945
|
-
parser.report(
|
|
5969
|
+
parser.report(120);
|
|
5946
5970
|
if ((parser.getToken() & 537079808) === 537079808)
|
|
5947
|
-
parser.report(
|
|
5948
|
-
scope?.addBlockName(context, parser.tokenValue, 8
|
|
5971
|
+
parser.report(121);
|
|
5972
|
+
scope?.addBlockName(context, parser.tokenValue, 8);
|
|
5949
5973
|
return parseIdentifier(parser, context);
|
|
5950
5974
|
}
|
|
5951
5975
|
function parseImportDeclaration(parser, context, scope) {
|
|
5952
5976
|
const start = parser.tokenStart;
|
|
5953
5977
|
nextToken(parser, context);
|
|
5954
5978
|
let source;
|
|
5979
|
+
let sourceParsed = false;
|
|
5980
|
+
let phase = null;
|
|
5955
5981
|
const { tokenStart } = parser;
|
|
5956
5982
|
let specifiers = [];
|
|
5957
5983
|
if (parser.getToken() === 134283267) {
|
|
@@ -5959,14 +5985,93 @@ function parseImportDeclaration(parser, context, scope) {
|
|
|
5959
5985
|
}
|
|
5960
5986
|
else {
|
|
5961
5987
|
if (parser.getToken() & 143360) {
|
|
5962
|
-
const
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5988
|
+
const token = parser.getToken();
|
|
5989
|
+
const { tokenValue } = parser;
|
|
5990
|
+
const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && tokenValue == 'defer';
|
|
5991
|
+
const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && tokenValue == 'source';
|
|
5992
|
+
if (isPhaseDefer || isPhaseSource) {
|
|
5993
|
+
const phaseOrLocal = parseIdentifier(parser, context);
|
|
5994
|
+
if (tokenValue === 'defer') {
|
|
5995
|
+
if (parser.getToken() === 8391476) {
|
|
5996
|
+
phase = 'defer';
|
|
5997
|
+
specifiers = [parseImportNamespaceSpecifier(parser, context, scope)];
|
|
5998
|
+
}
|
|
5999
|
+
else if (parser.getToken() === 209011 || parser.getToken() === 18) {
|
|
6000
|
+
scope?.addBlockName(context, tokenValue, 8);
|
|
6001
|
+
specifiers = [
|
|
6002
|
+
parser.finishNode({
|
|
6003
|
+
type: 'ImportDefaultSpecifier',
|
|
6004
|
+
local: phaseOrLocal,
|
|
6005
|
+
}, tokenStart),
|
|
6006
|
+
];
|
|
6007
|
+
}
|
|
6008
|
+
else {
|
|
6009
|
+
parser.report(108);
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6012
|
+
else if (parser.getToken() === 209011) {
|
|
6013
|
+
const fromToken = parser.getToken();
|
|
6014
|
+
const fromStart = parser.tokenStart;
|
|
6015
|
+
const fromLocal = parseIdentifier(parser, context);
|
|
6016
|
+
if (parser.getToken() === 209011) {
|
|
6017
|
+
validateBindingIdentifier(parser, context, 16, fromToken, 0);
|
|
6018
|
+
scope?.addBlockName(context, fromLocal.name, 8);
|
|
6019
|
+
phase = 'source';
|
|
6020
|
+
specifiers = [
|
|
6021
|
+
parser.finishNode({
|
|
6022
|
+
type: 'ImportDefaultSpecifier',
|
|
6023
|
+
local: fromLocal,
|
|
6024
|
+
}, fromStart),
|
|
6025
|
+
];
|
|
6026
|
+
}
|
|
6027
|
+
else {
|
|
6028
|
+
scope?.addBlockName(context, tokenValue, 8);
|
|
6029
|
+
specifiers = [
|
|
6030
|
+
parser.finishNode({
|
|
6031
|
+
type: 'ImportDefaultSpecifier',
|
|
6032
|
+
local: phaseOrLocal,
|
|
6033
|
+
}, tokenStart),
|
|
6034
|
+
];
|
|
6035
|
+
if (parser.getToken() !== 134283267)
|
|
6036
|
+
parser.report(105, 'Import');
|
|
6037
|
+
source = parseLiteral(parser, context);
|
|
6038
|
+
sourceParsed = true;
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
else if (parser.getToken() & 143360) {
|
|
6042
|
+
phase = 'source';
|
|
6043
|
+
const localStart = parser.tokenStart;
|
|
6044
|
+
const local = parseRestrictedIdentifier(parser, context, scope);
|
|
6045
|
+
specifiers = [
|
|
6046
|
+
parser.finishNode({
|
|
6047
|
+
type: 'ImportDefaultSpecifier',
|
|
6048
|
+
local,
|
|
6049
|
+
}, localStart),
|
|
6050
|
+
];
|
|
6051
|
+
}
|
|
6052
|
+
else if (parser.getToken() === 18) {
|
|
6053
|
+
scope?.addBlockName(context, tokenValue, 8);
|
|
6054
|
+
specifiers = [
|
|
6055
|
+
parser.finishNode({
|
|
6056
|
+
type: 'ImportDefaultSpecifier',
|
|
6057
|
+
local: phaseOrLocal,
|
|
6058
|
+
}, tokenStart),
|
|
6059
|
+
];
|
|
6060
|
+
}
|
|
6061
|
+
else {
|
|
6062
|
+
parser.report(109);
|
|
6063
|
+
}
|
|
6064
|
+
}
|
|
6065
|
+
else {
|
|
6066
|
+
const local = parseRestrictedIdentifier(parser, context, scope);
|
|
6067
|
+
specifiers = [
|
|
6068
|
+
parser.finishNode({
|
|
6069
|
+
type: 'ImportDefaultSpecifier',
|
|
6070
|
+
local,
|
|
6071
|
+
}, tokenStart),
|
|
6072
|
+
];
|
|
6073
|
+
}
|
|
6074
|
+
if (phase === null && !sourceParsed && consumeOpt(parser, context, 18)) {
|
|
5970
6075
|
switch (parser.getToken()) {
|
|
5971
6076
|
case 8391476:
|
|
5972
6077
|
specifiers.push(parseImportNamespaceSpecifier(parser, context, scope));
|
|
@@ -5995,7 +6100,8 @@ function parseImportDeclaration(parser, context, scope) {
|
|
|
5995
6100
|
parser.report(30, KeywordDescTable[parser.getToken() & 255]);
|
|
5996
6101
|
}
|
|
5997
6102
|
}
|
|
5998
|
-
|
|
6103
|
+
if (!sourceParsed)
|
|
6104
|
+
source = parseModuleSpecifier(parser, context);
|
|
5999
6105
|
}
|
|
6000
6106
|
const attributes = parseImportAttributes(parser, context);
|
|
6001
6107
|
const node = {
|
|
@@ -6003,6 +6109,7 @@ function parseImportDeclaration(parser, context, scope) {
|
|
|
6003
6109
|
specifiers,
|
|
6004
6110
|
source,
|
|
6005
6111
|
attributes,
|
|
6112
|
+
...(parser.features & 2 || parser.features & 4 ? { phase } : null),
|
|
6006
6113
|
};
|
|
6007
6114
|
matchOrInsertSemicolon(parser, context | 32);
|
|
6008
6115
|
return parser.finishNode(node, start);
|
|
@@ -6050,7 +6157,7 @@ function parseImportSpecifierOrNamedImports(parser, context, scope, specifiers)
|
|
|
6050
6157
|
else {
|
|
6051
6158
|
parser.report(25, KeywordDescTable[77932 & 255]);
|
|
6052
6159
|
}
|
|
6053
|
-
scope?.addBlockName(context, tokenValue, 8
|
|
6160
|
+
scope?.addBlockName(context, tokenValue, 8);
|
|
6054
6161
|
specifiers.push(parser.finishNode({
|
|
6055
6162
|
type: 'ImportSpecifier',
|
|
6056
6163
|
local,
|
|
@@ -6085,17 +6192,24 @@ function parseImportCallDeclaration(parser, context, privateScope, start) {
|
|
|
6085
6192
|
function parseExportDeclaration(parser, context, scope) {
|
|
6086
6193
|
const start = parser.leadingDecorators.decorators.length ? parser.leadingDecorators.start : parser.tokenStart;
|
|
6087
6194
|
nextToken(parser, context | 32);
|
|
6195
|
+
const isDefaultExport = consumeOpt(parser, context | 32, 20561);
|
|
6196
|
+
if (parser.leadingDecorators.decorators.length && parser.getToken() !== 86094) {
|
|
6197
|
+
parser.report(172);
|
|
6198
|
+
}
|
|
6088
6199
|
const specifiers = [];
|
|
6089
6200
|
let declaration = null;
|
|
6090
6201
|
let source = null;
|
|
6091
6202
|
let attributes = [];
|
|
6092
|
-
if (
|
|
6203
|
+
if (isDefaultExport) {
|
|
6093
6204
|
switch (parser.getToken()) {
|
|
6094
6205
|
case 86104: {
|
|
6095
|
-
declaration = parseFunctionDeclaration(parser, context, scope, undefined,
|
|
6206
|
+
declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 0, parser.tokenStart, 4);
|
|
6096
6207
|
break;
|
|
6097
6208
|
}
|
|
6098
6209
|
case 133:
|
|
6210
|
+
if (!(parser.features & 1)) {
|
|
6211
|
+
parser.report(30, '@');
|
|
6212
|
+
}
|
|
6099
6213
|
case 86094:
|
|
6100
6214
|
declaration = parseClassDeclaration(parser, context, scope, undefined, 1);
|
|
6101
6215
|
break;
|
|
@@ -6105,11 +6219,11 @@ function parseExportDeclaration(parser, context, scope) {
|
|
|
6105
6219
|
const { flags } = parser;
|
|
6106
6220
|
if ((flags & 1) === 0) {
|
|
6107
6221
|
if (parser.getToken() === 86104) {
|
|
6108
|
-
declaration = parseFunctionDeclaration(parser, context, scope, undefined,
|
|
6222
|
+
declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 1, 1, tokenStart, 4);
|
|
6109
6223
|
}
|
|
6110
6224
|
else {
|
|
6111
6225
|
if (parser.getToken() === 67174411) {
|
|
6112
|
-
declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1,
|
|
6226
|
+
declaration = parseAsyncArrowOrCallExpression(parser, context, undefined, declaration, 1, 1, flags, tokenStart);
|
|
6113
6227
|
declaration = parseMemberOrUpdateExpression(parser, context, undefined, declaration, 0, 0, tokenStart);
|
|
6114
6228
|
declaration = parseAssignmentExpression(parser, context, undefined, 0, 0, tokenStart, declaration);
|
|
6115
6229
|
}
|
|
@@ -6208,7 +6322,7 @@ function parseExportDeclaration(parser, context, scope) {
|
|
|
6208
6322
|
}
|
|
6209
6323
|
else {
|
|
6210
6324
|
if (hasLiteralLocal) {
|
|
6211
|
-
parser.report(
|
|
6325
|
+
parser.report(174);
|
|
6212
6326
|
}
|
|
6213
6327
|
if (scope) {
|
|
6214
6328
|
tmpExportedNames.forEach((n) => parser.declareUnboundVariable(n));
|
|
@@ -6219,11 +6333,14 @@ function parseExportDeclaration(parser, context, scope) {
|
|
|
6219
6333
|
break;
|
|
6220
6334
|
}
|
|
6221
6335
|
case 133:
|
|
6336
|
+
if (!(parser.features & 1)) {
|
|
6337
|
+
parser.report(30, '@');
|
|
6338
|
+
}
|
|
6222
6339
|
case 86094:
|
|
6223
6340
|
declaration = parseClassDeclaration(parser, context, scope, undefined, 2);
|
|
6224
6341
|
break;
|
|
6225
6342
|
case 86104:
|
|
6226
|
-
declaration = parseFunctionDeclaration(parser, context, scope, undefined,
|
|
6343
|
+
declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 0, parser.tokenStart, 4);
|
|
6227
6344
|
break;
|
|
6228
6345
|
case 241737:
|
|
6229
6346
|
declaration = parseLexicalDeclaration(parser, context, scope, undefined, 8, 64);
|
|
@@ -6238,7 +6355,7 @@ function parseExportDeclaration(parser, context, scope) {
|
|
|
6238
6355
|
const { tokenStart } = parser;
|
|
6239
6356
|
nextToken(parser, context);
|
|
6240
6357
|
if ((parser.flags & 1) === 0 && parser.getToken() === 86104) {
|
|
6241
|
-
declaration = parseFunctionDeclaration(parser, context, scope, undefined,
|
|
6358
|
+
declaration = parseFunctionDeclaration(parser, context, scope, undefined, 1, 2, 1, tokenStart, 4);
|
|
6242
6359
|
break;
|
|
6243
6360
|
}
|
|
6244
6361
|
}
|
|
@@ -6254,8 +6371,8 @@ function parseExportDeclaration(parser, context, scope) {
|
|
|
6254
6371
|
};
|
|
6255
6372
|
return parser.finishNode(node, start);
|
|
6256
6373
|
}
|
|
6257
|
-
function parseExpression(parser, context, privateScope, canAssign, inGroup, start) {
|
|
6258
|
-
let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start);
|
|
6374
|
+
function parseExpression(parser, context, privateScope, canAssign, inGroup, start, origin = 0) {
|
|
6375
|
+
let expr = parsePrimaryExpression(parser, context, privateScope, 2, 0, canAssign, inGroup, 1, start, origin);
|
|
6259
6376
|
expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
|
|
6260
6377
|
return parseAssignmentExpression(parser, context, privateScope, inGroup, 0, start, expr);
|
|
6261
6378
|
}
|
|
@@ -6351,7 +6468,7 @@ function parseBinaryExpression(parser, context, privateScope, inGroup, start, mi
|
|
|
6351
6468
|
t = parser.getToken();
|
|
6352
6469
|
precedence = t & 3840;
|
|
6353
6470
|
if ((t & 524288 && operator & 268435456) || (operator & 524288 && t & 268435456)) {
|
|
6354
|
-
parser.report(
|
|
6471
|
+
parser.report(167);
|
|
6355
6472
|
}
|
|
6356
6473
|
if (precedence + ((t === 8391735) << 8) - ((bit === t) << 12) <= minPrecedence)
|
|
6357
6474
|
break;
|
|
@@ -6378,10 +6495,10 @@ function parseUnaryExpression(parser, context, privateScope, isLHS, inGroup) {
|
|
|
6378
6495
|
parser.report(33);
|
|
6379
6496
|
if (context & 1 && unaryOperator === 16863276) {
|
|
6380
6497
|
if (arg.type === 'Identifier') {
|
|
6381
|
-
parser.report(
|
|
6498
|
+
parser.report(123);
|
|
6382
6499
|
}
|
|
6383
6500
|
else if (isPropertyWithPrivateFieldKey(arg)) {
|
|
6384
|
-
parser.report(
|
|
6501
|
+
parser.report(129);
|
|
6385
6502
|
}
|
|
6386
6503
|
}
|
|
6387
6504
|
parser.assignable = 2;
|
|
@@ -6410,7 +6527,7 @@ function parseAsyncExpression(parser, context, privateScope, inGroup, isLHS, can
|
|
|
6410
6527
|
}
|
|
6411
6528
|
}
|
|
6412
6529
|
if (!inNew && parser.getToken() === 67174411) {
|
|
6413
|
-
return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1,
|
|
6530
|
+
return parseAsyncArrowOrCallExpression(parser, context, privateScope, expr, canAssign, 1, flags, start);
|
|
6414
6531
|
}
|
|
6415
6532
|
if (parser.getToken() === 10) {
|
|
6416
6533
|
classifyIdentifier(parser, context, token);
|
|
@@ -6434,7 +6551,7 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
|
|
|
6434
6551
|
if (!canAssign)
|
|
6435
6552
|
parser.report(26);
|
|
6436
6553
|
if (parser.getToken() === 22)
|
|
6437
|
-
parser.report(
|
|
6554
|
+
parser.report(126);
|
|
6438
6555
|
let argument = null;
|
|
6439
6556
|
let delegate = false;
|
|
6440
6557
|
if ((parser.flags & 1) === 0) {
|
|
@@ -6458,20 +6575,24 @@ function parseYieldExpressionOrIdentifier(parser, context, privateScope, inGroup
|
|
|
6458
6575
|
return parseIdentifierOrArrow(parser, context, privateScope);
|
|
6459
6576
|
}
|
|
6460
6577
|
function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew, inGroup, start) {
|
|
6461
|
-
if (inGroup)
|
|
6578
|
+
if (inGroup) {
|
|
6579
|
+
if ((parser.destructible & 128) === 0) {
|
|
6580
|
+
parser.firstAwaitLocation ??= { start, end: parser.currentLocation };
|
|
6581
|
+
}
|
|
6462
6582
|
parser.destructible |= 128;
|
|
6583
|
+
}
|
|
6463
6584
|
if (context & 524288)
|
|
6464
|
-
parser.report(
|
|
6585
|
+
parser.report(179);
|
|
6465
6586
|
const possibleIdentifierOrArrowFunc = parseIdentifierOrArrow(parser, context, privateScope);
|
|
6466
6587
|
const isIdentifier = possibleIdentifierOrArrowFunc.type === 'ArrowFunctionExpression' ||
|
|
6467
6588
|
(parser.getToken() & 65536) === 0;
|
|
6468
6589
|
if (isIdentifier) {
|
|
6469
6590
|
if (context & 2048)
|
|
6470
|
-
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn },
|
|
6591
|
+
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 178);
|
|
6471
6592
|
if (context & 2)
|
|
6472
|
-
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn },
|
|
6593
|
+
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 112);
|
|
6473
6594
|
if (context & 8192 && context & 2048)
|
|
6474
|
-
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn },
|
|
6595
|
+
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 112);
|
|
6475
6596
|
return possibleIdentifierOrArrowFunc;
|
|
6476
6597
|
}
|
|
6477
6598
|
if (context & 8192) {
|
|
@@ -6493,8 +6614,9 @@ function parseAwaitExpressionOrIdentifier(parser, context, privateScope, inNew,
|
|
|
6493
6614
|
throw new ParseError(start, { index: parser.startIndex, line: parser.startLine, column: parser.startColumn }, 98);
|
|
6494
6615
|
return possibleIdentifierOrArrowFunc;
|
|
6495
6616
|
}
|
|
6496
|
-
function parseFunctionBody(parser, context, scope, privateScope,
|
|
6617
|
+
function parseFunctionBody(parser, context, scope, privateScope, funcNameToken, functionScope, origin = 0) {
|
|
6497
6618
|
const { tokenStart } = parser;
|
|
6619
|
+
parser.flags &= -4161;
|
|
6498
6620
|
consume(parser, context | 32, 2162700);
|
|
6499
6621
|
const body = [];
|
|
6500
6622
|
if (parser.getToken() !== 1074790415) {
|
|
@@ -6520,19 +6642,19 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
|
|
|
6520
6642
|
if (context & 1) {
|
|
6521
6643
|
if (funcNameToken) {
|
|
6522
6644
|
if ((funcNameToken & 537079808) === 537079808) {
|
|
6523
|
-
parser.report(
|
|
6645
|
+
parser.report(121);
|
|
6524
6646
|
}
|
|
6525
6647
|
if ((funcNameToken & 36864) === 36864) {
|
|
6526
6648
|
parser.report(40);
|
|
6527
6649
|
}
|
|
6528
6650
|
}
|
|
6529
6651
|
if (parser.flags & 512)
|
|
6530
|
-
parser.report(
|
|
6652
|
+
parser.report(121);
|
|
6531
6653
|
if (parser.flags & 256) {
|
|
6532
6654
|
if (parser.strictReservedRange) {
|
|
6533
|
-
throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1],
|
|
6655
|
+
throw new ParseError(parser.strictReservedRange[0], parser.strictReservedRange[1], 120);
|
|
6534
6656
|
}
|
|
6535
|
-
parser.report(
|
|
6657
|
+
parser.report(120);
|
|
6536
6658
|
}
|
|
6537
6659
|
}
|
|
6538
6660
|
}
|
|
@@ -6541,7 +6663,7 @@ function parseFunctionBody(parser, context, scope, privateScope, origin, funcNam
|
|
|
6541
6663
|
(512 | 256 | 64 | 4096);
|
|
6542
6664
|
parser.destructible = (parser.destructible | 256) ^ 256;
|
|
6543
6665
|
while (parser.getToken() !== 1074790415) {
|
|
6544
|
-
body.push(parseStatementListItem(parser, context, scope, privateScope,
|
|
6666
|
+
body.push(parseStatementListItem(parser, context, scope, privateScope, {}, 4));
|
|
6545
6667
|
}
|
|
6546
6668
|
consume(parser, origin & (16 | 8) ? context | 32 : context, 1074790415);
|
|
6547
6669
|
parser.flags &= -4289;
|
|
@@ -6557,7 +6679,7 @@ function parseSuperExpression(parser, context) {
|
|
|
6557
6679
|
nextToken(parser, context);
|
|
6558
6680
|
switch (parser.getToken()) {
|
|
6559
6681
|
case 67108991:
|
|
6560
|
-
parser.report(
|
|
6682
|
+
parser.report(169);
|
|
6561
6683
|
case 67174411: {
|
|
6562
6684
|
if ((context & 512) === 0)
|
|
6563
6685
|
parser.report(28);
|
|
@@ -6604,7 +6726,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
|
|
|
6604
6726
|
case 67108877: {
|
|
6605
6727
|
nextToken(parser, (context | 262144 | 8) ^ 8);
|
|
6606
6728
|
if (context & 16 && parser.getToken() === 131 && parser.tokenValue === 'super') {
|
|
6607
|
-
parser.report(
|
|
6729
|
+
parser.report(175);
|
|
6608
6730
|
}
|
|
6609
6731
|
parser.assignable =
|
|
6610
6732
|
(parser.flags & 2048) === 2048
|
|
@@ -6684,7 +6806,7 @@ function parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGr
|
|
|
6684
6806
|
}
|
|
6685
6807
|
default:
|
|
6686
6808
|
if ((parser.flags & 2048) === 2048) {
|
|
6687
|
-
parser.report(
|
|
6809
|
+
parser.report(168);
|
|
6688
6810
|
}
|
|
6689
6811
|
parser.assignable = 2;
|
|
6690
6812
|
expr = parser.finishNode({
|
|
@@ -6765,7 +6887,7 @@ function parsePropertyOrPrivatePropertyName(parser, context, privateScope) {
|
|
|
6765
6887
|
parser.getToken() !== -2147483527 &&
|
|
6766
6888
|
parser.getToken() !== -2147483526 &&
|
|
6767
6889
|
parser.getToken() !== 131) {
|
|
6768
|
-
parser.report(
|
|
6890
|
+
parser.report(162);
|
|
6769
6891
|
}
|
|
6770
6892
|
return parser.getToken() === 131
|
|
6771
6893
|
? parsePrivateIdentifier(parser, context, privateScope, 0)
|
|
@@ -6790,7 +6912,7 @@ function parseUpdateExpressionPrefixed(parser, context, privateScope, inNew, isL
|
|
|
6790
6912
|
prefix: true,
|
|
6791
6913
|
}, start);
|
|
6792
6914
|
}
|
|
6793
|
-
function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start) {
|
|
6915
|
+
function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canAssign, inGroup, isLHS, start, origin = 0) {
|
|
6794
6916
|
if ((parser.getToken() & 143360) === 143360) {
|
|
6795
6917
|
switch (parser.getToken()) {
|
|
6796
6918
|
case 209006:
|
|
@@ -6810,16 +6932,16 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
|
|
|
6810
6932
|
if ((token & 36864) === 36864) {
|
|
6811
6933
|
parser.flags |= 256;
|
|
6812
6934
|
}
|
|
6813
|
-
return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start);
|
|
6935
|
+
return parseArrowFromIdentifier(parser, context, privateScope, tokenValue, expr, inNew, canAssign, 0, start, origin);
|
|
6814
6936
|
}
|
|
6815
6937
|
if (context & 16 &&
|
|
6816
6938
|
!(context & 32768) &&
|
|
6817
6939
|
!(context & 8192) &&
|
|
6818
6940
|
parser.tokenValue === 'arguments')
|
|
6819
|
-
parser.report(
|
|
6941
|
+
parser.report(132);
|
|
6820
6942
|
if ((token & 255) === (241737 & 255)) {
|
|
6821
6943
|
if (context & 1)
|
|
6822
|
-
parser.report(
|
|
6944
|
+
parser.report(115);
|
|
6823
6945
|
if (kind & (8 | 16))
|
|
6824
6946
|
parser.report(100);
|
|
6825
6947
|
}
|
|
@@ -6851,7 +6973,7 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
|
|
|
6851
6973
|
case 69271571:
|
|
6852
6974
|
return parseArrayLiteral(parser, context, privateScope, canAssign ? 0 : 1, inGroup);
|
|
6853
6975
|
case 67174411:
|
|
6854
|
-
return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1,
|
|
6976
|
+
return parseParenthesizedExpression(parser, context | 64, privateScope, canAssign, 1, start, origin);
|
|
6855
6977
|
case 86021:
|
|
6856
6978
|
case 86022:
|
|
6857
6979
|
case 86023:
|
|
@@ -6861,6 +6983,9 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
|
|
|
6861
6983
|
case 65540:
|
|
6862
6984
|
return parseRegExpLiteral(parser, context);
|
|
6863
6985
|
case 133:
|
|
6986
|
+
if (!(parser.features & 1)) {
|
|
6987
|
+
parser.report(30, '@');
|
|
6988
|
+
}
|
|
6864
6989
|
case 86094:
|
|
6865
6990
|
return parseClassExpression(parser, context, privateScope, inGroup, start);
|
|
6866
6991
|
case 86109:
|
|
@@ -6889,24 +7014,37 @@ function parsePrimaryExpression(parser, context, privateScope, kind, inNew, canA
|
|
|
6889
7014
|
function parseImportCallOrMetaExpression(parser, context, privateScope, inNew, inGroup, start) {
|
|
6890
7015
|
let expr = parseIdentifier(parser, context);
|
|
6891
7016
|
if (parser.getToken() === 67108877) {
|
|
6892
|
-
return parseImportMetaExpression(parser, context, expr, start);
|
|
7017
|
+
return parseImportMetaExpression(parser, context, expr, start, privateScope, inGroup, inNew);
|
|
6893
7018
|
}
|
|
6894
7019
|
if (inNew)
|
|
6895
|
-
parser.report(
|
|
7020
|
+
parser.report(144);
|
|
6896
7021
|
expr = parseImportExpression(parser, context, privateScope, inGroup, start);
|
|
6897
7022
|
parser.assignable = 2;
|
|
6898
7023
|
return parseMemberOrUpdateExpression(parser, context, privateScope, expr, inGroup, 0, start);
|
|
6899
7024
|
}
|
|
6900
|
-
function parseImportMetaExpression(parser, context, meta, start) {
|
|
6901
|
-
|
|
6902
|
-
|
|
7025
|
+
function parseImportMetaExpression(parser, context, meta, start, privateScope, inGroup = 0, inNew = 0) {
|
|
7026
|
+
const propertyStart = parser.tokenStart;
|
|
7027
|
+
const propertyEnd = parser.currentLocation;
|
|
6903
7028
|
nextToken(parser, context);
|
|
6904
7029
|
const token = parser.getToken();
|
|
7030
|
+
const isPhaseDefer = parser.features & 2 && (token & -2147483648) === 0 && parser.tokenValue === 'defer';
|
|
7031
|
+
const isPhaseSource = parser.features & 4 && (token & -2147483648) === 0 && parser.tokenValue === 'source';
|
|
7032
|
+
if (isPhaseDefer || isPhaseSource) {
|
|
7033
|
+
if (inNew)
|
|
7034
|
+
parser.report(144);
|
|
7035
|
+
nextToken(parser, context);
|
|
7036
|
+
const expression = parseImportExpression(parser, context, privateScope, inGroup, start, parser.tokenValue);
|
|
7037
|
+
parser.assignable = 2;
|
|
7038
|
+
return expression;
|
|
7039
|
+
}
|
|
7040
|
+
if ((context & 2) === 0) {
|
|
7041
|
+
throw new ParseError(propertyStart, propertyEnd, 171);
|
|
7042
|
+
}
|
|
6905
7043
|
if (token !== 209031 && parser.tokenValue !== 'meta') {
|
|
6906
|
-
parser.report(
|
|
7044
|
+
parser.report(176);
|
|
6907
7045
|
}
|
|
6908
7046
|
else if (token & -2147483648) {
|
|
6909
|
-
parser.report(
|
|
7047
|
+
parser.report(177);
|
|
6910
7048
|
}
|
|
6911
7049
|
parser.assignable = 2;
|
|
6912
7050
|
return parser.finishNode({
|
|
@@ -6915,10 +7053,10 @@ function parseImportMetaExpression(parser, context, meta, start) {
|
|
|
6915
7053
|
property: parseIdentifier(parser, context),
|
|
6916
7054
|
}, start);
|
|
6917
7055
|
}
|
|
6918
|
-
function parseImportExpression(parser, context, privateScope, inGroup, start) {
|
|
7056
|
+
function parseImportExpression(parser, context, privateScope, inGroup, start, phase = null) {
|
|
6919
7057
|
consume(parser, context | 32, 67174411);
|
|
6920
7058
|
if (parser.getToken() === 14)
|
|
6921
|
-
parser.report(
|
|
7059
|
+
parser.report(145);
|
|
6922
7060
|
const source = parseExpression(parser, context, privateScope, 1, inGroup, parser.tokenStart);
|
|
6923
7061
|
let options = null;
|
|
6924
7062
|
if (parser.getToken() === 18) {
|
|
@@ -6933,6 +7071,7 @@ function parseImportExpression(parser, context, privateScope, inGroup, start) {
|
|
|
6933
7071
|
type: 'ImportExpression',
|
|
6934
7072
|
source,
|
|
6935
7073
|
options,
|
|
7074
|
+
...(parser.features & 2 || parser.features & 4 ? { phase } : null),
|
|
6936
7075
|
};
|
|
6937
7076
|
consume(parser, context, 16);
|
|
6938
7077
|
return parser.finishNode(node, start);
|
|
@@ -6950,7 +7089,7 @@ function parseImportAttributes(parser, context) {
|
|
|
6950
7089
|
const value = parseStringLiteral(parser, context);
|
|
6951
7090
|
const keyContent = key.type === 'Literal' ? key.value : key.name;
|
|
6952
7091
|
if (keysContent.has(keyContent)) {
|
|
6953
|
-
parser.report(
|
|
7092
|
+
parser.report(147, keyContent);
|
|
6954
7093
|
}
|
|
6955
7094
|
keysContent.add(keyContent);
|
|
6956
7095
|
attributes.push(parser.finishNode({
|
|
@@ -6988,7 +7127,7 @@ function parseModuleExportName(parser, context) {
|
|
|
6988
7127
|
if (parser.getToken() === 134283267) {
|
|
6989
7128
|
const value = parser.tokenValue;
|
|
6990
7129
|
if (!value.isWellFormed()) {
|
|
6991
|
-
parser.report(
|
|
7130
|
+
parser.report(173);
|
|
6992
7131
|
}
|
|
6993
7132
|
return parseLiteral(parser, context);
|
|
6994
7133
|
}
|
|
@@ -7163,7 +7302,7 @@ function parseThisExpression(parser, context) {
|
|
|
7163
7302
|
type: 'ThisExpression',
|
|
7164
7303
|
}, tokenStart);
|
|
7165
7304
|
}
|
|
7166
|
-
function parseFunctionDeclaration(parser, context, scope, privateScope,
|
|
7305
|
+
function parseFunctionDeclaration(parser, context, scope, privateScope, allowGen, flags, isAsync, start, origin = 0) {
|
|
7167
7306
|
nextToken(parser, context | 32);
|
|
7168
7307
|
const isGenerator = allowGen ? optionalBit(parser, context, 8391476) : 0;
|
|
7169
7308
|
let id = null;
|
|
@@ -7217,7 +7356,7 @@ function parseFunctionDeclaration(parser, context, scope, privateScope, origin,
|
|
|
7217
7356
|
functionScope = functionScope?.createChildScope(256);
|
|
7218
7357
|
const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, functionScope, privateScope, 0, 1);
|
|
7219
7358
|
const modifierFlags = 8 | 4 | 128 | 524288;
|
|
7220
|
-
const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope,
|
|
7359
|
+
const body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 32768 | 4096, functionScope?.createChildScope(64), privateScope, funcNameToken, functionScope, 8);
|
|
7221
7360
|
return parser.finishNode({
|
|
7222
7361
|
type: 'FunctionDeclaration',
|
|
7223
7362
|
id,
|
|
@@ -7256,7 +7395,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
|
|
|
7256
7395
|
const params = parseFormalParametersOrFormalList(parser, (context | 8192) & -524289, scope, privateScope, inGroup, 1);
|
|
7257
7396
|
const body = parseFunctionBody(parser, (context & -131229) |
|
|
7258
7397
|
32768 |
|
|
7259
|
-
4096, scope?.createChildScope(64), privateScope,
|
|
7398
|
+
4096, scope?.createChildScope(64), privateScope, funcNameToken, scope);
|
|
7260
7399
|
parser.assignable = 2;
|
|
7261
7400
|
return parser.finishNode({
|
|
7262
7401
|
type: 'FunctionExpression',
|
|
@@ -7268,7 +7407,7 @@ function parseFunctionExpression(parser, context, privateScope, isAsync, inGroup
|
|
|
7268
7407
|
}, start);
|
|
7269
7408
|
}
|
|
7270
7409
|
function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGroup) {
|
|
7271
|
-
const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2
|
|
7410
|
+
const expr = parseArrayExpressionOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
|
|
7272
7411
|
if (parser.destructible & 64) {
|
|
7273
7412
|
parser.report(63);
|
|
7274
7413
|
}
|
|
@@ -7277,7 +7416,7 @@ function parseArrayLiteral(parser, context, privateScope, skipInitializer, inGro
|
|
|
7277
7416
|
}
|
|
7278
7417
|
return expr;
|
|
7279
7418
|
}
|
|
7280
|
-
function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
|
|
7419
|
+
function parseArrayExpressionOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
|
|
7281
7420
|
const { tokenStart: start } = parser;
|
|
7282
7421
|
nextToken(parser, context | 32);
|
|
7283
7422
|
const elements = [];
|
|
@@ -7386,7 +7525,7 @@ function parseArrayExpressionOrPattern(parser, context, scope, privateScope, ski
|
|
|
7386
7525
|
}
|
|
7387
7526
|
}
|
|
7388
7527
|
else if (token === 14) {
|
|
7389
|
-
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind,
|
|
7528
|
+
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 20, kind, 0, inGroup, isPattern, origin);
|
|
7390
7529
|
destructible |= parser.destructible;
|
|
7391
7530
|
if (parser.getToken() !== 18 && parser.getToken() !== 20)
|
|
7392
7531
|
parser.report(30, KeywordDescTable[parser.getToken() & 255]);
|
|
@@ -7456,7 +7595,7 @@ function parseArrayOrObjectAssignmentPattern(parser, context, privateScope, dest
|
|
|
7456
7595
|
right,
|
|
7457
7596
|
}, start);
|
|
7458
7597
|
}
|
|
7459
|
-
function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind,
|
|
7598
|
+
function parseSpreadOrRestElement(parser, context, scope, privateScope, closingToken, kind, isAsync, inGroup, isPattern, origin = 0) {
|
|
7460
7599
|
const { tokenStart: start } = parser;
|
|
7461
7600
|
nextToken(parser, context | 32);
|
|
7462
7601
|
let argument = null;
|
|
@@ -7549,7 +7688,7 @@ function parseSpreadOrRestElement(parser, context, scope, privateScope, closingT
|
|
|
7549
7688
|
}
|
|
7550
7689
|
parser.destructible = destructible;
|
|
7551
7690
|
if (parser.getToken() !== closingToken && parser.getToken() !== 18)
|
|
7552
|
-
parser.report(
|
|
7691
|
+
parser.report(163);
|
|
7553
7692
|
return parser.finishNode({
|
|
7554
7693
|
type: isPattern ? 'RestElement' : 'SpreadElement',
|
|
7555
7694
|
argument: argument,
|
|
@@ -7605,7 +7744,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
|
|
|
7605
7744
|
scope = scope?.createChildScope(64);
|
|
7606
7745
|
const body = parseFunctionBody(parser, (context & -655373) |
|
|
7607
7746
|
32768 |
|
|
7608
|
-
4096, scope, privateScope,
|
|
7747
|
+
4096, scope, privateScope, void 0, scope?.parent);
|
|
7609
7748
|
return parser.finishNode({
|
|
7610
7749
|
type: 'FunctionExpression',
|
|
7611
7750
|
params,
|
|
@@ -7616,7 +7755,7 @@ function parseMethodDefinition(parser, context, privateScope, kind, inGroup, sta
|
|
|
7616
7755
|
}, start);
|
|
7617
7756
|
}
|
|
7618
7757
|
function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGroup) {
|
|
7619
|
-
const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2
|
|
7758
|
+
const expr = parseObjectLiteralOrPattern(parser, context, void 0, privateScope, skipInitializer, inGroup, 0, 2);
|
|
7620
7759
|
if (parser.destructible & 64) {
|
|
7621
7760
|
parser.report(63);
|
|
7622
7761
|
}
|
|
@@ -7625,7 +7764,7 @@ function parseObjectLiteral(parser, context, privateScope, skipInitializer, inGr
|
|
|
7625
7764
|
}
|
|
7626
7765
|
return expr;
|
|
7627
7766
|
}
|
|
7628
|
-
function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin) {
|
|
7767
|
+
function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipInitializer, inGroup, isPattern, kind, origin = 0) {
|
|
7629
7768
|
const { tokenStart: start } = parser;
|
|
7630
7769
|
nextToken(parser, context);
|
|
7631
7770
|
const properties = [];
|
|
@@ -7636,7 +7775,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7636
7775
|
const { tokenValue, tokenStart } = parser;
|
|
7637
7776
|
const token = parser.getToken();
|
|
7638
7777
|
if (token === 14) {
|
|
7639
|
-
properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind,
|
|
7778
|
+
properties.push(parseSpreadOrRestElement(parser, context, scope, privateScope, 1074790415, kind, 0, inGroup, isPattern, origin));
|
|
7640
7779
|
}
|
|
7641
7780
|
else {
|
|
7642
7781
|
let state = 0;
|
|
@@ -7808,7 +7947,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7808
7947
|
parser.report(95);
|
|
7809
7948
|
if (token === 209005) {
|
|
7810
7949
|
if (parser.flags & 1)
|
|
7811
|
-
parser.report(
|
|
7950
|
+
parser.report(134);
|
|
7812
7951
|
state |= 16 | 1;
|
|
7813
7952
|
}
|
|
7814
7953
|
else if (token === 209008) {
|
|
@@ -7872,7 +8011,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7872
8011
|
value = parseMethodDefinition(parser, context, privateScope, state, inGroup, parser.tokenStart);
|
|
7873
8012
|
}
|
|
7874
8013
|
else {
|
|
7875
|
-
parser.report(
|
|
8014
|
+
parser.report(135);
|
|
7876
8015
|
}
|
|
7877
8016
|
}
|
|
7878
8017
|
else if ((parser.getToken() & 134217728) === 134217728) {
|
|
@@ -7976,7 +8115,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
7976
8115
|
destructible = 16;
|
|
7977
8116
|
}
|
|
7978
8117
|
else {
|
|
7979
|
-
parser.report(
|
|
8118
|
+
parser.report(136);
|
|
7980
8119
|
}
|
|
7981
8120
|
}
|
|
7982
8121
|
else if (parser.getToken() === 69271571) {
|
|
@@ -8123,7 +8262,7 @@ function parseObjectLiteralOrPattern(parser, context, scope, privateScope, skipI
|
|
|
8123
8262
|
value = parseMethodDefinition(parser, context, privateScope, state, inGroup, parser.tokenStart);
|
|
8124
8263
|
}
|
|
8125
8264
|
else {
|
|
8126
|
-
parser.report(
|
|
8265
|
+
parser.report(128);
|
|
8127
8266
|
}
|
|
8128
8267
|
}
|
|
8129
8268
|
else {
|
|
@@ -8164,6 +8303,7 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
|
|
|
8164
8303
|
const params = [];
|
|
8165
8304
|
parser.flags = (parser.flags | 128) ^ 128;
|
|
8166
8305
|
parser.strictReservedRange = null;
|
|
8306
|
+
parser.firstAwaitLocation = null;
|
|
8167
8307
|
if (parser.getToken() === 16) {
|
|
8168
8308
|
if (kind & 512) {
|
|
8169
8309
|
parser.report(37, 'Setter', 'one', '');
|
|
@@ -8193,17 +8333,17 @@ function parseMethodFormals(parser, context, scope, privateScope, kind, type, in
|
|
|
8193
8333
|
parser.flags |= 512;
|
|
8194
8334
|
}
|
|
8195
8335
|
}
|
|
8196
|
-
left = parseAndClassifyIdentifier(parser, context, scope, kind | 1
|
|
8336
|
+
left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
|
|
8197
8337
|
}
|
|
8198
8338
|
else {
|
|
8199
8339
|
if (parser.getToken() === 2162700) {
|
|
8200
|
-
left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type
|
|
8340
|
+
left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
|
|
8201
8341
|
}
|
|
8202
8342
|
else if (parser.getToken() === 69271571) {
|
|
8203
|
-
left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type
|
|
8343
|
+
left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, type);
|
|
8204
8344
|
}
|
|
8205
8345
|
else if (parser.getToken() === 14) {
|
|
8206
|
-
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0,
|
|
8346
|
+
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, type, 0, inGroup, 1);
|
|
8207
8347
|
}
|
|
8208
8348
|
isNonSimpleParameterList = 1;
|
|
8209
8349
|
if (parser.destructible & (32 | 16))
|
|
@@ -8242,17 +8382,20 @@ function parseComputedPropertyName(parser, context, privateScope, inGroup) {
|
|
|
8242
8382
|
consume(parser, context, 20);
|
|
8243
8383
|
return key;
|
|
8244
8384
|
}
|
|
8245
|
-
function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind,
|
|
8385
|
+
function parseParenthesizedExpression(parser, context, privateScope, canAssign, kind, start, origin) {
|
|
8246
8386
|
parser.flags = (parser.flags | 128) ^ 128;
|
|
8247
8387
|
const parenthesesStart = parser.tokenStart;
|
|
8248
8388
|
nextToken(parser, context | 32 | 262144);
|
|
8249
8389
|
const scope = parser.createScopeIfLexical()?.createChildScope(512);
|
|
8250
8390
|
context = (context | 131072) ^ 131072;
|
|
8251
8391
|
if (consumeOpt(parser, context, 16)) {
|
|
8252
|
-
return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start);
|
|
8392
|
+
return parseParenthesizedArrow(parser, context, scope, privateScope, [], canAssign, 0, start, origin);
|
|
8253
8393
|
}
|
|
8254
8394
|
let destructible = 0;
|
|
8395
|
+
const previousAwaitYield = parser.destructible & (256 | 128);
|
|
8255
8396
|
parser.destructible &= -385;
|
|
8397
|
+
const previousFirstAwaitLocation = parser.firstAwaitLocation;
|
|
8398
|
+
parser.firstAwaitLocation = null;
|
|
8256
8399
|
let expr;
|
|
8257
8400
|
let expressions = [];
|
|
8258
8401
|
let isSequence = 0;
|
|
@@ -8264,14 +8407,14 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8264
8407
|
const { tokenStart } = parser;
|
|
8265
8408
|
const token = parser.getToken();
|
|
8266
8409
|
if (token & 143360) {
|
|
8267
|
-
scope?.addBlockName(context, parser.tokenValue, 1
|
|
8410
|
+
scope?.addBlockName(context, parser.tokenValue, 1);
|
|
8268
8411
|
if ((token & 537079808) === 537079808) {
|
|
8269
8412
|
isNonSimpleParameterList = 1;
|
|
8270
8413
|
}
|
|
8271
8414
|
else if ((token & 36864) === 36864) {
|
|
8272
8415
|
hasStrictReserved = 1;
|
|
8273
8416
|
}
|
|
8274
|
-
expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart);
|
|
8417
|
+
expr = parsePrimaryExpression(parser, context, privateScope, kind, 0, 1, 1, 1, tokenStart, 0);
|
|
8275
8418
|
if (parser.getToken() === 16 || parser.getToken() === 18) {
|
|
8276
8419
|
if (parser.assignable & 2) {
|
|
8277
8420
|
destructible |= 16;
|
|
@@ -8294,14 +8437,14 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8294
8437
|
else if ((token & 2097152) === 2097152) {
|
|
8295
8438
|
expr =
|
|
8296
8439
|
token === 2162700
|
|
8297
|
-
? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind
|
|
8298
|
-
: parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind
|
|
8440
|
+
? parseObjectLiteralOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind)
|
|
8441
|
+
: parseArrayExpressionOrPattern(parser, context | 262144, scope, privateScope, 0, 1, 0, kind);
|
|
8299
8442
|
destructible |= parser.destructible;
|
|
8300
8443
|
isNonSimpleParameterList = 1;
|
|
8301
8444
|
parser.assignable = 2;
|
|
8302
8445
|
if (parser.getToken() !== 16 && parser.getToken() !== 18) {
|
|
8303
8446
|
if (destructible & 8)
|
|
8304
|
-
parser.report(
|
|
8447
|
+
parser.report(124);
|
|
8305
8448
|
expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, tokenStart);
|
|
8306
8449
|
destructible |= 16;
|
|
8307
8450
|
if (parser.getToken() !== 16 && parser.getToken() !== 18) {
|
|
@@ -8310,7 +8453,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8310
8453
|
}
|
|
8311
8454
|
}
|
|
8312
8455
|
else if (token === 14) {
|
|
8313
|
-
expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind,
|
|
8456
|
+
expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, 1, 0);
|
|
8314
8457
|
if (parser.destructible & 16)
|
|
8315
8458
|
parser.report(74);
|
|
8316
8459
|
isNonSimpleParameterList = 1;
|
|
@@ -8343,7 +8486,10 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8343
8486
|
}, tokenAfterParenthesesStart);
|
|
8344
8487
|
}
|
|
8345
8488
|
consume(parser, context, 16);
|
|
8346
|
-
parser.destructible = destructible;
|
|
8489
|
+
parser.destructible = destructible | previousAwaitYield;
|
|
8490
|
+
if (previousFirstAwaitLocation) {
|
|
8491
|
+
parser.firstAwaitLocation = previousFirstAwaitLocation;
|
|
8492
|
+
}
|
|
8347
8493
|
return parser.options.preserveParens
|
|
8348
8494
|
? parser.finishNode({
|
|
8349
8495
|
type: 'ParenthesizedExpression',
|
|
@@ -8374,7 +8520,7 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8374
8520
|
}
|
|
8375
8521
|
consume(parser, context, 16);
|
|
8376
8522
|
if (destructible & 16 && destructible & 8)
|
|
8377
|
-
parser.report(
|
|
8523
|
+
parser.report(153);
|
|
8378
8524
|
destructible |=
|
|
8379
8525
|
parser.destructible & 256
|
|
8380
8526
|
? 256
|
|
@@ -8384,8 +8530,12 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8384
8530
|
if (parser.getToken() === 10) {
|
|
8385
8531
|
if (destructible & (32 | 16))
|
|
8386
8532
|
parser.report(49);
|
|
8387
|
-
if (context & (2048 | 2) && destructible & 128)
|
|
8533
|
+
if (context & (2048 | 2) && destructible & 128) {
|
|
8534
|
+
const loc = parser.firstAwaitLocation;
|
|
8535
|
+
if (loc)
|
|
8536
|
+
throw new ParseError(loc.start, loc.end, 31);
|
|
8388
8537
|
parser.report(31);
|
|
8538
|
+
}
|
|
8389
8539
|
if (context & (1 | 1024) && destructible & 256) {
|
|
8390
8540
|
parser.report(32);
|
|
8391
8541
|
}
|
|
@@ -8393,15 +8543,19 @@ function parseParenthesizedExpression(parser, context, privateScope, canAssign,
|
|
|
8393
8543
|
parser.flags |= 128;
|
|
8394
8544
|
if (hasStrictReserved)
|
|
8395
8545
|
parser.flags |= 256;
|
|
8396
|
-
return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start);
|
|
8546
|
+
return parseParenthesizedArrow(parser, context, scope, privateScope, isSequence ? expressions : [expr], canAssign, 0, start, origin);
|
|
8397
8547
|
}
|
|
8398
8548
|
if (destructible & 64) {
|
|
8399
8549
|
parser.report(63);
|
|
8400
8550
|
}
|
|
8401
8551
|
if (destructible & 8) {
|
|
8402
|
-
parser.report(
|
|
8552
|
+
parser.report(146);
|
|
8553
|
+
}
|
|
8554
|
+
parser.destructible =
|
|
8555
|
+
((parser.destructible | 256) ^ 256) | destructible | previousAwaitYield;
|
|
8556
|
+
if (previousFirstAwaitLocation) {
|
|
8557
|
+
parser.firstAwaitLocation = previousFirstAwaitLocation;
|
|
8403
8558
|
}
|
|
8404
|
-
parser.destructible = ((parser.destructible | 256) ^ 256) | destructible;
|
|
8405
8559
|
return parser.options.preserveParens
|
|
8406
8560
|
? parser.finishNode({
|
|
8407
8561
|
type: 'ParenthesizedExpression',
|
|
@@ -8432,23 +8586,23 @@ function parseIdentifierOrArrow(parser, context, privateScope) {
|
|
|
8432
8586
|
}
|
|
8433
8587
|
return expr;
|
|
8434
8588
|
}
|
|
8435
|
-
function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start) {
|
|
8589
|
+
function parseArrowFromIdentifier(parser, context, privateScope, value, expr, inNew, canAssign, isAsync, start, origin = 0) {
|
|
8436
8590
|
if (!canAssign)
|
|
8437
8591
|
parser.report(57);
|
|
8438
8592
|
if (inNew)
|
|
8439
8593
|
parser.report(51);
|
|
8440
8594
|
parser.flags &= -129;
|
|
8441
8595
|
const scope = parser.options.lexical ? createArrowHeadParsingScope(parser, context, value) : void 0;
|
|
8442
|
-
return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start);
|
|
8596
|
+
return parseArrowFunctionExpression(parser, context, scope, privateScope, [expr], isAsync, start, origin);
|
|
8443
8597
|
}
|
|
8444
|
-
function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start) {
|
|
8598
|
+
function parseParenthesizedArrow(parser, context, scope, privateScope, params, canAssign, isAsync, start, origin = 0) {
|
|
8445
8599
|
if (!canAssign)
|
|
8446
8600
|
parser.report(57);
|
|
8447
8601
|
for (let i = 0; i < params.length; ++i)
|
|
8448
8602
|
reinterpretToPattern(parser, params[i]);
|
|
8449
|
-
return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start);
|
|
8603
|
+
return parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin);
|
|
8450
8604
|
}
|
|
8451
|
-
function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start) {
|
|
8605
|
+
function parseArrowFunctionExpression(parser, context, scope, privateScope, params, isAsync, start, origin = 0) {
|
|
8452
8606
|
if (parser.flags & 1)
|
|
8453
8607
|
parser.report(48);
|
|
8454
8608
|
consume(parser, context | 32, 10);
|
|
@@ -8466,29 +8620,32 @@ function parseArrowFunctionExpression(parser, context, scope, privateScope, para
|
|
|
8466
8620
|
else {
|
|
8467
8621
|
scope = scope?.createChildScope(64);
|
|
8468
8622
|
const modifierFlags = 4 | 131072 | 8;
|
|
8469
|
-
body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope,
|
|
8623
|
+
body = parseFunctionBody(parser, ((context | modifierFlags) ^ modifierFlags) | 4096, scope, privateScope, void 0, void 0, 16);
|
|
8470
8624
|
switch (parser.getToken()) {
|
|
8471
8625
|
case 69271571:
|
|
8472
8626
|
if ((parser.flags & 1) === 0) {
|
|
8473
|
-
parser.report(
|
|
8627
|
+
parser.report(118);
|
|
8474
8628
|
}
|
|
8475
8629
|
parser.flags |= 8192;
|
|
8476
8630
|
break;
|
|
8477
8631
|
case 67108877:
|
|
8478
8632
|
case 67174409:
|
|
8479
8633
|
case 22:
|
|
8480
|
-
parser.report(
|
|
8634
|
+
parser.report(119);
|
|
8481
8635
|
case 67174411:
|
|
8482
8636
|
if ((parser.flags & 1) === 0) {
|
|
8483
|
-
parser.report(
|
|
8637
|
+
parser.report(118);
|
|
8484
8638
|
}
|
|
8485
8639
|
parser.flags |= 1024;
|
|
8486
8640
|
break;
|
|
8487
8641
|
}
|
|
8488
|
-
if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0)
|
|
8489
|
-
|
|
8642
|
+
if ((parser.getToken() & 8388608) === 8388608 && (parser.flags & 1) === 0) {
|
|
8643
|
+
if (parser.getToken() !== 8673330 || origin !== 32) {
|
|
8644
|
+
parser.report(30, KeywordDescTable[parser.getToken() & 255]);
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8490
8647
|
if ((parser.getToken() & 33619968) === 33619968)
|
|
8491
|
-
parser.report(
|
|
8648
|
+
parser.report(127);
|
|
8492
8649
|
}
|
|
8493
8650
|
parser.assignable = 2;
|
|
8494
8651
|
return parser.finishNode({
|
|
@@ -8504,6 +8661,7 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
|
|
|
8504
8661
|
consume(parser, context, 67174411);
|
|
8505
8662
|
parser.flags = (parser.flags | 128) ^ 128;
|
|
8506
8663
|
parser.strictReservedRange = null;
|
|
8664
|
+
parser.firstAwaitLocation = null;
|
|
8507
8665
|
const params = [];
|
|
8508
8666
|
if (consumeOpt(parser, context, 16))
|
|
8509
8667
|
return params;
|
|
@@ -8523,17 +8681,17 @@ function parseFormalParametersOrFormalList(parser, context, scope, privateScope,
|
|
|
8523
8681
|
parser.flags |= 512;
|
|
8524
8682
|
}
|
|
8525
8683
|
}
|
|
8526
|
-
left = parseAndClassifyIdentifier(parser, context, scope, kind | 1
|
|
8684
|
+
left = parseAndClassifyIdentifier(parser, context, scope, kind | 1);
|
|
8527
8685
|
}
|
|
8528
8686
|
else {
|
|
8529
8687
|
if (token === 2162700) {
|
|
8530
|
-
left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind
|
|
8688
|
+
left = parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
|
|
8531
8689
|
}
|
|
8532
8690
|
else if (token === 69271571) {
|
|
8533
|
-
left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind
|
|
8691
|
+
left = parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, inGroup, 1, kind);
|
|
8534
8692
|
}
|
|
8535
8693
|
else if (token === 14) {
|
|
8536
|
-
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0,
|
|
8694
|
+
left = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 0, inGroup, 1);
|
|
8537
8695
|
}
|
|
8538
8696
|
else {
|
|
8539
8697
|
parser.report(30, KeywordDescTable[token & 255]);
|
|
@@ -8628,7 +8786,7 @@ function parseNewExpression(parser, context, privateScope, inGroup) {
|
|
|
8628
8786
|
const expr = parsePrimaryExpression(parser, context, privateScope, 2, 1, 0, inGroup, 1, tokenStart);
|
|
8629
8787
|
context = (context | 131072) ^ 131072;
|
|
8630
8788
|
if (parser.getToken() === 67108991)
|
|
8631
|
-
parser.report(
|
|
8789
|
+
parser.report(170);
|
|
8632
8790
|
const callee = parseMemberExpressionNoCall(parser, context, privateScope, expr, inGroup, tokenStart);
|
|
8633
8791
|
parser.assignable = 2;
|
|
8634
8792
|
return parser.finishNode({
|
|
@@ -8657,9 +8815,11 @@ function parseAsyncArrowAfterIdent(parser, context, privateScope, canAssign, sta
|
|
|
8657
8815
|
}
|
|
8658
8816
|
return parseArrowFromIdentifier(parser, (context & -524289) | 2048, privateScope, parser.tokenValue, parseIdentifier(parser, context), 0, canAssign, 1, start);
|
|
8659
8817
|
}
|
|
8660
|
-
function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind,
|
|
8818
|
+
function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee, canAssign, kind, flags, start) {
|
|
8661
8819
|
nextToken(parser, context | 32);
|
|
8662
8820
|
const scope = parser.createScopeIfLexical()?.createChildScope(512);
|
|
8821
|
+
const previousFirstAwaitLocation = parser.firstAwaitLocation;
|
|
8822
|
+
parser.firstAwaitLocation = null;
|
|
8663
8823
|
context = (context | 131072) ^ 131072;
|
|
8664
8824
|
if (consumeOpt(parser, context, 16)) {
|
|
8665
8825
|
if (parser.getToken() === 10) {
|
|
@@ -8673,6 +8833,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8673
8833
|
else {
|
|
8674
8834
|
parser.assignable = 2;
|
|
8675
8835
|
}
|
|
8836
|
+
if (previousFirstAwaitLocation)
|
|
8837
|
+
parser.firstAwaitLocation = previousFirstAwaitLocation;
|
|
8676
8838
|
return parser.finishNode({
|
|
8677
8839
|
type: 'CallExpression',
|
|
8678
8840
|
callee,
|
|
@@ -8691,7 +8853,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8691
8853
|
const { tokenStart } = parser;
|
|
8692
8854
|
const token = parser.getToken();
|
|
8693
8855
|
if (token & 143360) {
|
|
8694
|
-
scope?.addBlockName(context, parser.tokenValue, kind
|
|
8856
|
+
scope?.addBlockName(context, parser.tokenValue, kind);
|
|
8695
8857
|
if ((token & 537079808) === 537079808) {
|
|
8696
8858
|
parser.flags |= 512;
|
|
8697
8859
|
}
|
|
@@ -8721,13 +8883,13 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8721
8883
|
else if (token & 2097152) {
|
|
8722
8884
|
expr =
|
|
8723
8885
|
token === 2162700
|
|
8724
|
-
? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind
|
|
8725
|
-
: parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind
|
|
8886
|
+
? parseObjectLiteralOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind)
|
|
8887
|
+
: parseArrayExpressionOrPattern(parser, context, scope, privateScope, 0, 1, 0, kind);
|
|
8726
8888
|
destructible |= parser.destructible;
|
|
8727
8889
|
isNonSimpleParameterList = 1;
|
|
8728
8890
|
if (parser.getToken() !== 16 && parser.getToken() !== 18) {
|
|
8729
8891
|
if (destructible & 8)
|
|
8730
|
-
parser.report(
|
|
8892
|
+
parser.report(124);
|
|
8731
8893
|
expr = parseMemberOrUpdateExpression(parser, context, privateScope, expr, 0, 0, tokenStart);
|
|
8732
8894
|
destructible |= 16;
|
|
8733
8895
|
if ((parser.getToken() & 8388608) === 8388608) {
|
|
@@ -8739,7 +8901,7 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8739
8901
|
}
|
|
8740
8902
|
}
|
|
8741
8903
|
else if (token === 14) {
|
|
8742
|
-
expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind,
|
|
8904
|
+
expr = parseSpreadOrRestElement(parser, context, scope, privateScope, 16, kind, 1, 1, 0);
|
|
8743
8905
|
destructible |=
|
|
8744
8906
|
(parser.getToken() === 16 ? 0 : 16) | parser.destructible;
|
|
8745
8907
|
isNonSimpleParameterList = 1;
|
|
@@ -8760,6 +8922,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8760
8922
|
else {
|
|
8761
8923
|
parser.assignable = 2;
|
|
8762
8924
|
}
|
|
8925
|
+
if (previousFirstAwaitLocation)
|
|
8926
|
+
parser.firstAwaitLocation = previousFirstAwaitLocation;
|
|
8763
8927
|
return parser.finishNode({
|
|
8764
8928
|
type: 'CallExpression',
|
|
8765
8929
|
callee,
|
|
@@ -8783,8 +8947,12 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8783
8947
|
parser.report(27);
|
|
8784
8948
|
if (parser.flags & 1 || flags & 1)
|
|
8785
8949
|
parser.report(48);
|
|
8786
|
-
if (destructible & 128)
|
|
8950
|
+
if (destructible & 128) {
|
|
8951
|
+
const loc = parser.firstAwaitLocation;
|
|
8952
|
+
if (loc)
|
|
8953
|
+
throw new ParseError(loc.start, loc.end, 31);
|
|
8787
8954
|
parser.report(31);
|
|
8955
|
+
}
|
|
8788
8956
|
if (context & (1 | 1024) && destructible & 256)
|
|
8789
8957
|
parser.report(32);
|
|
8790
8958
|
if (isNonSimpleParameterList)
|
|
@@ -8803,6 +8971,8 @@ function parseAsyncArrowOrCallExpression(parser, context, privateScope, callee,
|
|
|
8803
8971
|
else {
|
|
8804
8972
|
parser.assignable = 2;
|
|
8805
8973
|
}
|
|
8974
|
+
if (previousFirstAwaitLocation)
|
|
8975
|
+
parser.firstAwaitLocation = previousFirstAwaitLocation;
|
|
8806
8976
|
return parser.finishNode({
|
|
8807
8977
|
type: 'CallExpression',
|
|
8808
8978
|
callee,
|
|
@@ -8828,9 +8998,6 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
|
|
|
8828
8998
|
let start;
|
|
8829
8999
|
let decorators;
|
|
8830
9000
|
if (parser.leadingDecorators.decorators.length) {
|
|
8831
|
-
if (parser.getToken() === 133) {
|
|
8832
|
-
parser.report(30, '@');
|
|
8833
|
-
}
|
|
8834
9001
|
start = parser.leadingDecorators.start;
|
|
8835
9002
|
decorators = [...parser.leadingDecorators.decorators];
|
|
8836
9003
|
parser.leadingDecorators.decorators.length = 0;
|
|
@@ -8840,19 +9007,19 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
|
|
|
8840
9007
|
decorators = parseDecorators(parser, context, privateScope);
|
|
8841
9008
|
}
|
|
8842
9009
|
context = (context | 16384 | 1) ^ 16384;
|
|
8843
|
-
|
|
9010
|
+
consume(parser, context, 86094);
|
|
8844
9011
|
let id = null;
|
|
8845
9012
|
let superClass = null;
|
|
8846
9013
|
const { tokenValue } = parser;
|
|
8847
9014
|
if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
|
|
8848
9015
|
if (isStrictReservedWord(parser, context, parser.getToken())) {
|
|
8849
|
-
parser.report(
|
|
9016
|
+
parser.report(120);
|
|
8850
9017
|
}
|
|
8851
9018
|
if ((parser.getToken() & 537079808) === 537079808) {
|
|
8852
|
-
parser.report(
|
|
9019
|
+
parser.report(121);
|
|
8853
9020
|
}
|
|
8854
9021
|
if (scope) {
|
|
8855
|
-
scope.addBlockName(context, tokenValue, 32
|
|
9022
|
+
scope.addBlockName(context, tokenValue, 32);
|
|
8856
9023
|
if (flags) {
|
|
8857
9024
|
if (flags & 2) {
|
|
8858
9025
|
parser.declareUnboundVariable(tokenValue);
|
|
@@ -8873,13 +9040,13 @@ function parseClassDeclaration(parser, context, scope, privateScope, flags) {
|
|
|
8873
9040
|
else {
|
|
8874
9041
|
inheritedContext = (inheritedContext | 512) ^ 512;
|
|
8875
9042
|
}
|
|
8876
|
-
const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2,
|
|
9043
|
+
const body = parseClassBody(parser, inheritedContext, context, scope, privateScope, 2, 0, 8);
|
|
8877
9044
|
return parser.finishNode({
|
|
8878
9045
|
type: 'ClassDeclaration',
|
|
8879
9046
|
id,
|
|
8880
9047
|
superClass,
|
|
8881
9048
|
body,
|
|
8882
|
-
...(parser.
|
|
9049
|
+
...(parser.features & 1 ? { decorators } : null),
|
|
8883
9050
|
}, start);
|
|
8884
9051
|
}
|
|
8885
9052
|
function parseClassExpression(parser, context, privateScope, inGroup, start) {
|
|
@@ -8887,12 +9054,12 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
|
|
|
8887
9054
|
let superClass = null;
|
|
8888
9055
|
const decorators = parseDecorators(parser, context, privateScope);
|
|
8889
9056
|
context = (context | 1 | 16384) ^ 16384;
|
|
8890
|
-
|
|
9057
|
+
consume(parser, context, 86094);
|
|
8891
9058
|
if (parser.getToken() & 4096 && parser.getToken() !== 20565) {
|
|
8892
9059
|
if (isStrictReservedWord(parser, context, parser.getToken()))
|
|
8893
|
-
parser.report(
|
|
9060
|
+
parser.report(120);
|
|
8894
9061
|
if ((parser.getToken() & 537079808) === 537079808) {
|
|
8895
|
-
parser.report(
|
|
9062
|
+
parser.report(121);
|
|
8896
9063
|
}
|
|
8897
9064
|
id = parseIdentifier(parser, context);
|
|
8898
9065
|
}
|
|
@@ -8904,37 +9071,74 @@ function parseClassExpression(parser, context, privateScope, inGroup, start) {
|
|
|
8904
9071
|
else {
|
|
8905
9072
|
inheritedContext = (inheritedContext | 512) ^ 512;
|
|
8906
9073
|
}
|
|
8907
|
-
const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2,
|
|
9074
|
+
const body = parseClassBody(parser, inheritedContext, context, void 0, privateScope, 2, inGroup);
|
|
8908
9075
|
parser.assignable = 2;
|
|
8909
9076
|
return parser.finishNode({
|
|
8910
9077
|
type: 'ClassExpression',
|
|
8911
9078
|
id,
|
|
8912
9079
|
superClass,
|
|
8913
9080
|
body,
|
|
8914
|
-
...(parser.
|
|
9081
|
+
...(parser.features & 1 ? { decorators } : null),
|
|
8915
9082
|
}, start);
|
|
8916
9083
|
}
|
|
8917
9084
|
function parseDecorators(parser, context, privateScope) {
|
|
8918
9085
|
const list = [];
|
|
8919
|
-
if (parser.
|
|
9086
|
+
if (parser.features & 1) {
|
|
8920
9087
|
while (parser.getToken() === 133) {
|
|
8921
|
-
list.push(
|
|
9088
|
+
list.push(parseDecorator(parser, context, privateScope));
|
|
8922
9089
|
}
|
|
8923
9090
|
}
|
|
8924
9091
|
return list;
|
|
8925
9092
|
}
|
|
8926
|
-
function
|
|
9093
|
+
function parseDecorator(parser, context, privateScope) {
|
|
8927
9094
|
const start = parser.tokenStart;
|
|
8928
9095
|
nextToken(parser, context | 32);
|
|
8929
9096
|
const expressionStart = parser.tokenStart;
|
|
8930
|
-
let expression
|
|
8931
|
-
|
|
9097
|
+
let expression;
|
|
9098
|
+
if (parser.getToken() === 67174411) {
|
|
9099
|
+
expression = parsePrimaryExpression(parser, context, privateScope, 2, 0, 1, 0, 1, start);
|
|
9100
|
+
}
|
|
9101
|
+
else {
|
|
9102
|
+
const token = parser.getToken();
|
|
9103
|
+
if (((token & 143360) !== 143360 && !isValidIdentifier(context, token)) ||
|
|
9104
|
+
(context & 1 && (token & 36864) === 36864)) {
|
|
9105
|
+
parser.report(30, KeywordDescTable[token & 255]);
|
|
9106
|
+
}
|
|
9107
|
+
if (token === 209006 && context & (2048 | 2)) {
|
|
9108
|
+
parser.report(112);
|
|
9109
|
+
}
|
|
9110
|
+
if (token === 241771 && context & 1024) {
|
|
9111
|
+
parser.report(97, 'yield');
|
|
9112
|
+
}
|
|
9113
|
+
let memberExpression = parseIdentifier(parser, context | 64);
|
|
9114
|
+
while (parser.getToken() === 67108877) {
|
|
9115
|
+
nextToken(parser, (context | 262144 | 8) ^ 8);
|
|
9116
|
+
const property = parsePropertyOrPrivatePropertyName(parser, context | 64, privateScope);
|
|
9117
|
+
memberExpression = parser.finishNode({
|
|
9118
|
+
type: 'MemberExpression',
|
|
9119
|
+
object: memberExpression,
|
|
9120
|
+
computed: false,
|
|
9121
|
+
property,
|
|
9122
|
+
optional: false,
|
|
9123
|
+
}, expressionStart);
|
|
9124
|
+
}
|
|
9125
|
+
expression = memberExpression;
|
|
9126
|
+
if (parser.getToken() === 67174411) {
|
|
9127
|
+
const args = parseArguments(parser, context, privateScope, 0);
|
|
9128
|
+
expression = parser.finishNode({
|
|
9129
|
+
type: 'CallExpression',
|
|
9130
|
+
callee: memberExpression,
|
|
9131
|
+
arguments: args,
|
|
9132
|
+
optional: false,
|
|
9133
|
+
}, expressionStart);
|
|
9134
|
+
}
|
|
9135
|
+
}
|
|
8932
9136
|
return parser.finishNode({
|
|
8933
9137
|
type: 'Decorator',
|
|
8934
9138
|
expression,
|
|
8935
9139
|
}, start);
|
|
8936
9140
|
}
|
|
8937
|
-
function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind,
|
|
9141
|
+
function parseClassBody(parser, context, inheritedContext, scope, parentScope, kind, inGroup, origin = 0) {
|
|
8938
9142
|
const { tokenStart } = parser;
|
|
8939
9143
|
const privateScope = parser.createPrivateScopeIfLexical(parentScope);
|
|
8940
9144
|
consume(parser, context | 32, 2162700);
|
|
@@ -8947,13 +9151,13 @@ function parseClassBody(parser, context, inheritedContext, scope, parentScope, k
|
|
|
8947
9151
|
const decoratorStart = parser.tokenStart;
|
|
8948
9152
|
const decorators = parseDecorators(parser, context, privateScope);
|
|
8949
9153
|
if (decorators.length > 0 && parser.tokenValue === 'constructor') {
|
|
8950
|
-
parser.report(
|
|
9154
|
+
parser.report(111);
|
|
8951
9155
|
}
|
|
8952
9156
|
if (parser.getToken() === 1074790415)
|
|
8953
|
-
parser.report(
|
|
9157
|
+
parser.report(110);
|
|
8954
9158
|
if (consumeOpt(parser, context, 1074790417)) {
|
|
8955
9159
|
if (decorators.length > 0)
|
|
8956
|
-
parser.report(
|
|
9160
|
+
parser.report(122);
|
|
8957
9161
|
continue;
|
|
8958
9162
|
}
|
|
8959
9163
|
body.push(parseClassElementList(parser, context, scope, privateScope, inheritedContext, kind, decorators, 0, inGroup, decorators.length > 0 ? decoratorStart : parser.tokenStart));
|
|
@@ -9016,7 +9220,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
|
|
|
9016
9220
|
if ((parser.getToken() & 1073741824) === 1073741824) {
|
|
9017
9221
|
return parsePropertyDefinition(parser, context, privateScope, key, kind, decorators, start);
|
|
9018
9222
|
}
|
|
9019
|
-
if (parser.
|
|
9223
|
+
if (parser.features & 1)
|
|
9020
9224
|
kind |= 1024;
|
|
9021
9225
|
}
|
|
9022
9226
|
break;
|
|
@@ -9069,12 +9273,12 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
|
|
|
9069
9273
|
key = parsePrivateIdentifier(parser, context, privateScope, kind);
|
|
9070
9274
|
}
|
|
9071
9275
|
else
|
|
9072
|
-
parser.report(
|
|
9276
|
+
parser.report(137);
|
|
9073
9277
|
}
|
|
9074
9278
|
if ((kind & 2) === 0) {
|
|
9075
9279
|
if (parser.tokenValue === 'constructor') {
|
|
9076
9280
|
if ((parser.getToken() & 1073741824) === 1073741824) {
|
|
9077
|
-
parser.report(
|
|
9281
|
+
parser.report(131);
|
|
9078
9282
|
}
|
|
9079
9283
|
else if ((kind & 32) === 0 && parser.getToken() === 67174411) {
|
|
9080
9284
|
if (kind & (768 | 16 | 128 | 8)) {
|
|
@@ -9112,7 +9316,7 @@ function parseClassElementList(parser, context, scope, privateScope, inheritedCo
|
|
|
9112
9316
|
computed: (kind & 2) > 0,
|
|
9113
9317
|
key,
|
|
9114
9318
|
value,
|
|
9115
|
-
...(parser.
|
|
9319
|
+
...(parser.features & 1 ? { decorators } : null),
|
|
9116
9320
|
}, start);
|
|
9117
9321
|
}
|
|
9118
9322
|
function parsePrivateIdentifier(parser, context, privateScope, kind) {
|
|
@@ -9120,7 +9324,7 @@ function parsePrivateIdentifier(parser, context, privateScope, kind) {
|
|
|
9120
9324
|
nextToken(parser, context);
|
|
9121
9325
|
const { tokenValue } = parser;
|
|
9122
9326
|
if (tokenValue === 'constructor')
|
|
9123
|
-
parser.report(
|
|
9327
|
+
parser.report(130);
|
|
9124
9328
|
if (parser.options.lexical) {
|
|
9125
9329
|
if (!privateScope)
|
|
9126
9330
|
parser.report(4, tokenValue);
|
|
@@ -9145,7 +9349,7 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
|
|
|
9145
9349
|
nextToken(parser, context | 32);
|
|
9146
9350
|
const { tokenStart } = parser;
|
|
9147
9351
|
if (parser.getToken() === 537079928)
|
|
9148
|
-
parser.report(
|
|
9352
|
+
parser.report(121);
|
|
9149
9353
|
const modifierFlags = 1024 |
|
|
9150
9354
|
2048 |
|
|
9151
9355
|
8192 |
|
|
@@ -9171,32 +9375,32 @@ function parsePropertyDefinition(parser, context, privateScope, key, state, deco
|
|
|
9171
9375
|
value,
|
|
9172
9376
|
static: (state & 32) > 0,
|
|
9173
9377
|
computed: (state & 2) > 0,
|
|
9174
|
-
...(parser.
|
|
9378
|
+
...(parser.features & 1 ? { decorators } : null),
|
|
9175
9379
|
}, start);
|
|
9176
9380
|
}
|
|
9177
|
-
function parseBindingPattern(parser, context, scope, privateScope,
|
|
9381
|
+
function parseBindingPattern(parser, context, scope, privateScope, kind, origin = 0) {
|
|
9178
9382
|
if (parser.getToken() & 143360 ||
|
|
9179
9383
|
((context & 1) === 0 && parser.getToken() === -2147483526))
|
|
9180
|
-
return parseAndClassifyIdentifier(parser, context, scope,
|
|
9384
|
+
return parseAndClassifyIdentifier(parser, context, scope, kind, origin);
|
|
9181
9385
|
if ((parser.getToken() & 2097152) !== 2097152)
|
|
9182
9386
|
parser.report(30, KeywordDescTable[parser.getToken() & 255]);
|
|
9183
9387
|
const left = parser.getToken() === 69271571
|
|
9184
|
-
? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1,
|
|
9185
|
-
: parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1,
|
|
9388
|
+
? parseArrayExpressionOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin)
|
|
9389
|
+
: parseObjectLiteralOrPattern(parser, context, scope, privateScope, 1, 0, 1, kind, origin);
|
|
9186
9390
|
if (parser.destructible & 16)
|
|
9187
9391
|
parser.report(50);
|
|
9188
9392
|
if (parser.destructible & 32)
|
|
9189
9393
|
parser.report(50);
|
|
9190
9394
|
return left;
|
|
9191
9395
|
}
|
|
9192
|
-
function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
|
|
9396
|
+
function parseAndClassifyIdentifier(parser, context, scope, kind, origin = 0) {
|
|
9193
9397
|
const token = parser.getToken();
|
|
9194
9398
|
if (context & 1) {
|
|
9195
9399
|
if ((token & 537079808) === 537079808) {
|
|
9196
|
-
parser.report(
|
|
9400
|
+
parser.report(121);
|
|
9197
9401
|
}
|
|
9198
9402
|
else if ((token & 36864) === 36864 || token === -2147483526) {
|
|
9199
|
-
parser.report(
|
|
9403
|
+
parser.report(120);
|
|
9200
9404
|
}
|
|
9201
9405
|
}
|
|
9202
9406
|
if ((token & 20480) === 20480) {
|
|
@@ -9206,7 +9410,7 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
|
|
|
9206
9410
|
if (context & 1024)
|
|
9207
9411
|
parser.report(32);
|
|
9208
9412
|
if (context & 2)
|
|
9209
|
-
parser.report(
|
|
9413
|
+
parser.report(113);
|
|
9210
9414
|
}
|
|
9211
9415
|
if ((token & 255) === (241737 & 255)) {
|
|
9212
9416
|
if (kind & (8 | 16))
|
|
@@ -9214,9 +9418,9 @@ function parseAndClassifyIdentifier(parser, context, scope, kind, origin) {
|
|
|
9214
9418
|
}
|
|
9215
9419
|
if (token === 209006) {
|
|
9216
9420
|
if (context & 2048)
|
|
9217
|
-
parser.report(
|
|
9421
|
+
parser.report(178);
|
|
9218
9422
|
if (context & 2)
|
|
9219
|
-
parser.report(
|
|
9423
|
+
parser.report(112);
|
|
9220
9424
|
}
|
|
9221
9425
|
const { tokenValue, tokenStart: start } = parser;
|
|
9222
9426
|
nextToken(parser, context);
|
|
@@ -9248,7 +9452,7 @@ function parseJSXRootElementOrFragment(parser, context, privateScope, inJSXChild
|
|
|
9248
9452
|
[children, closingElement] = parseJSXChildrenAndClosingElement(parser, context, privateScope, inJSXChild);
|
|
9249
9453
|
const close = isEqualTagName(closingElement.name);
|
|
9250
9454
|
if (isEqualTagName(openingElement.name) !== close)
|
|
9251
|
-
parser.report(
|
|
9455
|
+
parser.report(157, close);
|
|
9252
9456
|
}
|
|
9253
9457
|
return parser.finishNode({
|
|
9254
9458
|
type: 'JSXElement',
|
|
@@ -9317,7 +9521,7 @@ function parseJSXChildrenAndClosingFragment(parser, context, privateScope, inJSX
|
|
|
9317
9521
|
}
|
|
9318
9522
|
function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild) {
|
|
9319
9523
|
if (parser.getToken() === 138)
|
|
9320
|
-
return parseJSXText(parser
|
|
9524
|
+
return parseJSXText(parser);
|
|
9321
9525
|
if (parser.getToken() === 2162700)
|
|
9322
9526
|
return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
|
|
9323
9527
|
if (parser.getToken() === 8456256) {
|
|
@@ -9331,7 +9535,7 @@ function parseJSXChildOrClosingElement(parser, context, privateScope, inJSXChild
|
|
|
9331
9535
|
}
|
|
9332
9536
|
function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChild) {
|
|
9333
9537
|
if (parser.getToken() === 138)
|
|
9334
|
-
return parseJSXText(parser
|
|
9538
|
+
return parseJSXText(parser);
|
|
9335
9539
|
if (parser.getToken() === 2162700)
|
|
9336
9540
|
return parseJSXExpressionContainer(parser, context, privateScope, 1, 0);
|
|
9337
9541
|
if (parser.getToken() === 8456256) {
|
|
@@ -9343,9 +9547,9 @@ function parseJSXChildOrClosingFragment(parser, context, privateScope, inJSXChil
|
|
|
9343
9547
|
}
|
|
9344
9548
|
parser.report(0);
|
|
9345
9549
|
}
|
|
9346
|
-
function parseJSXText(parser
|
|
9550
|
+
function parseJSXText(parser) {
|
|
9347
9551
|
const start = parser.tokenStart;
|
|
9348
|
-
|
|
9552
|
+
nextJSXToken(parser);
|
|
9349
9553
|
const node = {
|
|
9350
9554
|
type: 'JSXText',
|
|
9351
9555
|
value: parser.tokenValue,
|
|
@@ -9443,7 +9647,7 @@ function parseJsxAttribute(parser, context, privateScope) {
|
|
|
9443
9647
|
value = parseJSXExpressionContainer(parser, context, privateScope, 0, 1);
|
|
9444
9648
|
break;
|
|
9445
9649
|
default:
|
|
9446
|
-
parser.report(
|
|
9650
|
+
parser.report(156);
|
|
9447
9651
|
}
|
|
9448
9652
|
}
|
|
9449
9653
|
return parser.finishNode({
|
|
@@ -9470,7 +9674,7 @@ function parseJSXExpressionContainer(parser, context, privateScope, inJSXChild,
|
|
|
9470
9674
|
let expression;
|
|
9471
9675
|
if (parser.getToken() === 1074790415) {
|
|
9472
9676
|
if (isAttr)
|
|
9473
|
-
parser.report(
|
|
9677
|
+
parser.report(159);
|
|
9474
9678
|
expression = parseJSXEmptyExpression(parser, {
|
|
9475
9679
|
index: parser.startIndex,
|
|
9476
9680
|
line: parser.startLine,
|