@samitouri / QOS-React-2 / commits / f21270a97d

[rust] Complete estree through ES2021

Adds more AST types to handle the full ES2021 spec. At least, in theory I defined the schema correctly, and we'll have to just fix any bugs as we encounter them.

Joe Savona committed Jul 25, 2023 at 15:58 UTC f21270a97d531c45e7f57960a5436a1fd9e9c35c
8 files changed +886 -21
compiler/forget/crates/forget_estree/src/generated.rs
+735 -5
@@ -36,6 +36,11 @@ pub struct RegExpValue {
36 pub pattern: String,
37 pub flags: String,
38 }
39 +#[derive(Serialize, Deserialize, Clone, Debug)]
40 +pub struct TemplateElementValue {
41 + pub cooked: Option<String>,
42 + pub raw: String,
43 +}
44 #[derive(Deserialize, Clone, Debug)]
45 pub struct Identifier {
46 pub name: String,
@@ -68,6 +73,8 @@ pub struct Literal {
73 #[serde(default)]
74 pub regex: Option<RegExpValue>,
75 #[serde(default)]
76 + pub bigint: Option<String>,
77 + #[serde(default)]
78 pub loc: Option<SourceLocation>,
79 #[serde(default)]
80 pub range: Option<SourceRange>,
@@ -82,6 +89,7 @@ impl Serialize for Literal {
89 state.serialize_entry("value", &self.value)?;
90 state.serialize_entry("raw", &self.raw)?;
91 state.serialize_entry("regex", &self.regex)?;
92 + state.serialize_entry("bigint", &self.bigint)?;
93 state.serialize_entry("loc", &self.loc)?;
94 state.serialize_entry("range", &self.range)?;
95 state.end()
@@ -423,7 +431,7 @@ impl Serialize for TryStatement {
431 }
432 #[derive(Deserialize, Clone, Debug)]
433 pub struct CatchClause {
426 - pub param: Pattern,
434 + pub param: Option<Pattern>,
435 pub body: BlockStatement,
436 #[serde(default)]
437 pub loc: Option<SourceLocation>,
@@ -544,6 +552,9 @@ impl Serialize for ForInStatement {
552 }
553 #[derive(Deserialize, Clone, Debug)]
554 pub struct ForOfStatement {
555 + #[serde(rename = "await")]
556 + #[serde(default)]
557 + pub is_await: bool,
558 pub left: ForInInit,
559 pub right: Expression,
560 pub body: Statement,
@@ -559,6 +570,7 @@ impl Serialize for ForOfStatement {
570 {
571 let mut state = serializer.serialize_map(None)?;
572 state.serialize_entry("type", "ForOfStatement")?;
573 + state.serialize_entry("await", &self.is_await)?;
574 state.serialize_entry("left", &self.left)?;
575 state.serialize_entry("right", &self.right)?;
576 state.serialize_entry("body", &self.body)?;
@@ -808,7 +820,7 @@ impl Serialize for ArrayExpression {
820 }
821 #[derive(Deserialize, Clone, Debug)]
822 pub struct ObjectExpression {
811 - pub properties: Vec<Property>,
823 + pub properties: Vec<PropertyOrSpreadElement>,
824 #[serde(default)]
825 pub loc: Option<SourceLocation>,
826 #[serde(default)]
@@ -1043,7 +1055,11 @@ impl Serialize for LogicalExpression {
1055 pub struct MemberExpression {
1056 pub object: ExpressionOrSuper,
1057 pub property: Expression,
1046 - pub computed: bool,
1058 + #[serde(rename = "computed")]
1059 + pub is_computed: bool,
1060 + #[serde(rename = "optional")]
1061 + #[serde(default)]
1062 + pub is_optional: bool,
1063 #[serde(default)]
1064 pub loc: Option<SourceLocation>,
1065 #[serde(default)]
@@ -1058,7 +1074,8 @@ impl Serialize for MemberExpression {
1074 state.serialize_entry("type", "MemberExpression")?;
1075 state.serialize_entry("object", &self.object)?;
1076 state.serialize_entry("property", &self.property)?;
1061 - state.serialize_entry("computed", &self.computed)?;
1077 + state.serialize_entry("computed", &self.is_computed)?;
1078 + state.serialize_entry("optional", &self.is_optional)?;
1079 state.serialize_entry("loc", &self.loc)?;
1080 state.serialize_entry("range", &self.range)?;
1081 state.end()
@@ -1093,6 +1110,9 @@ impl Serialize for ConditionalExpression {
1110 pub struct CallExpression {
1111 pub callee: ExpressionOrSuper,
1112 pub arguments: Vec<ExpressionOrSpread>,
1113 + #[serde(rename = "optional")]
1114 + #[serde(default)]
1115 + pub is_optional: bool,
1116 #[serde(default)]
1117 pub loc: Option<SourceLocation>,
1118 #[serde(default)]
@@ -1107,6 +1127,7 @@ impl Serialize for CallExpression {
1127 state.serialize_entry("type", "CallExpression")?;
1128 state.serialize_entry("callee", &self.callee)?;
1129 state.serialize_entry("arguments", &self.arguments)?;
1130 + state.serialize_entry("optional", &self.is_optional)?;
1131 state.serialize_entry("loc", &self.loc)?;
1132 state.serialize_entry("range", &self.range)?;
1133 state.end()
@@ -1380,6 +1401,8 @@ impl Serialize for ExportDefaultDeclaration {
1401 pub struct ExportAllDeclaration {
1402 pub source: Literal,
1403 #[serde(default)]
1404 + pub exported: Option<Identifier>,
1405 + #[serde(default)]
1406 pub loc: Option<SourceLocation>,
1407 #[serde(default)]
1408 pub range: Option<SourceRange>,
@@ -1392,6 +1415,7 @@ impl Serialize for ExportAllDeclaration {
1415 let mut state = serializer.serialize_map(None)?;
1416 state.serialize_entry("type", "ExportAllDeclaration")?;
1417 state.serialize_entry("source", &self.source)?;
1418 + state.serialize_entry("exported", &self.exported)?;
1419 state.serialize_entry("loc", &self.loc)?;
1420 state.serialize_entry("range", &self.range)?;
1421 state.end()
@@ -1754,7 +1778,7 @@ impl Serialize for ArrayPattern {
1778 }
1779 #[derive(Deserialize, Clone, Debug)]
1780 pub struct ObjectPattern {
1757 - pub properties: Vec<AssignmentProperty>,
1781 + pub properties: Vec<AssignmentPropertyOrRestElement>,
1782 #[serde(default)]
1783 pub loc: Option<SourceLocation>,
1784 #[serde(default)]
@@ -1844,6 +1868,161 @@ impl Serialize for AssignmentPattern {
1868 state.end()
1869 }
1870 }
1871 +#[derive(Deserialize, Clone, Debug)]
1872 +pub struct TemplateLiteral {
1873 + pub quasis: Vec<TemplateElement>,
1874 + pub expressions: Vec<Expression>,
1875 + #[serde(default)]
1876 + pub loc: Option<SourceLocation>,
1877 + #[serde(default)]
1878 + pub range: Option<SourceRange>,
1879 +}
1880 +impl Serialize for TemplateLiteral {
1881 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1882 + where
1883 + S: Serializer,
1884 + {
1885 + let mut state = serializer.serialize_map(None)?;
1886 + state.serialize_entry("type", "TemplateLiteral")?;
1887 + state.serialize_entry("quasis", &self.quasis)?;
1888 + state.serialize_entry("expressions", &self.expressions)?;
1889 + state.serialize_entry("loc", &self.loc)?;
1890 + state.serialize_entry("range", &self.range)?;
1891 + state.end()
1892 + }
1893 +}
1894 +#[derive(Deserialize, Clone, Debug)]
1895 +pub struct TemplateElement {
1896 + pub tail: bool,
1897 + pub value: TemplateElementValue,
1898 + #[serde(default)]
1899 + pub loc: Option<SourceLocation>,
1900 + #[serde(default)]
1901 + pub range: Option<SourceRange>,
1902 +}
1903 +impl Serialize for TemplateElement {
1904 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1905 + where
1906 + S: Serializer,
1907 + {
1908 + let mut state = serializer.serialize_map(None)?;
1909 + state.serialize_entry("type", "TemplateElement")?;
1910 + state.serialize_entry("tail", &self.tail)?;
1911 + state.serialize_entry("value", &self.value)?;
1912 + state.serialize_entry("loc", &self.loc)?;
1913 + state.serialize_entry("range", &self.range)?;
1914 + state.end()
1915 + }
1916 +}
1917 +#[derive(Deserialize, Clone, Debug)]
1918 +pub struct TaggedTemplateExpression {
1919 + pub tag: Expression,
1920 + pub quasi: TemplateLiteral,
1921 + #[serde(default)]
1922 + pub loc: Option<SourceLocation>,
1923 + #[serde(default)]
1924 + pub range: Option<SourceRange>,
1925 +}
1926 +impl Serialize for TaggedTemplateExpression {
1927 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1928 + where
1929 + S: Serializer,
1930 + {
1931 + let mut state = serializer.serialize_map(None)?;
1932 + state.serialize_entry("type", "TaggedTemplateExpression")?;
1933 + state.serialize_entry("tag", &self.tag)?;
1934 + state.serialize_entry("quasi", &self.quasi)?;
1935 + state.serialize_entry("loc", &self.loc)?;
1936 + state.serialize_entry("range", &self.range)?;
1937 + state.end()
1938 + }
1939 +}
1940 +#[derive(Deserialize, Clone, Debug)]
1941 +pub struct MetaProperty {
1942 + pub meta: Identifier,
1943 + pub property: Identifier,
1944 + #[serde(default)]
1945 + pub loc: Option<SourceLocation>,
1946 + #[serde(default)]
1947 + pub range: Option<SourceRange>,
1948 +}
1949 +impl Serialize for MetaProperty {
1950 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1951 + where
1952 + S: Serializer,
1953 + {
1954 + let mut state = serializer.serialize_map(None)?;
1955 + state.serialize_entry("type", "MetaProperty")?;
1956 + state.serialize_entry("meta", &self.meta)?;
1957 + state.serialize_entry("property", &self.property)?;
1958 + state.serialize_entry("loc", &self.loc)?;
1959 + state.serialize_entry("range", &self.range)?;
1960 + state.end()
1961 + }
1962 +}
1963 +#[derive(Deserialize, Clone, Debug)]
1964 +pub struct AwaitExpression {
1965 + pub argument: Expression,
1966 + #[serde(default)]
1967 + pub loc: Option<SourceLocation>,
1968 + #[serde(default)]
1969 + pub range: Option<SourceRange>,
1970 +}
1971 +impl Serialize for AwaitExpression {
1972 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1973 + where
1974 + S: Serializer,
1975 + {
1976 + let mut state = serializer.serialize_map(None)?;
1977 + state.serialize_entry("type", "AwaitExpression")?;
1978 + state.serialize_entry("argument", &self.argument)?;
1979 + state.serialize_entry("loc", &self.loc)?;
1980 + state.serialize_entry("range", &self.range)?;
1981 + state.end()
1982 + }
1983 +}
1984 +#[derive(Deserialize, Clone, Debug)]
1985 +pub struct ChainExpression {
1986 + pub expression: ChainElement,
1987 + #[serde(default)]
1988 + pub loc: Option<SourceLocation>,
1989 + #[serde(default)]
1990 + pub range: Option<SourceRange>,
1991 +}
1992 +impl Serialize for ChainExpression {
1993 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1994 + where
1995 + S: Serializer,
1996 + {
1997 + let mut state = serializer.serialize_map(None)?;
1998 + state.serialize_entry("type", "ChainExpression")?;
1999 + state.serialize_entry("expression", &self.expression)?;
2000 + state.serialize_entry("loc", &self.loc)?;
2001 + state.serialize_entry("range", &self.range)?;
2002 + state.end()
2003 + }
2004 +}
2005 +#[derive(Deserialize, Clone, Debug)]
2006 +pub struct ImportExpression {
2007 + pub source: Expression,
2008 + #[serde(default)]
2009 + pub loc: Option<SourceLocation>,
2010 + #[serde(default)]
2011 + pub range: Option<SourceRange>,
2012 +}
2013 +impl Serialize for ImportExpression {
2014 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2015 + where
2016 + S: Serializer,
2017 + {
2018 + let mut state = serializer.serialize_map(None)?;
2019 + state.serialize_entry("type", "ImportExpression")?;
2020 + state.serialize_entry("source", &self.source)?;
2021 + state.serialize_entry("loc", &self.loc)?;
2022 + state.serialize_entry("range", &self.range)?;
2023 + state.end()
2024 + }
2025 +}
2026 #[derive(Serialize, Clone, Debug)]
2027 #[serde(untagged)]
2028 pub enum Statement {
@@ -2082,19 +2261,25 @@ pub enum Expression {
2261 ArrayExpression(Box<ArrayExpression>),
2262 ArrowFunctionExpression(Box<ArrowFunctionExpression>),
2263 AssignmentExpression(Box<AssignmentExpression>),
2264 + AwaitExpression(Box<AwaitExpression>),
2265 BinaryExpression(Box<BinaryExpression>),
2266 CallExpression(Box<CallExpression>),
2267 + ChainExpression(Box<ChainExpression>),
2268 ClassExpression(Box<ClassExpression>),
2269 ConditionalExpression(Box<ConditionalExpression>),
2270 FunctionExpression(Box<FunctionExpression>),
2271 Identifier(Box<Identifier>),
2272 + ImportExpression(Box<ImportExpression>),
2273 JSXElement(Box<JSXElement>),
2274 Literal(Box<Literal>),
2275 LogicalExpression(Box<LogicalExpression>),
2276 MemberExpression(Box<MemberExpression>),
2277 + MetaProperty(Box<MetaProperty>),
2278 NewExpression(Box<NewExpression>),
2279 ObjectExpression(Box<ObjectExpression>),
2280 SequenceExpression(Box<SequenceExpression>),
2281 + TaggedTemplateExpression(Box<TaggedTemplateExpression>),
2282 + TemplateLiteral(Box<TemplateLiteral>),
2283 ThisExpression(Box<ThisExpression>),
2284 UnaryExpression(Box<UnaryExpression>),
2285 UpdateExpression(Box<UpdateExpression>),
@@ -2105,19 +2290,25 @@ enum __ExpressionTag {
2290 ArrayExpression,
2291 ArrowFunctionExpression,
2292 AssignmentExpression,
2293 + AwaitExpression,
2294 BinaryExpression,
2295 CallExpression,
2296 + ChainExpression,
2297 ClassExpression,
2298 ConditionalExpression,
2299 FunctionExpression,
2300 Identifier,
2301 + ImportExpression,
2302 JSXElement,
2303 Literal,
2304 LogicalExpression,
2305 MemberExpression,
2306 + MetaProperty,
2307 NewExpression,
2308 ObjectExpression,
2309 SequenceExpression,
2310 + TaggedTemplateExpression,
2311 + TemplateLiteral,
2312 ThisExpression,
2313 UnaryExpression,
2314 UpdateExpression,
@@ -2159,6 +2350,14 @@ impl<'de> serde::Deserialize<'de> for Expression {
2350 )?;
2351 Ok(Expression::AssignmentExpression(node))
2352 }
2353 + __ExpressionTag::AwaitExpression => {
2354 + let node: Box<AwaitExpression> = <Box<
2355 + AwaitExpression,
2356 + > as Deserialize>::deserialize(
2357 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2358 + )?;
2359 + Ok(Expression::AwaitExpression(node))
2360 + }
2361 __ExpressionTag::BinaryExpression => {
2362 let node: Box<BinaryExpression> = <Box<
2363 BinaryExpression,
@@ -2175,6 +2374,14 @@ impl<'de> serde::Deserialize<'de> for Expression {
2374 )?;
2375 Ok(Expression::CallExpression(node))
2376 }
2377 + __ExpressionTag::ChainExpression => {
2378 + let node: Box<ChainExpression> = <Box<
2379 + ChainExpression,
2380 + > as Deserialize>::deserialize(
2381 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2382 + )?;
2383 + Ok(Expression::ChainExpression(node))
2384 + }
2385 __ExpressionTag::ClassExpression => {
2386 let node: Box<ClassExpression> = <Box<
2387 ClassExpression,
@@ -2207,6 +2414,14 @@ impl<'de> serde::Deserialize<'de> for Expression {
2414 )?;
2415 Ok(Expression::Identifier(node))
2416 }
2417 + __ExpressionTag::ImportExpression => {
2418 + let node: Box<ImportExpression> = <Box<
2419 + ImportExpression,
2420 + > as Deserialize>::deserialize(
2421 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2422 + )?;
2423 + Ok(Expression::ImportExpression(node))
2424 + }
2425 __ExpressionTag::JSXElement => {
2426 let node: Box<JSXElement> = <Box<
2427 JSXElement,
@@ -2239,6 +2454,14 @@ impl<'de> serde::Deserialize<'de> for Expression {
2454 )?;
2455 Ok(Expression::MemberExpression(node))
2456 }
2457 + __ExpressionTag::MetaProperty => {
2458 + let node: Box<MetaProperty> = <Box<
2459 + MetaProperty,
2460 + > as Deserialize>::deserialize(
2461 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2462 + )?;
2463 + Ok(Expression::MetaProperty(node))
2464 + }
2465 __ExpressionTag::NewExpression => {
2466 let node: Box<NewExpression> = <Box<
2467 NewExpression,
@@ -2263,6 +2486,22 @@ impl<'de> serde::Deserialize<'de> for Expression {
2486 )?;
2487 Ok(Expression::SequenceExpression(node))
2488 }
2489 + __ExpressionTag::TaggedTemplateExpression => {
2490 + let node: Box<TaggedTemplateExpression> = <Box<
2491 + TaggedTemplateExpression,
2492 + > as Deserialize>::deserialize(
2493 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2494 + )?;
2495 + Ok(Expression::TaggedTemplateExpression(node))
2496 + }
2497 + __ExpressionTag::TemplateLiteral => {
2498 + let node: Box<TemplateLiteral> = <Box<
2499 + TemplateLiteral,
2500 + > as Deserialize>::deserialize(
2501 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
2502 + )?;
2503 + Ok(Expression::TemplateLiteral(node))
2504 + }
2505 __ExpressionTag::ThisExpression => {
2506 let node: Box<ThisExpression> = <Box<
2507 ThisExpression,
@@ -2740,19 +2979,25 @@ enum __ExpressionOrSuperTag {
2979 ArrayExpression,
2980 ArrowFunctionExpression,
2981 AssignmentExpression,
2982 + AwaitExpression,
2983 BinaryExpression,
2984 CallExpression,
2985 + ChainExpression,
2986 ClassExpression,
2987 ConditionalExpression,
2988 FunctionExpression,
2989 Identifier,
2990 + ImportExpression,
2991 JSXElement,
2992 Literal,
2993 LogicalExpression,
2994 MemberExpression,
2995 + MetaProperty,
2996 NewExpression,
2997 ObjectExpression,
2998 SequenceExpression,
2999 + TaggedTemplateExpression,
3000 + TemplateLiteral,
3001 ThisExpression,
3002 UnaryExpression,
3003 UpdateExpression,
@@ -2799,6 +3044,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSuper {
3044 )?;
3045 Ok(ExpressionOrSuper::Expression(Expression::AssignmentExpression(node)))
3046 }
3047 + __ExpressionOrSuperTag::AwaitExpression => {
3048 + let node: Box<AwaitExpression> = <Box<
3049 + AwaitExpression,
3050 + > as Deserialize>::deserialize(
3051 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3052 + )?;
3053 + Ok(ExpressionOrSuper::Expression(Expression::AwaitExpression(node)))
3054 + }
3055 __ExpressionOrSuperTag::BinaryExpression => {
3056 let node: Box<BinaryExpression> = <Box<
3057 BinaryExpression,
@@ -2815,6 +3068,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSuper {
3068 )?;
3069 Ok(ExpressionOrSuper::Expression(Expression::CallExpression(node)))
3070 }
3071 + __ExpressionOrSuperTag::ChainExpression => {
3072 + let node: Box<ChainExpression> = <Box<
3073 + ChainExpression,
3074 + > as Deserialize>::deserialize(
3075 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3076 + )?;
3077 + Ok(ExpressionOrSuper::Expression(Expression::ChainExpression(node)))
3078 + }
3079 __ExpressionOrSuperTag::ClassExpression => {
3080 let node: Box<ClassExpression> = <Box<
3081 ClassExpression,
@@ -2851,6 +3112,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSuper {
3112 )?;
3113 Ok(ExpressionOrSuper::Expression(Expression::Identifier(node)))
3114 }
3115 + __ExpressionOrSuperTag::ImportExpression => {
3116 + let node: Box<ImportExpression> = <Box<
3117 + ImportExpression,
3118 + > as Deserialize>::deserialize(
3119 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3120 + )?;
3121 + Ok(ExpressionOrSuper::Expression(Expression::ImportExpression(node)))
3122 + }
3123 __ExpressionOrSuperTag::JSXElement => {
3124 let node: Box<JSXElement> = <Box<
3125 JSXElement,
@@ -2883,6 +3152,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSuper {
3152 )?;
3153 Ok(ExpressionOrSuper::Expression(Expression::MemberExpression(node)))
3154 }
3155 + __ExpressionOrSuperTag::MetaProperty => {
3156 + let node: Box<MetaProperty> = <Box<
3157 + MetaProperty,
3158 + > as Deserialize>::deserialize(
3159 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3160 + )?;
3161 + Ok(ExpressionOrSuper::Expression(Expression::MetaProperty(node)))
3162 + }
3163 __ExpressionOrSuperTag::NewExpression => {
3164 let node: Box<NewExpression> = <Box<
3165 NewExpression,
@@ -2907,6 +3184,26 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSuper {
3184 )?;
3185 Ok(ExpressionOrSuper::Expression(Expression::SequenceExpression(node)))
3186 }
3187 + __ExpressionOrSuperTag::TaggedTemplateExpression => {
3188 + let node: Box<TaggedTemplateExpression> = <Box<
3189 + TaggedTemplateExpression,
3190 + > as Deserialize>::deserialize(
3191 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3192 + )?;
3193 + Ok(
3194 + ExpressionOrSuper::Expression(
3195 + Expression::TaggedTemplateExpression(node),
3196 + ),
3197 + )
3198 + }
3199 + __ExpressionOrSuperTag::TemplateLiteral => {
3200 + let node: Box<TemplateLiteral> = <Box<
3201 + TemplateLiteral,
3202 + > as Deserialize>::deserialize(
3203 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3204 + )?;
3205 + Ok(ExpressionOrSuper::Expression(Expression::TemplateLiteral(node)))
3206 + }
3207 __ExpressionOrSuperTag::ThisExpression => {
3208 let node: Box<ThisExpression> = <Box<
3209 ThisExpression,
@@ -2961,19 +3258,25 @@ enum __ExpressionOrSpreadTag {
3258 ArrayExpression,
3259 ArrowFunctionExpression,
3260 AssignmentExpression,
3261 + AwaitExpression,
3262 BinaryExpression,
3263 CallExpression,
3264 + ChainExpression,
3265 ClassExpression,
3266 ConditionalExpression,
3267 FunctionExpression,
3268 Identifier,
3269 + ImportExpression,
3270 JSXElement,
3271 Literal,
3272 LogicalExpression,
3273 MemberExpression,
3274 + MetaProperty,
3275 NewExpression,
3276 ObjectExpression,
3277 SequenceExpression,
3278 + TaggedTemplateExpression,
3279 + TemplateLiteral,
3280 ThisExpression,
3281 UnaryExpression,
3282 UpdateExpression,
@@ -3024,6 +3327,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSpread {
3327 ),
3328 )
3329 }
3330 + __ExpressionOrSpreadTag::AwaitExpression => {
3331 + let node: Box<AwaitExpression> = <Box<
3332 + AwaitExpression,
3333 + > as Deserialize>::deserialize(
3334 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3335 + )?;
3336 + Ok(ExpressionOrSpread::Expression(Expression::AwaitExpression(node)))
3337 + }
3338 __ExpressionOrSpreadTag::BinaryExpression => {
3339 let node: Box<BinaryExpression> = <Box<
3340 BinaryExpression,
@@ -3040,6 +3351,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSpread {
3351 )?;
3352 Ok(ExpressionOrSpread::Expression(Expression::CallExpression(node)))
3353 }
3354 + __ExpressionOrSpreadTag::ChainExpression => {
3355 + let node: Box<ChainExpression> = <Box<
3356 + ChainExpression,
3357 + > as Deserialize>::deserialize(
3358 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3359 + )?;
3360 + Ok(ExpressionOrSpread::Expression(Expression::ChainExpression(node)))
3361 + }
3362 __ExpressionOrSpreadTag::ClassExpression => {
3363 let node: Box<ClassExpression> = <Box<
3364 ClassExpression,
@@ -3076,6 +3395,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSpread {
3395 )?;
3396 Ok(ExpressionOrSpread::Expression(Expression::Identifier(node)))
3397 }
3398 + __ExpressionOrSpreadTag::ImportExpression => {
3399 + let node: Box<ImportExpression> = <Box<
3400 + ImportExpression,
3401 + > as Deserialize>::deserialize(
3402 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3403 + )?;
3404 + Ok(ExpressionOrSpread::Expression(Expression::ImportExpression(node)))
3405 + }
3406 __ExpressionOrSpreadTag::JSXElement => {
3407 let node: Box<JSXElement> = <Box<
3408 JSXElement,
@@ -3108,6 +3435,14 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSpread {
3435 )?;
3436 Ok(ExpressionOrSpread::Expression(Expression::MemberExpression(node)))
3437 }
3438 + __ExpressionOrSpreadTag::MetaProperty => {
3439 + let node: Box<MetaProperty> = <Box<
3440 + MetaProperty,
3441 + > as Deserialize>::deserialize(
3442 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3443 + )?;
3444 + Ok(ExpressionOrSpread::Expression(Expression::MetaProperty(node)))
3445 + }
3446 __ExpressionOrSpreadTag::NewExpression => {
3447 let node: Box<NewExpression> = <Box<
3448 NewExpression,
@@ -3132,6 +3467,26 @@ impl<'de> serde::Deserialize<'de> for ExpressionOrSpread {
3467 )?;
3468 Ok(ExpressionOrSpread::Expression(Expression::SequenceExpression(node)))
3469 }
3470 + __ExpressionOrSpreadTag::TaggedTemplateExpression => {
3471 + let node: Box<TaggedTemplateExpression> = <Box<
3472 + TaggedTemplateExpression,
3473 + > as Deserialize>::deserialize(
3474 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3475 + )?;
3476 + Ok(
3477 + ExpressionOrSpread::Expression(
3478 + Expression::TaggedTemplateExpression(node),
3479 + ),
3480 + )
3481 + }
3482 + __ExpressionOrSpreadTag::TemplateLiteral => {
3483 + let node: Box<TemplateLiteral> = <Box<
3484 + TemplateLiteral,
3485 + > as Deserialize>::deserialize(
3486 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3487 + )?;
3488 + Ok(ExpressionOrSpread::Expression(Expression::TemplateLiteral(node)))
3489 + }
3490 __ExpressionOrSpreadTag::ThisExpression => {
3491 let node: Box<ThisExpression> = <Box<
3492 ThisExpression,
@@ -3187,19 +3542,25 @@ enum __FunctionBodyTag {
3542 ArrayExpression,
3543 ArrowFunctionExpression,
3544 AssignmentExpression,
3545 + AwaitExpression,
3546 BinaryExpression,
3547 CallExpression,
3548 + ChainExpression,
3549 ClassExpression,
3550 ConditionalExpression,
3551 FunctionExpression,
3552 Identifier,
3553 + ImportExpression,
3554 JSXElement,
3555 Literal,
3556 LogicalExpression,
3557 MemberExpression,
3558 + MetaProperty,
3559 NewExpression,
3560 ObjectExpression,
3561 SequenceExpression,
3562 + TaggedTemplateExpression,
3563 + TemplateLiteral,
3564 ThisExpression,
3565 UnaryExpression,
3566 UpdateExpression,
@@ -3249,6 +3610,14 @@ impl<'de> serde::Deserialize<'de> for FunctionBody {
3610 )?;
3611 Ok(FunctionBody::Expression(Expression::AssignmentExpression(node)))
3612 }
3613 + __FunctionBodyTag::AwaitExpression => {
3614 + let node: Box<AwaitExpression> = <Box<
3615 + AwaitExpression,
3616 + > as Deserialize>::deserialize(
3617 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3618 + )?;
3619 + Ok(FunctionBody::Expression(Expression::AwaitExpression(node)))
3620 + }
3621 __FunctionBodyTag::BinaryExpression => {
3622 let node: Box<BinaryExpression> = <Box<
3623 BinaryExpression,
@@ -3265,6 +3634,14 @@ impl<'de> serde::Deserialize<'de> for FunctionBody {
3634 )?;
3635 Ok(FunctionBody::Expression(Expression::CallExpression(node)))
3636 }
3637 + __FunctionBodyTag::ChainExpression => {
3638 + let node: Box<ChainExpression> = <Box<
3639 + ChainExpression,
3640 + > as Deserialize>::deserialize(
3641 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3642 + )?;
3643 + Ok(FunctionBody::Expression(Expression::ChainExpression(node)))
3644 + }
3645 __FunctionBodyTag::ClassExpression => {
3646 let node: Box<ClassExpression> = <Box<
3647 ClassExpression,
@@ -3297,6 +3674,14 @@ impl<'de> serde::Deserialize<'de> for FunctionBody {
3674 )?;
3675 Ok(FunctionBody::Expression(Expression::Identifier(node)))
3676 }
3677 + __FunctionBodyTag::ImportExpression => {
3678 + let node: Box<ImportExpression> = <Box<
3679 + ImportExpression,
3680 + > as Deserialize>::deserialize(
3681 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3682 + )?;
3683 + Ok(FunctionBody::Expression(Expression::ImportExpression(node)))
3684 + }
3685 __FunctionBodyTag::JSXElement => {
3686 let node: Box<JSXElement> = <Box<
3687 JSXElement,
@@ -3329,6 +3714,14 @@ impl<'de> serde::Deserialize<'de> for FunctionBody {
3714 )?;
3715 Ok(FunctionBody::Expression(Expression::MemberExpression(node)))
3716 }
3717 + __FunctionBodyTag::MetaProperty => {
3718 + let node: Box<MetaProperty> = <Box<
3719 + MetaProperty,
3720 + > as Deserialize>::deserialize(
3721 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3722 + )?;
3723 + Ok(FunctionBody::Expression(Expression::MetaProperty(node)))
3724 + }
3725 __FunctionBodyTag::NewExpression => {
3726 let node: Box<NewExpression> = <Box<
3727 NewExpression,
@@ -3353,6 +3746,22 @@ impl<'de> serde::Deserialize<'de> for FunctionBody {
3746 )?;
3747 Ok(FunctionBody::Expression(Expression::SequenceExpression(node)))
3748 }
3749 + __FunctionBodyTag::TaggedTemplateExpression => {
3750 + let node: Box<TaggedTemplateExpression> = <Box<
3751 + TaggedTemplateExpression,
3752 + > as Deserialize>::deserialize(
3753 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3754 + )?;
3755 + Ok(FunctionBody::Expression(Expression::TaggedTemplateExpression(node)))
3756 + }
3757 + __FunctionBodyTag::TemplateLiteral => {
3758 + let node: Box<TemplateLiteral> = <Box<
3759 + TemplateLiteral,
3760 + > as Deserialize>::deserialize(
3761 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3762 + )?;
3763 + Ok(FunctionBody::Expression(Expression::TemplateLiteral(node)))
3764 + }
3765 __FunctionBodyTag::ThisExpression => {
3766 let node: Box<ThisExpression> = <Box<
3767 ThisExpression,
@@ -3471,19 +3880,25 @@ enum __ForInitTag {
3880 ArrayExpression,
3881 ArrowFunctionExpression,
3882 AssignmentExpression,
3883 + AwaitExpression,
3884 BinaryExpression,
3885 CallExpression,
3886 + ChainExpression,
3887 ClassExpression,
3888 ConditionalExpression,
3889 FunctionExpression,
3890 Identifier,
3891 + ImportExpression,
3892 JSXElement,
3893 Literal,
3894 LogicalExpression,
3895 MemberExpression,
3896 + MetaProperty,
3897 NewExpression,
3898 ObjectExpression,
3899 SequenceExpression,
3900 + TaggedTemplateExpression,
3901 + TemplateLiteral,
3902 ThisExpression,
3903 UnaryExpression,
3904 UpdateExpression,
@@ -3526,6 +3941,14 @@ impl<'de> serde::Deserialize<'de> for ForInit {
3941 )?;
3942 Ok(ForInit::Expression(Expression::AssignmentExpression(node)))
3943 }
3944 + __ForInitTag::AwaitExpression => {
3945 + let node: Box<AwaitExpression> = <Box<
3946 + AwaitExpression,
3947 + > as Deserialize>::deserialize(
3948 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3949 + )?;
3950 + Ok(ForInit::Expression(Expression::AwaitExpression(node)))
3951 + }
3952 __ForInitTag::BinaryExpression => {
3953 let node: Box<BinaryExpression> = <Box<
3954 BinaryExpression,
@@ -3542,6 +3965,14 @@ impl<'de> serde::Deserialize<'de> for ForInit {
3965 )?;
3966 Ok(ForInit::Expression(Expression::CallExpression(node)))
3967 }
3968 + __ForInitTag::ChainExpression => {
3969 + let node: Box<ChainExpression> = <Box<
3970 + ChainExpression,
3971 + > as Deserialize>::deserialize(
3972 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
3973 + )?;
3974 + Ok(ForInit::Expression(Expression::ChainExpression(node)))
3975 + }
3976 __ForInitTag::ClassExpression => {
3977 let node: Box<ClassExpression> = <Box<
3978 ClassExpression,
@@ -3574,6 +4005,14 @@ impl<'de> serde::Deserialize<'de> for ForInit {
4005 )?;
4006 Ok(ForInit::Expression(Expression::Identifier(node)))
4007 }
4008 + __ForInitTag::ImportExpression => {
4009 + let node: Box<ImportExpression> = <Box<
4010 + ImportExpression,
4011 + > as Deserialize>::deserialize(
4012 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4013 + )?;
4014 + Ok(ForInit::Expression(Expression::ImportExpression(node)))
4015 + }
4016 __ForInitTag::JSXElement => {
4017 let node: Box<JSXElement> = <Box<
4018 JSXElement,
@@ -3606,6 +4045,14 @@ impl<'de> serde::Deserialize<'de> for ForInit {
4045 )?;
4046 Ok(ForInit::Expression(Expression::MemberExpression(node)))
4047 }
4048 + __ForInitTag::MetaProperty => {
4049 + let node: Box<MetaProperty> = <Box<
4050 + MetaProperty,
4051 + > as Deserialize>::deserialize(
4052 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4053 + )?;
4054 + Ok(ForInit::Expression(Expression::MetaProperty(node)))
4055 + }
4056 __ForInitTag::NewExpression => {
4057 let node: Box<NewExpression> = <Box<
4058 NewExpression,
@@ -3630,6 +4077,22 @@ impl<'de> serde::Deserialize<'de> for ForInit {
4077 )?;
4078 Ok(ForInit::Expression(Expression::SequenceExpression(node)))
4079 }
4080 + __ForInitTag::TaggedTemplateExpression => {
4081 + let node: Box<TaggedTemplateExpression> = <Box<
4082 + TaggedTemplateExpression,
4083 + > as Deserialize>::deserialize(
4084 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4085 + )?;
4086 + Ok(ForInit::Expression(Expression::TaggedTemplateExpression(node)))
4087 + }
4088 + __ForInitTag::TemplateLiteral => {
4089 + let node: Box<TemplateLiteral> = <Box<
4090 + TemplateLiteral,
4091 + > as Deserialize>::deserialize(
4092 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4093 + )?;
4094 + Ok(ForInit::Expression(Expression::TemplateLiteral(node)))
4095 + }
4096 __ForInitTag::ThisExpression => {
4097 let node: Box<ThisExpression> = <Box<
4098 ThisExpression,
@@ -3753,6 +4216,90 @@ impl<'de> serde::Deserialize<'de> for ForInInit {
4216 }
4217 #[derive(Serialize, Clone, Debug)]
4218 #[serde(untagged)]
4219 +pub enum PropertyOrSpreadElement {
4220 + Property(Box<Property>),
4221 + SpreadElement(Box<SpreadElement>),
4222 +}
4223 +#[derive(Deserialize, Debug)]
4224 +enum __PropertyOrSpreadElementTag {
4225 + Property,
4226 + SpreadElement,
4227 +}
4228 +impl<'de> serde::Deserialize<'de> for PropertyOrSpreadElement {
4229 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4230 + where
4231 + D: serde::Deserializer<'de>,
4232 + {
4233 + let tagged = serde::Deserializer::deserialize_any(
4234 + deserializer,
4235 + serde::__private::de::TaggedContentVisitor::<
4236 + __PropertyOrSpreadElementTag,
4237 + >::new("type", "PropertyOrSpreadElement"),
4238 + )?;
4239 + match tagged.0 {
4240 + __PropertyOrSpreadElementTag::Property => {
4241 + let node: Box<Property> = <Box<
4242 + Property,
4243 + > as Deserialize>::deserialize(
4244 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4245 + )?;
4246 + Ok(PropertyOrSpreadElement::Property(node))
4247 + }
4248 + __PropertyOrSpreadElementTag::SpreadElement => {
4249 + let node: Box<SpreadElement> = <Box<
4250 + SpreadElement,
4251 + > as Deserialize>::deserialize(
4252 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4253 + )?;
4254 + Ok(PropertyOrSpreadElement::SpreadElement(node))
4255 + }
4256 + }
4257 + }
4258 +}
4259 +#[derive(Serialize, Clone, Debug)]
4260 +#[serde(untagged)]
4261 +pub enum AssignmentPropertyOrRestElement {
4262 + AssignmentProperty(Box<AssignmentProperty>),
4263 + RestElement(Box<RestElement>),
4264 +}
4265 +#[derive(Deserialize, Debug)]
4266 +enum __AssignmentPropertyOrRestElementTag {
4267 + AssignmentProperty,
4268 + RestElement,
4269 +}
4270 +impl<'de> serde::Deserialize<'de> for AssignmentPropertyOrRestElement {
4271 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4272 + where
4273 + D: serde::Deserializer<'de>,
4274 + {
4275 + let tagged = serde::Deserializer::deserialize_any(
4276 + deserializer,
4277 + serde::__private::de::TaggedContentVisitor::<
4278 + __AssignmentPropertyOrRestElementTag,
4279 + >::new("type", "AssignmentPropertyOrRestElement"),
4280 + )?;
4281 + match tagged.0 {
4282 + __AssignmentPropertyOrRestElementTag::AssignmentProperty => {
4283 + let node: Box<AssignmentProperty> = <Box<
4284 + AssignmentProperty,
4285 + > as Deserialize>::deserialize(
4286 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4287 + )?;
4288 + Ok(AssignmentPropertyOrRestElement::AssignmentProperty(node))
4289 + }
4290 + __AssignmentPropertyOrRestElementTag::RestElement => {
4291 + let node: Box<RestElement> = <Box<
4292 + RestElement,
4293 + > as Deserialize>::deserialize(
4294 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4295 + )?;
4296 + Ok(AssignmentPropertyOrRestElement::RestElement(node))
4297 + }
4298 + }
4299 + }
4300 +}
4301 +#[derive(Serialize, Clone, Debug)]
4302 +#[serde(untagged)]
4303 pub enum PropertyKey {
4304 Identifier(Box<Identifier>),
4305 Literal(Box<Literal>),
@@ -3804,19 +4351,25 @@ enum __AssignmentTargetTag {
4351 ArrayExpression,
4352 ArrowFunctionExpression,
4353 AssignmentExpression,
4354 + AwaitExpression,
4355 BinaryExpression,
4356 CallExpression,
4357 + ChainExpression,
4358 ClassExpression,
4359 ConditionalExpression,
4360 FunctionExpression,
4361 Identifier,
4362 + ImportExpression,
4363 JSXElement,
4364 Literal,
4365 LogicalExpression,
4366 MemberExpression,
4367 + MetaProperty,
4368 NewExpression,
4369 ObjectExpression,
4370 SequenceExpression,
4371 + TaggedTemplateExpression,
4372 + TemplateLiteral,
4373 ThisExpression,
4374 UnaryExpression,
4375 UpdateExpression,
@@ -3866,6 +4419,14 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4419 )?;
4420 Ok(AssignmentTarget::Expression(Expression::AssignmentExpression(node)))
4421 }
4422 + __AssignmentTargetTag::AwaitExpression => {
4423 + let node: Box<AwaitExpression> = <Box<
4424 + AwaitExpression,
4425 + > as Deserialize>::deserialize(
4426 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4427 + )?;
4428 + Ok(AssignmentTarget::Expression(Expression::AwaitExpression(node)))
4429 + }
4430 __AssignmentTargetTag::BinaryExpression => {
4431 let node: Box<BinaryExpression> = <Box<
4432 BinaryExpression,
@@ -3882,6 +4443,14 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4443 )?;
4444 Ok(AssignmentTarget::Expression(Expression::CallExpression(node)))
4445 }
4446 + __AssignmentTargetTag::ChainExpression => {
4447 + let node: Box<ChainExpression> = <Box<
4448 + ChainExpression,
4449 + > as Deserialize>::deserialize(
4450 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4451 + )?;
4452 + Ok(AssignmentTarget::Expression(Expression::ChainExpression(node)))
4453 + }
4454 __AssignmentTargetTag::ClassExpression => {
4455 let node: Box<ClassExpression> = <Box<
4456 ClassExpression,
@@ -3914,6 +4483,14 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4483 )?;
4484 Ok(AssignmentTarget::Expression(Expression::Identifier(node)))
4485 }
4486 + __AssignmentTargetTag::ImportExpression => {
4487 + let node: Box<ImportExpression> = <Box<
4488 + ImportExpression,
4489 + > as Deserialize>::deserialize(
4490 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4491 + )?;
4492 + Ok(AssignmentTarget::Expression(Expression::ImportExpression(node)))
4493 + }
4494 __AssignmentTargetTag::JSXElement => {
4495 let node: Box<JSXElement> = <Box<
4496 JSXElement,
@@ -3946,6 +4523,14 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4523 )?;
4524 Ok(AssignmentTarget::Expression(Expression::MemberExpression(node)))
4525 }
4526 + __AssignmentTargetTag::MetaProperty => {
4527 + let node: Box<MetaProperty> = <Box<
4528 + MetaProperty,
4529 + > as Deserialize>::deserialize(
4530 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4531 + )?;
4532 + Ok(AssignmentTarget::Expression(Expression::MetaProperty(node)))
4533 + }
4534 __AssignmentTargetTag::NewExpression => {
4535 let node: Box<NewExpression> = <Box<
4536 NewExpression,
@@ -3970,6 +4555,26 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4555 )?;
4556 Ok(AssignmentTarget::Expression(Expression::SequenceExpression(node)))
4557 }
4558 + __AssignmentTargetTag::TaggedTemplateExpression => {
4559 + let node: Box<TaggedTemplateExpression> = <Box<
4560 + TaggedTemplateExpression,
4561 + > as Deserialize>::deserialize(
4562 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4563 + )?;
4564 + Ok(
4565 + AssignmentTarget::Expression(
4566 + Expression::TaggedTemplateExpression(node),
4567 + ),
4568 + )
4569 + }
4570 + __AssignmentTargetTag::TemplateLiteral => {
4571 + let node: Box<TemplateLiteral> = <Box<
4572 + TemplateLiteral,
4573 + > as Deserialize>::deserialize(
4574 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4575 + )?;
4576 + Ok(AssignmentTarget::Expression(Expression::TemplateLiteral(node)))
4577 + }
4578 __AssignmentTargetTag::ThisExpression => {
4579 let node: Box<ThisExpression> = <Box<
4580 ThisExpression,
@@ -4039,6 +4644,48 @@ impl<'de> serde::Deserialize<'de> for AssignmentTarget {
4644 }
4645 #[derive(Serialize, Clone, Debug)]
4646 #[serde(untagged)]
4647 +pub enum ChainElement {
4648 + CallExpression(Box<CallExpression>),
4649 + MemberExpression(Box<MemberExpression>),
4650 +}
4651 +#[derive(Deserialize, Debug)]
4652 +enum __ChainElementTag {
4653 + CallExpression,
4654 + MemberExpression,
4655 +}
4656 +impl<'de> serde::Deserialize<'de> for ChainElement {
4657 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
4658 + where
4659 + D: serde::Deserializer<'de>,
4660 + {
4661 + let tagged = serde::Deserializer::deserialize_any(
4662 + deserializer,
4663 + serde::__private::de::TaggedContentVisitor::<
4664 + __ChainElementTag,
4665 + >::new("type", "ChainElement"),
4666 + )?;
4667 + match tagged.0 {
4668 + __ChainElementTag::CallExpression => {
4669 + let node: Box<CallExpression> = <Box<
4670 + CallExpression,
4671 + > as Deserialize>::deserialize(
4672 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4673 + )?;
4674 + Ok(ChainElement::CallExpression(node))
4675 + }
4676 + __ChainElementTag::MemberExpression => {
4677 + let node: Box<MemberExpression> = <Box<
4678 + MemberExpression,
4679 + > as Deserialize>::deserialize(
4680 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4681 + )?;
4682 + Ok(ChainElement::MemberExpression(node))
4683 + }
4684 + }
4685 + }
4686 +}
4687 +#[derive(Serialize, Clone, Debug)]
4688 +#[serde(untagged)]
4689 pub enum JSXMemberExpressionOrIdentifier {
4690 JSXIdentifier(Box<JSXIdentifier>),
4691 JSXMemberExpression(Box<JSXMemberExpression>),
@@ -4090,19 +4737,25 @@ enum __JSXExpressionOrEmptyTag {
4737 ArrayExpression,
4738 ArrowFunctionExpression,
4739 AssignmentExpression,
4740 + AwaitExpression,
4741 BinaryExpression,
4742 CallExpression,
4743 + ChainExpression,
4744 ClassExpression,
4745 ConditionalExpression,
4746 FunctionExpression,
4747 Identifier,
4748 + ImportExpression,
4749 JSXElement,
4750 Literal,
4751 LogicalExpression,
4752 MemberExpression,
4753 + MetaProperty,
4754 NewExpression,
4755 ObjectExpression,
4756 SequenceExpression,
4757 + TaggedTemplateExpression,
4758 + TemplateLiteral,
4759 ThisExpression,
4760 UnaryExpression,
4761 UpdateExpression,
@@ -4153,6 +4806,14 @@ impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty {
4806 ),
4807 )
4808 }
4809 + __JSXExpressionOrEmptyTag::AwaitExpression => {
4810 + let node: Box<AwaitExpression> = <Box<
4811 + AwaitExpression,
4812 + > as Deserialize>::deserialize(
4813 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4814 + )?;
4815 + Ok(JSXExpressionOrEmpty::Expression(Expression::AwaitExpression(node)))
4816 + }
4817 __JSXExpressionOrEmptyTag::BinaryExpression => {
4818 let node: Box<BinaryExpression> = <Box<
4819 BinaryExpression,
@@ -4169,6 +4830,14 @@ impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty {
4830 )?;
4831 Ok(JSXExpressionOrEmpty::Expression(Expression::CallExpression(node)))
4832 }
4833 + __JSXExpressionOrEmptyTag::ChainExpression => {
4834 + let node: Box<ChainExpression> = <Box<
4835 + ChainExpression,
4836 + > as Deserialize>::deserialize(
4837 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4838 + )?;
4839 + Ok(JSXExpressionOrEmpty::Expression(Expression::ChainExpression(node)))
4840 + }
4841 __JSXExpressionOrEmptyTag::ClassExpression => {
4842 let node: Box<ClassExpression> = <Box<
4843 ClassExpression,
@@ -4209,6 +4878,14 @@ impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty {
4878 )?;
4879 Ok(JSXExpressionOrEmpty::Expression(Expression::Identifier(node)))
4880 }
4881 + __JSXExpressionOrEmptyTag::ImportExpression => {
4882 + let node: Box<ImportExpression> = <Box<
4883 + ImportExpression,
4884 + > as Deserialize>::deserialize(
4885 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4886 + )?;
4887 + Ok(JSXExpressionOrEmpty::Expression(Expression::ImportExpression(node)))
4888 + }
4889 __JSXExpressionOrEmptyTag::JSXElement => {
4890 let node: Box<JSXElement> = <Box<
4891 JSXElement,
@@ -4241,6 +4918,14 @@ impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty {
4918 )?;
4919 Ok(JSXExpressionOrEmpty::Expression(Expression::MemberExpression(node)))
4920 }
4921 + __JSXExpressionOrEmptyTag::MetaProperty => {
4922 + let node: Box<MetaProperty> = <Box<
4923 + MetaProperty,
4924 + > as Deserialize>::deserialize(
4925 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4926 + )?;
4927 + Ok(JSXExpressionOrEmpty::Expression(Expression::MetaProperty(node)))
4928 + }
4929 __JSXExpressionOrEmptyTag::NewExpression => {
4930 let node: Box<NewExpression> = <Box<
4931 NewExpression,
@@ -4269,6 +4954,26 @@ impl<'de> serde::Deserialize<'de> for JSXExpressionOrEmpty {
4954 ),
4955 )
4956 }
4957 + __JSXExpressionOrEmptyTag::TaggedTemplateExpression => {
4958 + let node: Box<TaggedTemplateExpression> = <Box<
4959 + TaggedTemplateExpression,
4960 + > as Deserialize>::deserialize(
4961 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4962 + )?;
4963 + Ok(
4964 + JSXExpressionOrEmpty::Expression(
4965 + Expression::TaggedTemplateExpression(node),
4966 + ),
4967 + )
4968 + }
4969 + __JSXExpressionOrEmptyTag::TemplateLiteral => {
4970 + let node: Box<TemplateLiteral> = <Box<
4971 + TemplateLiteral,
4972 + > as Deserialize>::deserialize(
4973 + serde::__private::de::ContentDeserializer::<D::Error>::new(tagged.1),
4974 + )?;
4975 + Ok(JSXExpressionOrEmpty::Expression(Expression::TemplateLiteral(node)))
4976 + }
4977 __JSXExpressionOrEmptyTag::ThisExpression => {
4978 let node: Box<ThisExpression> = <Box<
4979 ThisExpression,
@@ -4804,6 +5509,9 @@ pub enum BinaryOperator {
5509 /// ==
5510 #[serde(rename = "==")]
5511 Equals,
5512 + /// **
5513 + #[serde(rename = "**")]
5514 + Exponent,
5515 /// >
5516 #[serde(rename = ">")]
5517 GreaterThan,
@@ -4859,6 +5567,7 @@ impl std::fmt::Display for BinaryOperator {
5567 Self::BinaryXor => "^",
5568 Self::Divide => "/",
5569 Self::Equals => "==",
5570 + Self::Exponent => "**",
5571 Self::GreaterThan => ">",
5572 Self::GreaterThanOrEqual => ">=",
5573 Self::In => "in",
@@ -4888,6 +5597,7 @@ impl std::str::FromStr for BinaryOperator {
5597 "^" => Ok(Self::BinaryXor),
5598 "/" => Ok(Self::Divide),
5599 "==" => Ok(Self::Equals),
5600 + "**" => Ok(Self::Exponent),
5601 ">" => Ok(Self::GreaterThan),
5602 ">=" => Ok(Self::GreaterThanOrEqual),
5603 "in" => Ok(Self::In),
@@ -4920,6 +5630,9 @@ impl std::str::FromStr for BinaryOperator {
5630 Debug
5631 )]
5632 pub enum AssignmentOperator {
5633 + /// &&=
5634 + #[serde(rename = "&&=")]
5635 + AndEquals,
5636 /// &=
5637 #[serde(rename = "&=")]
5638 BinaryAndEquals,
@@ -4935,6 +5648,9 @@ pub enum AssignmentOperator {
5648 /// =
5649 #[serde(rename = "=")]
5650 Equals,
5651 + /// **=
5652 + #[serde(rename = "**=")]
5653 + Exponent,
5654 /// -=
5655 #[serde(rename = "-=")]
5656 MinusEquals,
@@ -4944,6 +5660,12 @@ pub enum AssignmentOperator {
5660 /// *=
5661 #[serde(rename = "*=")]
5662 MultiplyEquals,
5663 + /// ??=
5664 + #[serde(rename = "??=")]
5665 + NullCoalescingEquals,
5666 + /// ||=
5667 + #[serde(rename = "||=")]
5668 + OrEquals,
5669 /// +=
5670 #[serde(rename = "+=")]
5671 PlusEquals,
@@ -4960,14 +5682,18 @@ pub enum AssignmentOperator {
5682 impl std::fmt::Display for AssignmentOperator {
5683 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5684 let name = match self {
5685 + Self::AndEquals => "&&=",
5686 Self::BinaryAndEquals => "&=",
5687 Self::BinaryOrEquals => "|=",
5688 Self::BinaryXorEquals => "^=",
5689 Self::DivideEquals => "/=",
5690 Self::Equals => "=",
5691 + Self::Exponent => "**=",
5692 Self::MinusEquals => "-=",
5693 Self::ModuloEquals => "%=",
5694 Self::MultiplyEquals => "*=",
5695 + Self::NullCoalescingEquals => "??=",
5696 + Self::OrEquals => "||=",
5697 Self::PlusEquals => "+=",
5698 Self::ShiftLeftEquals => "<<=",
5699 Self::ShiftRightEquals => ">>=",
@@ -4980,14 +5706,18 @@ impl std::str::FromStr for AssignmentOperator {
5706 type Err = ();
5707 fn from_str(s: &str) -> Result<Self, Self::Err> {
5708 match s {
5709 + "&&=" => Ok(Self::AndEquals),
5710 "&=" => Ok(Self::BinaryAndEquals),
5711 "|=" => Ok(Self::BinaryOrEquals),
5712 "^=" => Ok(Self::BinaryXorEquals),
5713 "/=" => Ok(Self::DivideEquals),
5714 "=" => Ok(Self::Equals),
5715 + "**=" => Ok(Self::Exponent),
5716 "-=" => Ok(Self::MinusEquals),
5717 "%=" => Ok(Self::ModuloEquals),
5718 "*=" => Ok(Self::MultiplyEquals),
5719 + "??=" => Ok(Self::NullCoalescingEquals),
5720 + "||=" => Ok(Self::OrEquals),
5721 "+=" => Ok(Self::PlusEquals),
5722 "<<=" => Ok(Self::ShiftLeftEquals),
5723 ">>=" => Ok(Self::ShiftRightEquals),
compiler/forget/crates/forget_estree/src/snapshots/forget_estree__tests__fixtures@for-statement.json.snap
+3
@@ -614,6 +614,7 @@ Output:
614 },
615 "raw": "0",
616 "regex": null,
617 + "bigint": null,
618 "loc": {
619 "source": null,
620 "start": {
@@ -697,6 +698,7 @@ Output:
698 },
699 "raw": "0",
700 "regex": null,
701 + "bigint": null,
702 "loc": {
703 "source": null,
704 "start": {
@@ -775,6 +777,7 @@ Output:
777 },
778 "raw": "10",
779 "regex": null,
780 + "bigint": null,
781 "loc": {
782 "source": null,
783 "start": {
compiler/forget/crates/forget_estree/src/snapshots/forget_estree__tests__fixtures@import.json.snap
+1
@@ -161,6 +161,7 @@ Output:
161 },
162 "raw": "'react'",
163 "regex": null,
164 + "bigint": null,
165 "loc": {
166 "source": null,
167 "start": {
compiler/forget/crates/forget_estree/src/snapshots/forget_estree__tests__fixtures@simple.json.snap
+1
@@ -286,6 +286,7 @@ Output:
286 }
287 },
288 "computed": false,
289 + "optional": false,
290 "loc": {
291 "source": null,
292 "start": {
compiler/forget/crates/forget_estree/src/snapshots/forget_estree__tests__fixtures@test.json.snap
+1
@@ -478,6 +478,7 @@ Output:
478 },
479 "raw": "10",
480 "regex": null,
481 + "bigint": null,
482 "loc": {
483 "source": null,
484 "start": {
compiler/forget/crates/forget_estree/src/visit.rs
+17 -8
@@ -1,9 +1,9 @@
1 use crate::{
2 - AssignmentTarget, Class, Declaration, ExportAllDeclaration, ExportDefaultDeclaration,
3 - ExportNamedDeclaration, Expression, ExpressionOrSpread, ExpressionOrSuper, ForInInit, ForInit,
4 - Function, FunctionBody, Identifier, ImportDeclaration, ImportDeclarationSpecifier,
5 - ImportOrExportDeclaration, Literal, MethodDefinition, ModuleItem, Pattern, Program, Statement,
6 - SwitchCase, VariableDeclarator,
2 + AssignmentPropertyOrRestElement, AssignmentTarget, Class, Declaration, ExportAllDeclaration,
3 + ExportDefaultDeclaration, ExportNamedDeclaration, Expression, ExpressionOrSpread,
4 + ExpressionOrSuper, ForInInit, ForInit, Function, FunctionBody, Identifier, ImportDeclaration,
5 + ImportDeclarationSpecifier, ImportOrExportDeclaration, Literal, MethodDefinition, ModuleItem,
6 + Pattern, Program, Statement, SwitchCase, VariableDeclarator,
7 };
8
9 /// Trait for visiting an estree
@@ -219,7 +219,9 @@ pub trait Visitor<'ast> {
219 self.visit_statement(item);
220 }
221 if let Some(handler) = &stmt.handler {
222 - self.visit_lvalue(|visitor| visitor.visit_pattern(&handler.param));
222 + if let Some(param) = &handler.param {
223 + self.visit_lvalue(|visitor| visitor.visit_pattern(param));
224 + }
225 for item in &handler.body.body {
226 self.visit_statement(item);
227 }
@@ -318,7 +320,14 @@ pub trait Visitor<'ast> {
320 }
321 Pattern::ObjectPattern(pattern) => {
322 for property in &pattern.properties {
321 - self.visit_pattern(&property.value);
323 + match property {
324 + AssignmentPropertyOrRestElement::AssignmentProperty(property) => {
325 + self.visit_pattern(&property.value);
326 + }
327 + AssignmentPropertyOrRestElement::RestElement(property) => {
328 + self.visit_pattern(&property.argument);
329 + }
330 + }
331 }
332 }
333 Pattern::RestElement(pattern) => self.visit_pattern(&pattern.argument),
@@ -385,7 +394,7 @@ pub trait Visitor<'ast> {
394 }
395 ExpressionOrSuper::Expression(object) => self.visit_expression(object),
396 };
388 - if !expr.computed {
397 + if !expr.is_computed {
398 self.visit_expression(&expr.property)
399 }
400 }
compiler/forget/crates/forget_estree_codegen/src/ecmascript.json
+124 -6
@@ -63,6 +63,16 @@
63 "type": "String"
64 }
65 }
66 + },
67 + "TemplateElementValue": {
68 + "fields": {
69 + "cooked": {
70 + "type": "Option<String>"
71 + },
72 + "raw": {
73 + "type": "String"
74 + }
75 + }
76 }
77 },
78 "nodes": {
@@ -90,6 +100,10 @@
100 "regex": {
101 "type": "Option<RegExpValue>",
102 "optional": true
103 + },
104 + "bigint": {
105 + "type": "Option<String>",
106 + "optional": true
107 }
108 }
109 },
@@ -222,7 +236,7 @@
236 "CatchClause": {
237 "fields": {
238 "param": {
225 - "type": "Pattern"
239 + "type": "Option<Pattern>"
240 },
241 "body": {
242 "type": "BlockStatement"
@@ -280,6 +294,11 @@
294 },
295 "ForOfStatement": {
296 "fields": {
297 + "is_await": {
298 + "type": "bool",
299 + "optional": true,
300 + "rename": "await"
301 + },
302 "left": {
303 "type": "ForInInit"
304 },
@@ -388,7 +407,7 @@
407 "ObjectExpression": {
408 "fields": {
409 "properties": {
391 - "type": "Vec<Property>"
410 + "type": "Vec<PropertyOrSpreadElement>"
411 }
412 }
413 },
@@ -510,8 +529,14 @@
529 "property": {
530 "type": "Expression"
531 },
513 - "computed": {
514 - "type": "bool"
532 + "is_computed": {
533 + "type": "bool",
534 + "rename": "computed"
535 + },
536 + "is_optional": {
537 + "type": "bool",
538 + "optional": true,
539 + "rename": "optional"
540 }
541 }
542 },
@@ -535,6 +560,11 @@
560 },
561 "arguments": {
562 "type": "Vec<ExpressionOrSpread>"
563 + },
564 + "is_optional": {
565 + "type": "bool",
566 + "optional": true,
567 + "rename": "optional"
568 }
569 }
570 },
@@ -640,6 +670,10 @@
670 "fields": {
671 "source": {
672 "type": "Literal"
673 + },
674 + "exported": {
675 + "type": "Option<Identifier>",
676 + "optional": true
677 }
678 }
679 },
@@ -775,7 +809,7 @@
809 "ObjectPattern": {
810 "fields": {
811 "properties": {
778 - "type": "Vec<AssignmentProperty>"
812 + "type": "Vec<AssignmentPropertyOrRestElement>"
813 }
814 }
815 },
@@ -814,6 +848,67 @@
848 "type": "Expression"
849 }
850 }
851 + },
852 + "TemplateLiteral": {
853 + "fields": {
854 + "quasis": {
855 + "type": "Vec<TemplateElement>"
856 + },
857 + "expressions": {
858 + "type": "Vec<Expression>"
859 + }
860 + }
861 + },
862 + "TemplateElement": {
863 + "fields": {
864 + "tail": {
865 + "type": "bool"
866 + },
867 + "value": {
868 + "type": "TemplateElementValue"
869 + }
870 + }
871 + },
872 + "TaggedTemplateExpression": {
873 + "fields": {
874 + "tag": {
875 + "type": "Expression"
876 + },
877 + "quasi": {
878 + "type": "TemplateLiteral"
879 + }
880 + }
881 + },
882 + "MetaProperty": {
883 + "fields": {
884 + "meta": {
885 + "type": "Identifier"
886 + },
887 + "property": {
888 + "type": "Identifier"
889 + }
890 + }
891 + },
892 + "AwaitExpression": {
893 + "fields": {
894 + "argument": {
895 + "type": "Expression"
896 + }
897 + }
898 + },
899 + "ChainExpression": {
900 + "fields": {
901 + "expression": {
902 + "type": "ChainElement"
903 + }
904 + }
905 + },
906 + "ImportExpression": {
907 + "fields": {
908 + "source": {
909 + "type": "Expression"
910 + }
911 + }
912 }
913 },
914 "enums": {
@@ -844,19 +939,25 @@
939 "ArrayExpression",
940 "ArrowFunctionExpression",
941 "AssignmentExpression",
942 + "AwaitExpression",
943 "BinaryExpression",
944 "CallExpression",
945 + "ChainExpression",
946 "ClassExpression",
947 "ConditionalExpression",
948 "FunctionExpression",
949 "Identifier",
950 + "ImportExpression",
951 "JSXElement",
952 "Literal",
953 "LogicalExpression",
954 "MemberExpression",
955 + "MetaProperty",
956 "NewExpression",
957 "ObjectExpression",
958 "SequenceExpression",
959 + "TaggedTemplateExpression",
960 + "TemplateLiteral",
961 "ThisExpression",
962 "UnaryExpression",
963 "UpdateExpression",
@@ -909,6 +1010,14 @@
1010 "Pattern",
1011 "VariableDeclaration"
1012 ],
1013 + "PropertyOrSpreadElement": [
1014 + "Property",
1015 + "SpreadElement"
1016 + ],
1017 + "AssignmentPropertyOrRestElement": [
1018 + "AssignmentProperty",
1019 + "RestElement"
1020 + ],
1021 "PropertyKey": [
1022 "Identifier",
1023 "Literal"
@@ -917,6 +1026,10 @@
1026 "Expression",
1027 "Pattern"
1028 ],
1029 + "ChainElement": [
1030 + "CallExpression",
1031 + "MemberExpression"
1032 + ],
1033 "JSXMemberExpressionOrIdentifier": [
1034 "JSXMemberExpression",
1035 "JSXIdentifier"
@@ -983,6 +1096,7 @@
1096 "BinaryXor": "^",
1097 "Divide": "/",
1098 "Equals": "==",
1099 + "Exponent": "**",
1100 "GreaterThan": ">",
1101 "GreaterThanOrEqual": ">=",
1102 "In": "in",
@@ -1005,13 +1119,17 @@
1119 "BinaryXorEquals": "^=",
1120 "DivideEquals": "/=",
1121 "Equals": "=",
1122 + "Exponent": "**=",
1123 "MinusEquals": "-=",
1124 "ModuloEquals": "%=",
1125 "MultiplyEquals": "*=",
1126 "PlusEquals": "+=",
1127 "ShiftLeftEquals": "<<=",
1128 "ShiftRightEquals": ">>=",
1014 - "UnsignedShiftRightEquals": ">>>="
1129 + "UnsignedShiftRightEquals": ">>>=",
1130 + "AndEquals": "&&=",
1131 + "OrEquals": "||=",
1132 + "NullCoalescingEquals": "??="
1133 },
1134 "LogicalOperator": {
1135 "And": "&&",
compiler/forget/crates/forget_estree_swc/src/lib.rs
+4 -2
@@ -355,6 +355,7 @@ fn convert_expression(cx: &Context, expr: &Expr) -> forget_estree::Expression {
355 }
356 })
357 .collect(),
358 + is_optional: false,
359 loc: None,
360 range: convert_span(&expr.span),
361 }))
@@ -419,6 +420,7 @@ fn convert_expression(cx: &Context, expr: &Expr) -> forget_estree::Expression {
420 loc: None,
421 regex: None,
422 range,
423 + bigint: None,
424 }))
425 }
426 Expr::Assign(expr) => forget_estree::Expression::AssignmentExpression(Box::new(
@@ -511,8 +513,8 @@ fn convert_member_expression(cx: &Context, expr: &MemberExpr) -> forget_estree::
513 forget_estree::MemberExpression {
514 object: forget_estree::ExpressionOrSuper::Expression(convert_expression(cx, &expr.obj)),
515 property,
514 - computed: is_computed,
515 - // optional: false, // TODO
516 + is_computed,
517 + is_optional: false,
518 loc: None,
519 range: convert_span(&expr.span),
520 }