1 // WARNING: This file is auto-generated by crates/ast/generate_ast.py. 2 3 use crate::token::Token; 4 use ast::arena; 5 use ast::types::*; 6 use std::convert::Infallible; 7 8 pub type AstError = String; 9 type AstResult<'alloc, T> = Result<arena::Box<'alloc, T>, AstError>; 10 11 #[derive(Debug)] 12 pub enum StackValue<'alloc> { 13 Argument(arena::Box<'alloc, Argument<'alloc>>), 14 Arguments(arena::Box<'alloc, Arguments<'alloc>>), 15 ArrayAssignmentTarget(arena::Box<'alloc, ArrayAssignmentTarget<'alloc>>), 16 ArrayBinding(arena::Box<'alloc, ArrayBinding<'alloc>>), 17 ArrayExpression(arena::Box<'alloc, ArrayExpression<'alloc>>), 18 ArrayExpressionElement(arena::Box<'alloc, ArrayExpressionElement<'alloc>>), 19 ArrowExpressionBody(arena::Box<'alloc, ArrowExpressionBody<'alloc>>), 20 AssignmentTarget(arena::Box<'alloc, AssignmentTarget<'alloc>>), 21 AssignmentTargetIdentifier(arena::Box<'alloc, AssignmentTargetIdentifier>), 22 AssignmentTargetMaybeDefault(arena::Box<'alloc, AssignmentTargetMaybeDefault<'alloc>>), 23 AssignmentTargetPattern(arena::Box<'alloc, AssignmentTargetPattern<'alloc>>), 24 AssignmentTargetProperty(arena::Box<'alloc, AssignmentTargetProperty<'alloc>>), 25 AssignmentTargetPropertyIdentifier(arena::Box<'alloc, AssignmentTargetPropertyIdentifier<'alloc>>), 26 AssignmentTargetPropertyProperty(arena::Box<'alloc, AssignmentTargetPropertyProperty<'alloc>>), 27 AssignmentTargetWithDefault(arena::Box<'alloc, AssignmentTargetWithDefault<'alloc>>), 28 BinaryOperator(arena::Box<'alloc, BinaryOperator>), 29 Binding(arena::Box<'alloc, Binding<'alloc>>), 30 BindingIdentifier(arena::Box<'alloc, BindingIdentifier>), 31 BindingPattern(arena::Box<'alloc, BindingPattern<'alloc>>), 32 BindingProperty(arena::Box<'alloc, BindingProperty<'alloc>>), 33 BindingPropertyIdentifier(arena::Box<'alloc, BindingPropertyIdentifier<'alloc>>), 34 BindingPropertyProperty(arena::Box<'alloc, BindingPropertyProperty<'alloc>>), 35 BindingWithDefault(arena::Box<'alloc, BindingWithDefault<'alloc>>), 36 Block(arena::Box<'alloc, Block<'alloc>>), 37 CallExpression(arena::Box<'alloc, CallExpression<'alloc>>), 38 CatchClause(arena::Box<'alloc, CatchClause<'alloc>>), 39 ClassDeclaration(arena::Box<'alloc, ClassDeclaration<'alloc>>), 40 ClassElement(arena::Box<'alloc, ClassElement<'alloc>>), 41 ClassElementName(arena::Box<'alloc, ClassElementName<'alloc>>), 42 ClassExpression(arena::Box<'alloc, ClassExpression<'alloc>>), 43 CompoundAssignmentOperator(arena::Box<'alloc, CompoundAssignmentOperator>), 44 ComputedMemberAssignmentTarget(arena::Box<'alloc, ComputedMemberAssignmentTarget<'alloc>>), 45 ComputedMemberExpression(arena::Box<'alloc, ComputedMemberExpression<'alloc>>), 46 ComputedPropertyName(arena::Box<'alloc, ComputedPropertyName<'alloc>>), 47 CoverParenthesized(arena::Box<'alloc, CoverParenthesized<'alloc>>), 48 DataProperty(arena::Box<'alloc, DataProperty<'alloc>>), 49 Directive(arena::Box<'alloc, Directive>), 50 Export(arena::Box<'alloc, Export<'alloc>>), 51 ExportAllFrom(arena::Box<'alloc, ExportAllFrom>), 52 ExportDeclaration(arena::Box<'alloc, ExportDeclaration<'alloc>>), 53 ExportDefault(arena::Box<'alloc, ExportDefault<'alloc>>), 54 ExportFrom(arena::Box<'alloc, ExportFrom<'alloc>>), 55 ExportFromSpecifier(arena::Box<'alloc, ExportFromSpecifier>), 56 ExportLocalSpecifier(arena::Box<'alloc, ExportLocalSpecifier>), 57 ExportLocals(arena::Box<'alloc, ExportLocals<'alloc>>), 58 Expression(arena::Box<'alloc, Expression<'alloc>>), 59 ExpressionOrSuper(arena::Box<'alloc, ExpressionOrSuper<'alloc>>), 60 FormalParameters(arena::Box<'alloc, FormalParameters<'alloc>>), 61 Function(arena::Box<'alloc, Function<'alloc>>), 62 FunctionBody(arena::Box<'alloc, FunctionBody<'alloc>>), 63 Getter(arena::Box<'alloc, Getter<'alloc>>), 64 Identifier(arena::Box<'alloc, Identifier>), 65 IdentifierExpression(arena::Box<'alloc, IdentifierExpression>), 66 IdentifierName(arena::Box<'alloc, IdentifierName>), 67 IfStatement(arena::Box<'alloc, IfStatement<'alloc>>), 68 Import(arena::Box<'alloc, Import<'alloc>>), 69 ImportDeclaration(arena::Box<'alloc, ImportDeclaration<'alloc>>), 70 ImportNamespace(arena::Box<'alloc, ImportNamespace>), 71 ImportSpecifier(arena::Box<'alloc, ImportSpecifier>), 72 Label(arena::Box<'alloc, Label>), 73 MemberAssignmentTarget(arena::Box<'alloc, MemberAssignmentTarget<'alloc>>), 74 MemberExpression(arena::Box<'alloc, MemberExpression<'alloc>>), 75 Method(arena::Box<'alloc, Method<'alloc>>), 76 MethodDefinition(arena::Box<'alloc, MethodDefinition<'alloc>>), 77 Module(arena::Box<'alloc, Module<'alloc>>), 78 ModuleItems(arena::Box<'alloc, ModuleItems<'alloc>>), 79 NamedObjectProperty(arena::Box<'alloc, NamedObjectProperty<'alloc>>), 80 NumericLiteral(arena::Box<'alloc, NumericLiteral>), 81 ObjectAssignmentTarget(arena::Box<'alloc, ObjectAssignmentTarget<'alloc>>), 82 ObjectBinding(arena::Box<'alloc, ObjectBinding<'alloc>>), 83 ObjectExpression(arena::Box<'alloc, ObjectExpression<'alloc>>), 84 ObjectProperty(arena::Box<'alloc, ObjectProperty<'alloc>>), 85 OptionalChain(arena::Box<'alloc, OptionalChain<'alloc>>), 86 Parameter(arena::Box<'alloc, Parameter<'alloc>>), 87 PrivateFieldAssignmentTarget(arena::Box<'alloc, PrivateFieldAssignmentTarget<'alloc>>), 88 PrivateFieldExpression(arena::Box<'alloc, PrivateFieldExpression<'alloc>>), 89 PrivateIdentifier(arena::Box<'alloc, PrivateIdentifier>), 90 Program(arena::Box<'alloc, Program<'alloc>>), 91 PropertyName(arena::Box<'alloc, PropertyName<'alloc>>), 92 Script(arena::Box<'alloc, Script<'alloc>>), 93 Setter(arena::Box<'alloc, Setter<'alloc>>), 94 ShorthandProperty(arena::Box<'alloc, ShorthandProperty>), 95 SimpleAssignmentTarget(arena::Box<'alloc, SimpleAssignmentTarget<'alloc>>), 96 Statement(arena::Box<'alloc, Statement<'alloc>>), 97 StaticMemberAssignmentTarget(arena::Box<'alloc, StaticMemberAssignmentTarget<'alloc>>), 98 StaticMemberExpression(arena::Box<'alloc, StaticMemberExpression<'alloc>>), 99 StaticPropertyName(arena::Box<'alloc, StaticPropertyName>), 100 SwitchCase(arena::Box<'alloc, SwitchCase<'alloc>>), 101 SwitchDefault(arena::Box<'alloc, SwitchDefault<'alloc>>), 102 TemplateElement(arena::Box<'alloc, TemplateElement>), 103 TemplateExpression(arena::Box<'alloc, TemplateExpression<'alloc>>), 104 TemplateExpressionElement(arena::Box<'alloc, TemplateExpressionElement<'alloc>>), 105 Token(arena::Box<'alloc, Token>), 106 UnaryOperator(arena::Box<'alloc, UnaryOperator>), 107 UpdateOperator(arena::Box<'alloc, UpdateOperator>), 108 VariableDeclaration(arena::Box<'alloc, VariableDeclaration<'alloc>>), 109 VariableDeclarationKind(arena::Box<'alloc, VariableDeclarationKind>), 110 VariableDeclarationOrAssignmentTarget(arena::Box<'alloc, VariableDeclarationOrAssignmentTarget<'alloc>>), 111 VariableDeclarationOrExpression(arena::Box<'alloc, VariableDeclarationOrExpression<'alloc>>), 112 VariableDeclarator(arena::Box<'alloc, VariableDeclarator<'alloc>>), 113 VariableReference(arena::Box<'alloc, VariableReference>), 114 VecArrayExpressionElement(arena::Box<'alloc, arena::Vec<'alloc, ArrayExpressionElement<'alloc>>>), 115 VecBindingProperty(arena::Box<'alloc, arena::Vec<'alloc, BindingProperty<'alloc>>>), 116 VecClassElement(arena::Box<'alloc, arena::Vec<'alloc, arena::Box<'alloc, ClassElement<'alloc>>>>), 117 VecOption(arena::Box<'alloc, arena::Vec<'alloc, Option<Parameter<'alloc>>>>), 118 VecStatement(arena::Box<'alloc, arena::Vec<'alloc, Statement<'alloc>>>), 119 VecSwitchCase(arena::Box<'alloc, arena::Vec<'alloc, SwitchCase<'alloc>>>), 120 VecVariableDeclarator(arena::Box<'alloc, arena::Vec<'alloc, VariableDeclarator<'alloc>>>), 121 Void(arena::Box<'alloc, Void>), 122 } 123 124 impl<'alloc> StackValue<'alloc> { to_ast<T: StackValueItem<'alloc>>(self) -> AstResult<'alloc, T>125 pub fn to_ast<T: StackValueItem<'alloc>>(self) -> AstResult<'alloc, T> { 126 T::to_ast(self) 127 } 128 } 129 130 pub trait StackValueItem<'alloc>: Sized { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>131 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>; 132 } 133 134 /// Values that can be converted to StackValues, fallibly. 135 pub trait TryIntoStack<'alloc> { 136 type Error; try_into_stack(self) -> Result<StackValue<'alloc>, Self::Error>137 fn try_into_stack(self) -> Result<StackValue<'alloc>, Self::Error>; 138 } 139 impl<'alloc> StackValueItem<'alloc> for Argument<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>140 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 141 match sv { 142 StackValue::Argument(v) => Ok(v), 143 _ => Err(format!("StackValue expected Argument, got {:?}", sv)), 144 } 145 } 146 } 147 148 impl<'alloc> StackValueItem<'alloc> for Arguments<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>149 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 150 match sv { 151 StackValue::Arguments(v) => Ok(v), 152 _ => Err(format!("StackValue expected Arguments, got {:?}", sv)), 153 } 154 } 155 } 156 157 impl<'alloc> StackValueItem<'alloc> for ArrayAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>158 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 159 match sv { 160 StackValue::ArrayAssignmentTarget(v) => Ok(v), 161 _ => Err(format!("StackValue expected ArrayAssignmentTarget, got {:?}", sv)), 162 } 163 } 164 } 165 166 impl<'alloc> StackValueItem<'alloc> for ArrayBinding<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>167 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 168 match sv { 169 StackValue::ArrayBinding(v) => Ok(v), 170 _ => Err(format!("StackValue expected ArrayBinding, got {:?}", sv)), 171 } 172 } 173 } 174 175 impl<'alloc> StackValueItem<'alloc> for ArrayExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>176 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 177 match sv { 178 StackValue::ArrayExpression(v) => Ok(v), 179 _ => Err(format!("StackValue expected ArrayExpression, got {:?}", sv)), 180 } 181 } 182 } 183 184 impl<'alloc> StackValueItem<'alloc> for ArrayExpressionElement<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>185 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 186 match sv { 187 StackValue::ArrayExpressionElement(v) => Ok(v), 188 _ => Err(format!("StackValue expected ArrayExpressionElement, got {:?}", sv)), 189 } 190 } 191 } 192 193 impl<'alloc> StackValueItem<'alloc> for ArrowExpressionBody<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>194 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 195 match sv { 196 StackValue::ArrowExpressionBody(v) => Ok(v), 197 _ => Err(format!("StackValue expected ArrowExpressionBody, got {:?}", sv)), 198 } 199 } 200 } 201 202 impl<'alloc> StackValueItem<'alloc> for AssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>203 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 204 match sv { 205 StackValue::AssignmentTarget(v) => Ok(v), 206 _ => Err(format!("StackValue expected AssignmentTarget, got {:?}", sv)), 207 } 208 } 209 } 210 211 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetIdentifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>212 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 213 match sv { 214 StackValue::AssignmentTargetIdentifier(v) => Ok(v), 215 _ => Err(format!("StackValue expected AssignmentTargetIdentifier, got {:?}", sv)), 216 } 217 } 218 } 219 220 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetMaybeDefault<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>221 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 222 match sv { 223 StackValue::AssignmentTargetMaybeDefault(v) => Ok(v), 224 _ => Err(format!("StackValue expected AssignmentTargetMaybeDefault, got {:?}", sv)), 225 } 226 } 227 } 228 229 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetPattern<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>230 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 231 match sv { 232 StackValue::AssignmentTargetPattern(v) => Ok(v), 233 _ => Err(format!("StackValue expected AssignmentTargetPattern, got {:?}", sv)), 234 } 235 } 236 } 237 238 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>239 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 240 match sv { 241 StackValue::AssignmentTargetProperty(v) => Ok(v), 242 _ => Err(format!("StackValue expected AssignmentTargetProperty, got {:?}", sv)), 243 } 244 } 245 } 246 247 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetPropertyIdentifier<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>248 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 249 match sv { 250 StackValue::AssignmentTargetPropertyIdentifier(v) => Ok(v), 251 _ => Err(format!("StackValue expected AssignmentTargetPropertyIdentifier, got {:?}", sv)), 252 } 253 } 254 } 255 256 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetPropertyProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>257 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 258 match sv { 259 StackValue::AssignmentTargetPropertyProperty(v) => Ok(v), 260 _ => Err(format!("StackValue expected AssignmentTargetPropertyProperty, got {:?}", sv)), 261 } 262 } 263 } 264 265 impl<'alloc> StackValueItem<'alloc> for AssignmentTargetWithDefault<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>266 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 267 match sv { 268 StackValue::AssignmentTargetWithDefault(v) => Ok(v), 269 _ => Err(format!("StackValue expected AssignmentTargetWithDefault, got {:?}", sv)), 270 } 271 } 272 } 273 274 impl<'alloc> StackValueItem<'alloc> for BinaryOperator { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>275 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 276 match sv { 277 StackValue::BinaryOperator(v) => Ok(v), 278 _ => Err(format!("StackValue expected BinaryOperator, got {:?}", sv)), 279 } 280 } 281 } 282 283 impl<'alloc> StackValueItem<'alloc> for Binding<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>284 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 285 match sv { 286 StackValue::Binding(v) => Ok(v), 287 _ => Err(format!("StackValue expected Binding, got {:?}", sv)), 288 } 289 } 290 } 291 292 impl<'alloc> StackValueItem<'alloc> for BindingIdentifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>293 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 294 match sv { 295 StackValue::BindingIdentifier(v) => Ok(v), 296 _ => Err(format!("StackValue expected BindingIdentifier, got {:?}", sv)), 297 } 298 } 299 } 300 301 impl<'alloc> StackValueItem<'alloc> for BindingPattern<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>302 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 303 match sv { 304 StackValue::BindingPattern(v) => Ok(v), 305 _ => Err(format!("StackValue expected BindingPattern, got {:?}", sv)), 306 } 307 } 308 } 309 310 impl<'alloc> StackValueItem<'alloc> for BindingProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>311 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 312 match sv { 313 StackValue::BindingProperty(v) => Ok(v), 314 _ => Err(format!("StackValue expected BindingProperty, got {:?}", sv)), 315 } 316 } 317 } 318 319 impl<'alloc> StackValueItem<'alloc> for BindingPropertyIdentifier<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>320 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 321 match sv { 322 StackValue::BindingPropertyIdentifier(v) => Ok(v), 323 _ => Err(format!("StackValue expected BindingPropertyIdentifier, got {:?}", sv)), 324 } 325 } 326 } 327 328 impl<'alloc> StackValueItem<'alloc> for BindingPropertyProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>329 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 330 match sv { 331 StackValue::BindingPropertyProperty(v) => Ok(v), 332 _ => Err(format!("StackValue expected BindingPropertyProperty, got {:?}", sv)), 333 } 334 } 335 } 336 337 impl<'alloc> StackValueItem<'alloc> for BindingWithDefault<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>338 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 339 match sv { 340 StackValue::BindingWithDefault(v) => Ok(v), 341 _ => Err(format!("StackValue expected BindingWithDefault, got {:?}", sv)), 342 } 343 } 344 } 345 346 impl<'alloc> StackValueItem<'alloc> for Block<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>347 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 348 match sv { 349 StackValue::Block(v) => Ok(v), 350 _ => Err(format!("StackValue expected Block, got {:?}", sv)), 351 } 352 } 353 } 354 355 impl<'alloc> StackValueItem<'alloc> for CallExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>356 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 357 match sv { 358 StackValue::CallExpression(v) => Ok(v), 359 _ => Err(format!("StackValue expected CallExpression, got {:?}", sv)), 360 } 361 } 362 } 363 364 impl<'alloc> StackValueItem<'alloc> for CatchClause<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>365 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 366 match sv { 367 StackValue::CatchClause(v) => Ok(v), 368 _ => Err(format!("StackValue expected CatchClause, got {:?}", sv)), 369 } 370 } 371 } 372 373 impl<'alloc> StackValueItem<'alloc> for ClassDeclaration<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>374 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 375 match sv { 376 StackValue::ClassDeclaration(v) => Ok(v), 377 _ => Err(format!("StackValue expected ClassDeclaration, got {:?}", sv)), 378 } 379 } 380 } 381 382 impl<'alloc> StackValueItem<'alloc> for ClassElement<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>383 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 384 match sv { 385 StackValue::ClassElement(v) => Ok(v), 386 _ => Err(format!("StackValue expected ClassElement, got {:?}", sv)), 387 } 388 } 389 } 390 391 impl<'alloc> StackValueItem<'alloc> for ClassElementName<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>392 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 393 match sv { 394 StackValue::ClassElementName(v) => Ok(v), 395 _ => Err(format!("StackValue expected ClassElementName, got {:?}", sv)), 396 } 397 } 398 } 399 400 impl<'alloc> StackValueItem<'alloc> for ClassExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>401 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 402 match sv { 403 StackValue::ClassExpression(v) => Ok(v), 404 _ => Err(format!("StackValue expected ClassExpression, got {:?}", sv)), 405 } 406 } 407 } 408 409 impl<'alloc> StackValueItem<'alloc> for CompoundAssignmentOperator { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>410 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 411 match sv { 412 StackValue::CompoundAssignmentOperator(v) => Ok(v), 413 _ => Err(format!("StackValue expected CompoundAssignmentOperator, got {:?}", sv)), 414 } 415 } 416 } 417 418 impl<'alloc> StackValueItem<'alloc> for ComputedMemberAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>419 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 420 match sv { 421 StackValue::ComputedMemberAssignmentTarget(v) => Ok(v), 422 _ => Err(format!("StackValue expected ComputedMemberAssignmentTarget, got {:?}", sv)), 423 } 424 } 425 } 426 427 impl<'alloc> StackValueItem<'alloc> for ComputedMemberExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>428 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 429 match sv { 430 StackValue::ComputedMemberExpression(v) => Ok(v), 431 _ => Err(format!("StackValue expected ComputedMemberExpression, got {:?}", sv)), 432 } 433 } 434 } 435 436 impl<'alloc> StackValueItem<'alloc> for ComputedPropertyName<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>437 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 438 match sv { 439 StackValue::ComputedPropertyName(v) => Ok(v), 440 _ => Err(format!("StackValue expected ComputedPropertyName, got {:?}", sv)), 441 } 442 } 443 } 444 445 impl<'alloc> StackValueItem<'alloc> for CoverParenthesized<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>446 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 447 match sv { 448 StackValue::CoverParenthesized(v) => Ok(v), 449 _ => Err(format!("StackValue expected CoverParenthesized, got {:?}", sv)), 450 } 451 } 452 } 453 454 impl<'alloc> StackValueItem<'alloc> for DataProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>455 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 456 match sv { 457 StackValue::DataProperty(v) => Ok(v), 458 _ => Err(format!("StackValue expected DataProperty, got {:?}", sv)), 459 } 460 } 461 } 462 463 impl<'alloc> StackValueItem<'alloc> for Directive { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>464 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 465 match sv { 466 StackValue::Directive(v) => Ok(v), 467 _ => Err(format!("StackValue expected Directive, got {:?}", sv)), 468 } 469 } 470 } 471 472 impl<'alloc> StackValueItem<'alloc> for Export<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>473 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 474 match sv { 475 StackValue::Export(v) => Ok(v), 476 _ => Err(format!("StackValue expected Export, got {:?}", sv)), 477 } 478 } 479 } 480 481 impl<'alloc> StackValueItem<'alloc> for ExportAllFrom { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>482 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 483 match sv { 484 StackValue::ExportAllFrom(v) => Ok(v), 485 _ => Err(format!("StackValue expected ExportAllFrom, got {:?}", sv)), 486 } 487 } 488 } 489 490 impl<'alloc> StackValueItem<'alloc> for ExportDeclaration<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>491 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 492 match sv { 493 StackValue::ExportDeclaration(v) => Ok(v), 494 _ => Err(format!("StackValue expected ExportDeclaration, got {:?}", sv)), 495 } 496 } 497 } 498 499 impl<'alloc> StackValueItem<'alloc> for ExportDefault<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>500 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 501 match sv { 502 StackValue::ExportDefault(v) => Ok(v), 503 _ => Err(format!("StackValue expected ExportDefault, got {:?}", sv)), 504 } 505 } 506 } 507 508 impl<'alloc> StackValueItem<'alloc> for ExportFrom<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>509 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 510 match sv { 511 StackValue::ExportFrom(v) => Ok(v), 512 _ => Err(format!("StackValue expected ExportFrom, got {:?}", sv)), 513 } 514 } 515 } 516 517 impl<'alloc> StackValueItem<'alloc> for ExportFromSpecifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>518 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 519 match sv { 520 StackValue::ExportFromSpecifier(v) => Ok(v), 521 _ => Err(format!("StackValue expected ExportFromSpecifier, got {:?}", sv)), 522 } 523 } 524 } 525 526 impl<'alloc> StackValueItem<'alloc> for ExportLocalSpecifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>527 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 528 match sv { 529 StackValue::ExportLocalSpecifier(v) => Ok(v), 530 _ => Err(format!("StackValue expected ExportLocalSpecifier, got {:?}", sv)), 531 } 532 } 533 } 534 535 impl<'alloc> StackValueItem<'alloc> for ExportLocals<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>536 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 537 match sv { 538 StackValue::ExportLocals(v) => Ok(v), 539 _ => Err(format!("StackValue expected ExportLocals, got {:?}", sv)), 540 } 541 } 542 } 543 544 impl<'alloc> StackValueItem<'alloc> for Expression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>545 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 546 match sv { 547 StackValue::Expression(v) => Ok(v), 548 _ => Err(format!("StackValue expected Expression, got {:?}", sv)), 549 } 550 } 551 } 552 553 impl<'alloc> StackValueItem<'alloc> for ExpressionOrSuper<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>554 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 555 match sv { 556 StackValue::ExpressionOrSuper(v) => Ok(v), 557 _ => Err(format!("StackValue expected ExpressionOrSuper, got {:?}", sv)), 558 } 559 } 560 } 561 562 impl<'alloc> StackValueItem<'alloc> for FormalParameters<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>563 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 564 match sv { 565 StackValue::FormalParameters(v) => Ok(v), 566 _ => Err(format!("StackValue expected FormalParameters, got {:?}", sv)), 567 } 568 } 569 } 570 571 impl<'alloc> StackValueItem<'alloc> for Function<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>572 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 573 match sv { 574 StackValue::Function(v) => Ok(v), 575 _ => Err(format!("StackValue expected Function, got {:?}", sv)), 576 } 577 } 578 } 579 580 impl<'alloc> StackValueItem<'alloc> for FunctionBody<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>581 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 582 match sv { 583 StackValue::FunctionBody(v) => Ok(v), 584 _ => Err(format!("StackValue expected FunctionBody, got {:?}", sv)), 585 } 586 } 587 } 588 589 impl<'alloc> StackValueItem<'alloc> for Getter<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>590 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 591 match sv { 592 StackValue::Getter(v) => Ok(v), 593 _ => Err(format!("StackValue expected Getter, got {:?}", sv)), 594 } 595 } 596 } 597 598 impl<'alloc> StackValueItem<'alloc> for Identifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>599 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 600 match sv { 601 StackValue::Identifier(v) => Ok(v), 602 _ => Err(format!("StackValue expected Identifier, got {:?}", sv)), 603 } 604 } 605 } 606 607 impl<'alloc> StackValueItem<'alloc> for IdentifierExpression { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>608 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 609 match sv { 610 StackValue::IdentifierExpression(v) => Ok(v), 611 _ => Err(format!("StackValue expected IdentifierExpression, got {:?}", sv)), 612 } 613 } 614 } 615 616 impl<'alloc> StackValueItem<'alloc> for IdentifierName { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>617 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 618 match sv { 619 StackValue::IdentifierName(v) => Ok(v), 620 _ => Err(format!("StackValue expected IdentifierName, got {:?}", sv)), 621 } 622 } 623 } 624 625 impl<'alloc> StackValueItem<'alloc> for IfStatement<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>626 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 627 match sv { 628 StackValue::IfStatement(v) => Ok(v), 629 _ => Err(format!("StackValue expected IfStatement, got {:?}", sv)), 630 } 631 } 632 } 633 634 impl<'alloc> StackValueItem<'alloc> for Import<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>635 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 636 match sv { 637 StackValue::Import(v) => Ok(v), 638 _ => Err(format!("StackValue expected Import, got {:?}", sv)), 639 } 640 } 641 } 642 643 impl<'alloc> StackValueItem<'alloc> for ImportDeclaration<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>644 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 645 match sv { 646 StackValue::ImportDeclaration(v) => Ok(v), 647 _ => Err(format!("StackValue expected ImportDeclaration, got {:?}", sv)), 648 } 649 } 650 } 651 652 impl<'alloc> StackValueItem<'alloc> for ImportNamespace { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>653 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 654 match sv { 655 StackValue::ImportNamespace(v) => Ok(v), 656 _ => Err(format!("StackValue expected ImportNamespace, got {:?}", sv)), 657 } 658 } 659 } 660 661 impl<'alloc> StackValueItem<'alloc> for ImportSpecifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>662 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 663 match sv { 664 StackValue::ImportSpecifier(v) => Ok(v), 665 _ => Err(format!("StackValue expected ImportSpecifier, got {:?}", sv)), 666 } 667 } 668 } 669 670 impl<'alloc> StackValueItem<'alloc> for Label { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>671 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 672 match sv { 673 StackValue::Label(v) => Ok(v), 674 _ => Err(format!("StackValue expected Label, got {:?}", sv)), 675 } 676 } 677 } 678 679 impl<'alloc> StackValueItem<'alloc> for MemberAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>680 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 681 match sv { 682 StackValue::MemberAssignmentTarget(v) => Ok(v), 683 _ => Err(format!("StackValue expected MemberAssignmentTarget, got {:?}", sv)), 684 } 685 } 686 } 687 688 impl<'alloc> StackValueItem<'alloc> for MemberExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>689 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 690 match sv { 691 StackValue::MemberExpression(v) => Ok(v), 692 _ => Err(format!("StackValue expected MemberExpression, got {:?}", sv)), 693 } 694 } 695 } 696 697 impl<'alloc> StackValueItem<'alloc> for Method<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>698 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 699 match sv { 700 StackValue::Method(v) => Ok(v), 701 _ => Err(format!("StackValue expected Method, got {:?}", sv)), 702 } 703 } 704 } 705 706 impl<'alloc> StackValueItem<'alloc> for MethodDefinition<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>707 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 708 match sv { 709 StackValue::MethodDefinition(v) => Ok(v), 710 _ => Err(format!("StackValue expected MethodDefinition, got {:?}", sv)), 711 } 712 } 713 } 714 715 impl<'alloc> StackValueItem<'alloc> for Module<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>716 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 717 match sv { 718 StackValue::Module(v) => Ok(v), 719 _ => Err(format!("StackValue expected Module, got {:?}", sv)), 720 } 721 } 722 } 723 724 impl<'alloc> StackValueItem<'alloc> for ModuleItems<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>725 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 726 match sv { 727 StackValue::ModuleItems(v) => Ok(v), 728 _ => Err(format!("StackValue expected ModuleItems, got {:?}", sv)), 729 } 730 } 731 } 732 733 impl<'alloc> StackValueItem<'alloc> for NamedObjectProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>734 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 735 match sv { 736 StackValue::NamedObjectProperty(v) => Ok(v), 737 _ => Err(format!("StackValue expected NamedObjectProperty, got {:?}", sv)), 738 } 739 } 740 } 741 742 impl<'alloc> StackValueItem<'alloc> for NumericLiteral { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>743 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 744 match sv { 745 StackValue::NumericLiteral(v) => Ok(v), 746 _ => Err(format!("StackValue expected NumericLiteral, got {:?}", sv)), 747 } 748 } 749 } 750 751 impl<'alloc> StackValueItem<'alloc> for ObjectAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>752 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 753 match sv { 754 StackValue::ObjectAssignmentTarget(v) => Ok(v), 755 _ => Err(format!("StackValue expected ObjectAssignmentTarget, got {:?}", sv)), 756 } 757 } 758 } 759 760 impl<'alloc> StackValueItem<'alloc> for ObjectBinding<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>761 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 762 match sv { 763 StackValue::ObjectBinding(v) => Ok(v), 764 _ => Err(format!("StackValue expected ObjectBinding, got {:?}", sv)), 765 } 766 } 767 } 768 769 impl<'alloc> StackValueItem<'alloc> for ObjectExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>770 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 771 match sv { 772 StackValue::ObjectExpression(v) => Ok(v), 773 _ => Err(format!("StackValue expected ObjectExpression, got {:?}", sv)), 774 } 775 } 776 } 777 778 impl<'alloc> StackValueItem<'alloc> for ObjectProperty<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>779 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 780 match sv { 781 StackValue::ObjectProperty(v) => Ok(v), 782 _ => Err(format!("StackValue expected ObjectProperty, got {:?}", sv)), 783 } 784 } 785 } 786 787 impl<'alloc> StackValueItem<'alloc> for OptionalChain<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>788 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 789 match sv { 790 StackValue::OptionalChain(v) => Ok(v), 791 _ => Err(format!("StackValue expected OptionalChain, got {:?}", sv)), 792 } 793 } 794 } 795 796 impl<'alloc> StackValueItem<'alloc> for Parameter<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>797 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 798 match sv { 799 StackValue::Parameter(v) => Ok(v), 800 _ => Err(format!("StackValue expected Parameter, got {:?}", sv)), 801 } 802 } 803 } 804 805 impl<'alloc> StackValueItem<'alloc> for PrivateFieldAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>806 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 807 match sv { 808 StackValue::PrivateFieldAssignmentTarget(v) => Ok(v), 809 _ => Err(format!("StackValue expected PrivateFieldAssignmentTarget, got {:?}", sv)), 810 } 811 } 812 } 813 814 impl<'alloc> StackValueItem<'alloc> for PrivateFieldExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>815 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 816 match sv { 817 StackValue::PrivateFieldExpression(v) => Ok(v), 818 _ => Err(format!("StackValue expected PrivateFieldExpression, got {:?}", sv)), 819 } 820 } 821 } 822 823 impl<'alloc> StackValueItem<'alloc> for PrivateIdentifier { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>824 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 825 match sv { 826 StackValue::PrivateIdentifier(v) => Ok(v), 827 _ => Err(format!("StackValue expected PrivateIdentifier, got {:?}", sv)), 828 } 829 } 830 } 831 832 impl<'alloc> StackValueItem<'alloc> for Program<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>833 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 834 match sv { 835 StackValue::Program(v) => Ok(v), 836 _ => Err(format!("StackValue expected Program, got {:?}", sv)), 837 } 838 } 839 } 840 841 impl<'alloc> StackValueItem<'alloc> for PropertyName<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>842 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 843 match sv { 844 StackValue::PropertyName(v) => Ok(v), 845 _ => Err(format!("StackValue expected PropertyName, got {:?}", sv)), 846 } 847 } 848 } 849 850 impl<'alloc> StackValueItem<'alloc> for Script<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>851 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 852 match sv { 853 StackValue::Script(v) => Ok(v), 854 _ => Err(format!("StackValue expected Script, got {:?}", sv)), 855 } 856 } 857 } 858 859 impl<'alloc> StackValueItem<'alloc> for Setter<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>860 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 861 match sv { 862 StackValue::Setter(v) => Ok(v), 863 _ => Err(format!("StackValue expected Setter, got {:?}", sv)), 864 } 865 } 866 } 867 868 impl<'alloc> StackValueItem<'alloc> for ShorthandProperty { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>869 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 870 match sv { 871 StackValue::ShorthandProperty(v) => Ok(v), 872 _ => Err(format!("StackValue expected ShorthandProperty, got {:?}", sv)), 873 } 874 } 875 } 876 877 impl<'alloc> StackValueItem<'alloc> for SimpleAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>878 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 879 match sv { 880 StackValue::SimpleAssignmentTarget(v) => Ok(v), 881 _ => Err(format!("StackValue expected SimpleAssignmentTarget, got {:?}", sv)), 882 } 883 } 884 } 885 886 impl<'alloc> StackValueItem<'alloc> for Statement<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>887 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 888 match sv { 889 StackValue::Statement(v) => Ok(v), 890 _ => Err(format!("StackValue expected Statement, got {:?}", sv)), 891 } 892 } 893 } 894 895 impl<'alloc> StackValueItem<'alloc> for StaticMemberAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>896 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 897 match sv { 898 StackValue::StaticMemberAssignmentTarget(v) => Ok(v), 899 _ => Err(format!("StackValue expected StaticMemberAssignmentTarget, got {:?}", sv)), 900 } 901 } 902 } 903 904 impl<'alloc> StackValueItem<'alloc> for StaticMemberExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>905 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 906 match sv { 907 StackValue::StaticMemberExpression(v) => Ok(v), 908 _ => Err(format!("StackValue expected StaticMemberExpression, got {:?}", sv)), 909 } 910 } 911 } 912 913 impl<'alloc> StackValueItem<'alloc> for StaticPropertyName { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>914 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 915 match sv { 916 StackValue::StaticPropertyName(v) => Ok(v), 917 _ => Err(format!("StackValue expected StaticPropertyName, got {:?}", sv)), 918 } 919 } 920 } 921 922 impl<'alloc> StackValueItem<'alloc> for SwitchCase<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>923 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 924 match sv { 925 StackValue::SwitchCase(v) => Ok(v), 926 _ => Err(format!("StackValue expected SwitchCase, got {:?}", sv)), 927 } 928 } 929 } 930 931 impl<'alloc> StackValueItem<'alloc> for SwitchDefault<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>932 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 933 match sv { 934 StackValue::SwitchDefault(v) => Ok(v), 935 _ => Err(format!("StackValue expected SwitchDefault, got {:?}", sv)), 936 } 937 } 938 } 939 940 impl<'alloc> StackValueItem<'alloc> for TemplateElement { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>941 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 942 match sv { 943 StackValue::TemplateElement(v) => Ok(v), 944 _ => Err(format!("StackValue expected TemplateElement, got {:?}", sv)), 945 } 946 } 947 } 948 949 impl<'alloc> StackValueItem<'alloc> for TemplateExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>950 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 951 match sv { 952 StackValue::TemplateExpression(v) => Ok(v), 953 _ => Err(format!("StackValue expected TemplateExpression, got {:?}", sv)), 954 } 955 } 956 } 957 958 impl<'alloc> StackValueItem<'alloc> for TemplateExpressionElement<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>959 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 960 match sv { 961 StackValue::TemplateExpressionElement(v) => Ok(v), 962 _ => Err(format!("StackValue expected TemplateExpressionElement, got {:?}", sv)), 963 } 964 } 965 } 966 967 impl<'alloc> StackValueItem<'alloc> for Token { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>968 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 969 match sv { 970 StackValue::Token(v) => Ok(v), 971 _ => Err(format!("StackValue expected Token, got {:?}", sv)), 972 } 973 } 974 } 975 976 impl<'alloc> StackValueItem<'alloc> for UnaryOperator { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>977 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 978 match sv { 979 StackValue::UnaryOperator(v) => Ok(v), 980 _ => Err(format!("StackValue expected UnaryOperator, got {:?}", sv)), 981 } 982 } 983 } 984 985 impl<'alloc> StackValueItem<'alloc> for UpdateOperator { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>986 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 987 match sv { 988 StackValue::UpdateOperator(v) => Ok(v), 989 _ => Err(format!("StackValue expected UpdateOperator, got {:?}", sv)), 990 } 991 } 992 } 993 994 impl<'alloc> StackValueItem<'alloc> for VariableDeclaration<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>995 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 996 match sv { 997 StackValue::VariableDeclaration(v) => Ok(v), 998 _ => Err(format!("StackValue expected VariableDeclaration, got {:?}", sv)), 999 } 1000 } 1001 } 1002 1003 impl<'alloc> StackValueItem<'alloc> for VariableDeclarationKind { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1004 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1005 match sv { 1006 StackValue::VariableDeclarationKind(v) => Ok(v), 1007 _ => Err(format!("StackValue expected VariableDeclarationKind, got {:?}", sv)), 1008 } 1009 } 1010 } 1011 1012 impl<'alloc> StackValueItem<'alloc> for VariableDeclarationOrAssignmentTarget<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1013 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1014 match sv { 1015 StackValue::VariableDeclarationOrAssignmentTarget(v) => Ok(v), 1016 _ => Err(format!("StackValue expected VariableDeclarationOrAssignmentTarget, got {:?}", sv)), 1017 } 1018 } 1019 } 1020 1021 impl<'alloc> StackValueItem<'alloc> for VariableDeclarationOrExpression<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1022 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1023 match sv { 1024 StackValue::VariableDeclarationOrExpression(v) => Ok(v), 1025 _ => Err(format!("StackValue expected VariableDeclarationOrExpression, got {:?}", sv)), 1026 } 1027 } 1028 } 1029 1030 impl<'alloc> StackValueItem<'alloc> for VariableDeclarator<'alloc> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1031 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1032 match sv { 1033 StackValue::VariableDeclarator(v) => Ok(v), 1034 _ => Err(format!("StackValue expected VariableDeclarator, got {:?}", sv)), 1035 } 1036 } 1037 } 1038 1039 impl<'alloc> StackValueItem<'alloc> for VariableReference { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1040 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1041 match sv { 1042 StackValue::VariableReference(v) => Ok(v), 1043 _ => Err(format!("StackValue expected VariableReference, got {:?}", sv)), 1044 } 1045 } 1046 } 1047 1048 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, ArrayExpressionElement<'alloc>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1049 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1050 match sv { 1051 StackValue::VecArrayExpressionElement(v) => Ok(v), 1052 _ => Err(format!("StackValue expected Vec<ArrayExpressionElement>, got {:?}", sv)), 1053 } 1054 } 1055 } 1056 1057 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, BindingProperty<'alloc>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1058 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1059 match sv { 1060 StackValue::VecBindingProperty(v) => Ok(v), 1061 _ => Err(format!("StackValue expected Vec<BindingProperty>, got {:?}", sv)), 1062 } 1063 } 1064 } 1065 1066 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, arena::Box<'alloc, ClassElement<'alloc>>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1067 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1068 match sv { 1069 StackValue::VecClassElement(v) => Ok(v), 1070 _ => Err(format!("StackValue expected Vec<Box<ClassElement>>, got {:?}", sv)), 1071 } 1072 } 1073 } 1074 1075 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, Option<Parameter<'alloc>>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1076 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1077 match sv { 1078 StackValue::VecOption(v) => Ok(v), 1079 _ => Err(format!("StackValue expected Vec<Option<Parameter>>, got {:?}", sv)), 1080 } 1081 } 1082 } 1083 1084 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, Statement<'alloc>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1085 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1086 match sv { 1087 StackValue::VecStatement(v) => Ok(v), 1088 _ => Err(format!("StackValue expected Vec<Statement>, got {:?}", sv)), 1089 } 1090 } 1091 } 1092 1093 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, SwitchCase<'alloc>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1094 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1095 match sv { 1096 StackValue::VecSwitchCase(v) => Ok(v), 1097 _ => Err(format!("StackValue expected Vec<SwitchCase>, got {:?}", sv)), 1098 } 1099 } 1100 } 1101 1102 impl<'alloc> StackValueItem<'alloc> for arena::Vec<'alloc, VariableDeclarator<'alloc>> { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1103 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1104 match sv { 1105 StackValue::VecVariableDeclarator(v) => Ok(v), 1106 _ => Err(format!("StackValue expected Vec<VariableDeclarator>, got {:?}", sv)), 1107 } 1108 } 1109 } 1110 1111 impl<'alloc> StackValueItem<'alloc> for Void { to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self>1112 fn to_ast(sv: StackValue<'alloc>) -> AstResult<'alloc, Self> { 1113 match sv { 1114 StackValue::Void(v) => Ok(v), 1115 _ => Err(format!("StackValue expected Void, got {:?}", sv)), 1116 } 1117 } 1118 } 1119 1120 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Argument<'alloc>> { 1121 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1122 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1123 Ok(StackValue::Argument(self)) 1124 } 1125 } 1126 1127 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Arguments<'alloc>> { 1128 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1129 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1130 Ok(StackValue::Arguments(self)) 1131 } 1132 } 1133 1134 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ArrayAssignmentTarget<'alloc>> { 1135 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1136 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1137 Ok(StackValue::ArrayAssignmentTarget(self)) 1138 } 1139 } 1140 1141 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ArrayBinding<'alloc>> { 1142 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1143 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1144 Ok(StackValue::ArrayBinding(self)) 1145 } 1146 } 1147 1148 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ArrayExpression<'alloc>> { 1149 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1150 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1151 Ok(StackValue::ArrayExpression(self)) 1152 } 1153 } 1154 1155 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ArrayExpressionElement<'alloc>> { 1156 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1157 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1158 Ok(StackValue::ArrayExpressionElement(self)) 1159 } 1160 } 1161 1162 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ArrowExpressionBody<'alloc>> { 1163 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1164 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1165 Ok(StackValue::ArrowExpressionBody(self)) 1166 } 1167 } 1168 1169 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTarget<'alloc>> { 1170 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1171 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1172 Ok(StackValue::AssignmentTarget(self)) 1173 } 1174 } 1175 1176 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetIdentifier> { 1177 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1178 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1179 Ok(StackValue::AssignmentTargetIdentifier(self)) 1180 } 1181 } 1182 1183 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetMaybeDefault<'alloc>> { 1184 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1185 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1186 Ok(StackValue::AssignmentTargetMaybeDefault(self)) 1187 } 1188 } 1189 1190 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetPattern<'alloc>> { 1191 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1192 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1193 Ok(StackValue::AssignmentTargetPattern(self)) 1194 } 1195 } 1196 1197 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetProperty<'alloc>> { 1198 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1199 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1200 Ok(StackValue::AssignmentTargetProperty(self)) 1201 } 1202 } 1203 1204 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetPropertyIdentifier<'alloc>> { 1205 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1206 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1207 Ok(StackValue::AssignmentTargetPropertyIdentifier(self)) 1208 } 1209 } 1210 1211 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetPropertyProperty<'alloc>> { 1212 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1213 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1214 Ok(StackValue::AssignmentTargetPropertyProperty(self)) 1215 } 1216 } 1217 1218 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, AssignmentTargetWithDefault<'alloc>> { 1219 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1220 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1221 Ok(StackValue::AssignmentTargetWithDefault(self)) 1222 } 1223 } 1224 1225 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BinaryOperator> { 1226 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1227 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1228 Ok(StackValue::BinaryOperator(self)) 1229 } 1230 } 1231 1232 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Binding<'alloc>> { 1233 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1234 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1235 Ok(StackValue::Binding(self)) 1236 } 1237 } 1238 1239 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingIdentifier> { 1240 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1241 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1242 Ok(StackValue::BindingIdentifier(self)) 1243 } 1244 } 1245 1246 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingPattern<'alloc>> { 1247 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1248 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1249 Ok(StackValue::BindingPattern(self)) 1250 } 1251 } 1252 1253 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingProperty<'alloc>> { 1254 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1255 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1256 Ok(StackValue::BindingProperty(self)) 1257 } 1258 } 1259 1260 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingPropertyIdentifier<'alloc>> { 1261 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1262 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1263 Ok(StackValue::BindingPropertyIdentifier(self)) 1264 } 1265 } 1266 1267 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingPropertyProperty<'alloc>> { 1268 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1269 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1270 Ok(StackValue::BindingPropertyProperty(self)) 1271 } 1272 } 1273 1274 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, BindingWithDefault<'alloc>> { 1275 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1276 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1277 Ok(StackValue::BindingWithDefault(self)) 1278 } 1279 } 1280 1281 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Block<'alloc>> { 1282 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1283 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1284 Ok(StackValue::Block(self)) 1285 } 1286 } 1287 1288 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, CallExpression<'alloc>> { 1289 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1290 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1291 Ok(StackValue::CallExpression(self)) 1292 } 1293 } 1294 1295 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, CatchClause<'alloc>> { 1296 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1297 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1298 Ok(StackValue::CatchClause(self)) 1299 } 1300 } 1301 1302 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ClassDeclaration<'alloc>> { 1303 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1304 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1305 Ok(StackValue::ClassDeclaration(self)) 1306 } 1307 } 1308 1309 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ClassElement<'alloc>> { 1310 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1311 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1312 Ok(StackValue::ClassElement(self)) 1313 } 1314 } 1315 1316 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ClassElementName<'alloc>> { 1317 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1318 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1319 Ok(StackValue::ClassElementName(self)) 1320 } 1321 } 1322 1323 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ClassExpression<'alloc>> { 1324 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1325 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1326 Ok(StackValue::ClassExpression(self)) 1327 } 1328 } 1329 1330 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, CompoundAssignmentOperator> { 1331 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1332 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1333 Ok(StackValue::CompoundAssignmentOperator(self)) 1334 } 1335 } 1336 1337 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ComputedMemberAssignmentTarget<'alloc>> { 1338 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1339 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1340 Ok(StackValue::ComputedMemberAssignmentTarget(self)) 1341 } 1342 } 1343 1344 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ComputedMemberExpression<'alloc>> { 1345 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1346 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1347 Ok(StackValue::ComputedMemberExpression(self)) 1348 } 1349 } 1350 1351 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ComputedPropertyName<'alloc>> { 1352 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1353 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1354 Ok(StackValue::ComputedPropertyName(self)) 1355 } 1356 } 1357 1358 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, CoverParenthesized<'alloc>> { 1359 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1360 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1361 Ok(StackValue::CoverParenthesized(self)) 1362 } 1363 } 1364 1365 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, DataProperty<'alloc>> { 1366 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1367 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1368 Ok(StackValue::DataProperty(self)) 1369 } 1370 } 1371 1372 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Directive> { 1373 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1374 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1375 Ok(StackValue::Directive(self)) 1376 } 1377 } 1378 1379 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Export<'alloc>> { 1380 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1381 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1382 Ok(StackValue::Export(self)) 1383 } 1384 } 1385 1386 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportAllFrom> { 1387 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1388 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1389 Ok(StackValue::ExportAllFrom(self)) 1390 } 1391 } 1392 1393 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportDeclaration<'alloc>> { 1394 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1395 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1396 Ok(StackValue::ExportDeclaration(self)) 1397 } 1398 } 1399 1400 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportDefault<'alloc>> { 1401 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1402 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1403 Ok(StackValue::ExportDefault(self)) 1404 } 1405 } 1406 1407 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportFrom<'alloc>> { 1408 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1409 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1410 Ok(StackValue::ExportFrom(self)) 1411 } 1412 } 1413 1414 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportFromSpecifier> { 1415 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1416 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1417 Ok(StackValue::ExportFromSpecifier(self)) 1418 } 1419 } 1420 1421 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportLocalSpecifier> { 1422 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1423 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1424 Ok(StackValue::ExportLocalSpecifier(self)) 1425 } 1426 } 1427 1428 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExportLocals<'alloc>> { 1429 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1430 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1431 Ok(StackValue::ExportLocals(self)) 1432 } 1433 } 1434 1435 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Expression<'alloc>> { 1436 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1437 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1438 Ok(StackValue::Expression(self)) 1439 } 1440 } 1441 1442 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ExpressionOrSuper<'alloc>> { 1443 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1444 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1445 Ok(StackValue::ExpressionOrSuper(self)) 1446 } 1447 } 1448 1449 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, FormalParameters<'alloc>> { 1450 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1451 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1452 Ok(StackValue::FormalParameters(self)) 1453 } 1454 } 1455 1456 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Function<'alloc>> { 1457 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1458 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1459 Ok(StackValue::Function(self)) 1460 } 1461 } 1462 1463 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, FunctionBody<'alloc>> { 1464 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1465 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1466 Ok(StackValue::FunctionBody(self)) 1467 } 1468 } 1469 1470 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Getter<'alloc>> { 1471 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1472 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1473 Ok(StackValue::Getter(self)) 1474 } 1475 } 1476 1477 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Identifier> { 1478 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1479 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1480 Ok(StackValue::Identifier(self)) 1481 } 1482 } 1483 1484 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, IdentifierExpression> { 1485 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1486 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1487 Ok(StackValue::IdentifierExpression(self)) 1488 } 1489 } 1490 1491 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, IdentifierName> { 1492 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1493 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1494 Ok(StackValue::IdentifierName(self)) 1495 } 1496 } 1497 1498 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, IfStatement<'alloc>> { 1499 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1500 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1501 Ok(StackValue::IfStatement(self)) 1502 } 1503 } 1504 1505 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Import<'alloc>> { 1506 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1507 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1508 Ok(StackValue::Import(self)) 1509 } 1510 } 1511 1512 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ImportDeclaration<'alloc>> { 1513 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1514 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1515 Ok(StackValue::ImportDeclaration(self)) 1516 } 1517 } 1518 1519 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ImportNamespace> { 1520 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1521 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1522 Ok(StackValue::ImportNamespace(self)) 1523 } 1524 } 1525 1526 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ImportSpecifier> { 1527 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1528 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1529 Ok(StackValue::ImportSpecifier(self)) 1530 } 1531 } 1532 1533 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Label> { 1534 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1535 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1536 Ok(StackValue::Label(self)) 1537 } 1538 } 1539 1540 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, MemberAssignmentTarget<'alloc>> { 1541 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1542 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1543 Ok(StackValue::MemberAssignmentTarget(self)) 1544 } 1545 } 1546 1547 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, MemberExpression<'alloc>> { 1548 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1549 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1550 Ok(StackValue::MemberExpression(self)) 1551 } 1552 } 1553 1554 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Method<'alloc>> { 1555 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1556 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1557 Ok(StackValue::Method(self)) 1558 } 1559 } 1560 1561 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, MethodDefinition<'alloc>> { 1562 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1563 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1564 Ok(StackValue::MethodDefinition(self)) 1565 } 1566 } 1567 1568 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Module<'alloc>> { 1569 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1570 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1571 Ok(StackValue::Module(self)) 1572 } 1573 } 1574 1575 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ModuleItems<'alloc>> { 1576 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1577 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1578 Ok(StackValue::ModuleItems(self)) 1579 } 1580 } 1581 1582 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, NamedObjectProperty<'alloc>> { 1583 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1584 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1585 Ok(StackValue::NamedObjectProperty(self)) 1586 } 1587 } 1588 1589 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, NumericLiteral> { 1590 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1591 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1592 Ok(StackValue::NumericLiteral(self)) 1593 } 1594 } 1595 1596 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ObjectAssignmentTarget<'alloc>> { 1597 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1598 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1599 Ok(StackValue::ObjectAssignmentTarget(self)) 1600 } 1601 } 1602 1603 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ObjectBinding<'alloc>> { 1604 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1605 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1606 Ok(StackValue::ObjectBinding(self)) 1607 } 1608 } 1609 1610 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ObjectExpression<'alloc>> { 1611 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1612 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1613 Ok(StackValue::ObjectExpression(self)) 1614 } 1615 } 1616 1617 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ObjectProperty<'alloc>> { 1618 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1619 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1620 Ok(StackValue::ObjectProperty(self)) 1621 } 1622 } 1623 1624 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, OptionalChain<'alloc>> { 1625 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1626 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1627 Ok(StackValue::OptionalChain(self)) 1628 } 1629 } 1630 1631 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Parameter<'alloc>> { 1632 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1633 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1634 Ok(StackValue::Parameter(self)) 1635 } 1636 } 1637 1638 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, PrivateFieldAssignmentTarget<'alloc>> { 1639 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1640 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1641 Ok(StackValue::PrivateFieldAssignmentTarget(self)) 1642 } 1643 } 1644 1645 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, PrivateFieldExpression<'alloc>> { 1646 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1647 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1648 Ok(StackValue::PrivateFieldExpression(self)) 1649 } 1650 } 1651 1652 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, PrivateIdentifier> { 1653 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1654 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1655 Ok(StackValue::PrivateIdentifier(self)) 1656 } 1657 } 1658 1659 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Program<'alloc>> { 1660 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1661 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1662 Ok(StackValue::Program(self)) 1663 } 1664 } 1665 1666 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, PropertyName<'alloc>> { 1667 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1668 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1669 Ok(StackValue::PropertyName(self)) 1670 } 1671 } 1672 1673 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Script<'alloc>> { 1674 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1675 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1676 Ok(StackValue::Script(self)) 1677 } 1678 } 1679 1680 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Setter<'alloc>> { 1681 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1682 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1683 Ok(StackValue::Setter(self)) 1684 } 1685 } 1686 1687 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, ShorthandProperty> { 1688 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1689 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1690 Ok(StackValue::ShorthandProperty(self)) 1691 } 1692 } 1693 1694 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, SimpleAssignmentTarget<'alloc>> { 1695 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1696 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1697 Ok(StackValue::SimpleAssignmentTarget(self)) 1698 } 1699 } 1700 1701 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Statement<'alloc>> { 1702 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1703 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1704 Ok(StackValue::Statement(self)) 1705 } 1706 } 1707 1708 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, StaticMemberAssignmentTarget<'alloc>> { 1709 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1710 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1711 Ok(StackValue::StaticMemberAssignmentTarget(self)) 1712 } 1713 } 1714 1715 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, StaticMemberExpression<'alloc>> { 1716 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1717 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1718 Ok(StackValue::StaticMemberExpression(self)) 1719 } 1720 } 1721 1722 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, StaticPropertyName> { 1723 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1724 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1725 Ok(StackValue::StaticPropertyName(self)) 1726 } 1727 } 1728 1729 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, SwitchCase<'alloc>> { 1730 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1731 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1732 Ok(StackValue::SwitchCase(self)) 1733 } 1734 } 1735 1736 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, SwitchDefault<'alloc>> { 1737 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1738 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1739 Ok(StackValue::SwitchDefault(self)) 1740 } 1741 } 1742 1743 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, TemplateElement> { 1744 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1745 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1746 Ok(StackValue::TemplateElement(self)) 1747 } 1748 } 1749 1750 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, TemplateExpression<'alloc>> { 1751 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1752 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1753 Ok(StackValue::TemplateExpression(self)) 1754 } 1755 } 1756 1757 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, TemplateExpressionElement<'alloc>> { 1758 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1759 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1760 Ok(StackValue::TemplateExpressionElement(self)) 1761 } 1762 } 1763 1764 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Token> { 1765 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1766 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1767 Ok(StackValue::Token(self)) 1768 } 1769 } 1770 1771 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, UnaryOperator> { 1772 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1773 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1774 Ok(StackValue::UnaryOperator(self)) 1775 } 1776 } 1777 1778 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, UpdateOperator> { 1779 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1780 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1781 Ok(StackValue::UpdateOperator(self)) 1782 } 1783 } 1784 1785 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableDeclaration<'alloc>> { 1786 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1787 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1788 Ok(StackValue::VariableDeclaration(self)) 1789 } 1790 } 1791 1792 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableDeclarationKind> { 1793 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1794 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1795 Ok(StackValue::VariableDeclarationKind(self)) 1796 } 1797 } 1798 1799 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableDeclarationOrAssignmentTarget<'alloc>> { 1800 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1801 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1802 Ok(StackValue::VariableDeclarationOrAssignmentTarget(self)) 1803 } 1804 } 1805 1806 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableDeclarationOrExpression<'alloc>> { 1807 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1808 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1809 Ok(StackValue::VariableDeclarationOrExpression(self)) 1810 } 1811 } 1812 1813 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableDeclarator<'alloc>> { 1814 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1815 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1816 Ok(StackValue::VariableDeclarator(self)) 1817 } 1818 } 1819 1820 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, VariableReference> { 1821 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1822 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1823 Ok(StackValue::VariableReference(self)) 1824 } 1825 } 1826 1827 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, ArrayExpressionElement<'alloc>>> { 1828 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1829 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1830 Ok(StackValue::VecArrayExpressionElement(self)) 1831 } 1832 } 1833 1834 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, BindingProperty<'alloc>>> { 1835 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1836 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1837 Ok(StackValue::VecBindingProperty(self)) 1838 } 1839 } 1840 1841 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, arena::Box<'alloc, ClassElement<'alloc>>>> { 1842 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1843 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1844 Ok(StackValue::VecClassElement(self)) 1845 } 1846 } 1847 1848 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, Option<Parameter<'alloc>>>> { 1849 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1850 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1851 Ok(StackValue::VecOption(self)) 1852 } 1853 } 1854 1855 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, Statement<'alloc>>> { 1856 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1857 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1858 Ok(StackValue::VecStatement(self)) 1859 } 1860 } 1861 1862 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, SwitchCase<'alloc>>> { 1863 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1864 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1865 Ok(StackValue::VecSwitchCase(self)) 1866 } 1867 } 1868 1869 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, arena::Vec<'alloc, VariableDeclarator<'alloc>>> { 1870 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1871 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1872 Ok(StackValue::VecVariableDeclarator(self)) 1873 } 1874 } 1875 1876 impl<'alloc> TryIntoStack<'alloc> for arena::Box<'alloc, Void> { 1877 type Error = Infallible; try_into_stack(self) -> Result<StackValue<'alloc>, Infallible>1878 fn try_into_stack(self) -> Result<StackValue<'alloc>, Infallible> { 1879 Ok(StackValue::Void(self)) 1880 } 1881 } 1882 1883 impl<'alloc, T, E> TryIntoStack<'alloc> for Result<T, E> 1884 where 1885 T: TryIntoStack<'alloc>, 1886 E: From<T::Error>, 1887 { 1888 type Error = E; try_into_stack(self) -> Result<StackValue<'alloc>, E>1889 fn try_into_stack(self) -> Result<StackValue<'alloc>, E> { 1890 Ok(self?.try_into_stack()?) 1891 } 1892 } 1893