Browse Source

Remove unnecessary `Trace` and `Finalize` implementations from AST (#2103)

This Pull Request fchanges the following:

- Remove unnecessary `Trace` and `Finalize` implementations from AST
- Add `#[unsafe_ignore_trace]` to parameters stored in `CodeBlock`
- Remove unused `RcStatementList` type

Relates to #1615
pull/2109/head
raskad 2 years ago
parent
commit
9025c36b1b
  1. 3
      boa_engine/src/syntax/ast/node/array/mod.rs
  2. 3
      boa_engine/src/syntax/ast/node/await_expr/mod.rs
  3. 3
      boa_engine/src/syntax/ast/node/block/mod.rs
  4. 3
      boa_engine/src/syntax/ast/node/call/mod.rs
  5. 3
      boa_engine/src/syntax/ast/node/conditional/conditional_op/mod.rs
  6. 3
      boa_engine/src/syntax/ast/node/conditional/if_node/mod.rs
  7. 3
      boa_engine/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs
  8. 3
      boa_engine/src/syntax/ast/node/declaration/async_function_decl/mod.rs
  9. 3
      boa_engine/src/syntax/ast/node/declaration/async_function_expr/mod.rs
  10. 3
      boa_engine/src/syntax/ast/node/declaration/async_generator_decl/mod.rs
  11. 3
      boa_engine/src/syntax/ast/node/declaration/async_generator_expr/mod.rs
  12. 5
      boa_engine/src/syntax/ast/node/declaration/class_decl/mod.rs
  13. 3
      boa_engine/src/syntax/ast/node/declaration/function_decl/mod.rs
  14. 3
      boa_engine/src/syntax/ast/node/declaration/function_expr/mod.rs
  15. 3
      boa_engine/src/syntax/ast/node/declaration/generator_decl/mod.rs
  16. 3
      boa_engine/src/syntax/ast/node/declaration/generator_expr/mod.rs
  17. 15
      boa_engine/src/syntax/ast/node/declaration/mod.rs
  18. 3
      boa_engine/src/syntax/ast/node/field/get_const_field/mod.rs
  19. 3
      boa_engine/src/syntax/ast/node/field/get_field/mod.rs
  20. 3
      boa_engine/src/syntax/ast/node/field/get_private_field/mod.rs
  21. 3
      boa_engine/src/syntax/ast/node/iteration/do_while_loop/mod.rs
  22. 3
      boa_engine/src/syntax/ast/node/iteration/for_in_loop/mod.rs
  23. 5
      boa_engine/src/syntax/ast/node/iteration/for_loop/mod.rs
  24. 3
      boa_engine/src/syntax/ast/node/iteration/for_of_loop/mod.rs
  25. 3
      boa_engine/src/syntax/ast/node/iteration/mod.rs
  26. 3
      boa_engine/src/syntax/ast/node/iteration/while_loop/mod.rs
  27. 5
      boa_engine/src/syntax/ast/node/mod.rs
  28. 3
      boa_engine/src/syntax/ast/node/new/mod.rs
  29. 19
      boa_engine/src/syntax/ast/node/object/mod.rs
  30. 5
      boa_engine/src/syntax/ast/node/operator/assign/mod.rs
  31. 3
      boa_engine/src/syntax/ast/node/operator/bin_op/mod.rs
  32. 3
      boa_engine/src/syntax/ast/node/operator/unary_op/mod.rs
  33. 6
      boa_engine/src/syntax/ast/node/parameters.rs
  34. 3
      boa_engine/src/syntax/ast/node/return_smt/mod.rs
  35. 3
      boa_engine/src/syntax/ast/node/spread/mod.rs
  36. 29
      boa_engine/src/syntax/ast/node/statement_list/mod.rs
  37. 5
      boa_engine/src/syntax/ast/node/switch/mod.rs
  38. 7
      boa_engine/src/syntax/ast/node/template/mod.rs
  39. 3
      boa_engine/src/syntax/ast/node/throw/mod.rs
  40. 7
      boa_engine/src/syntax/ast/node/try_node/mod.rs
  41. 3
      boa_engine/src/syntax/ast/node/yield/mod.rs
  42. 1
      boa_engine/src/vm/code_block.rs

3
boa_engine/src/syntax/ast/node/array/mod.rs

@ -1,7 +1,6 @@
//! Array declaration node. //! Array declaration node.
use super::{join_nodes, Node}; use super::{join_nodes, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -27,7 +26,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-ArrayLiteral /// [spec]: https://tc39.es/ecma262/#prod-ArrayLiteral
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ArrayDecl { pub struct ArrayDecl {
arr: Box<[Node]>, arr: Box<[Node]>,
has_trailing_comma_spread: bool, has_trailing_comma_spread: bool,

3
boa_engine/src/syntax/ast/node/await_expr/mod.rs

@ -1,7 +1,6 @@
//! Await expression node. //! Await expression node.
use super::Node; use super::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -20,7 +19,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-AwaitExpression /// [spec]: https://tc39.es/ecma262/#prod-AwaitExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct AwaitExpr { pub struct AwaitExpr {
expr: Box<Node>, expr: Box<Node>,
} }

3
boa_engine/src/syntax/ast/node/block/mod.rs

@ -1,7 +1,6 @@
//! Block AST node. //! Block AST node.
use super::{Node, StatementList}; use super::{Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -27,7 +26,7 @@ mod tests;
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "deser", serde(transparent))] #[cfg_attr(feature = "deser", serde(transparent))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Block { pub struct Block {
#[cfg_attr(feature = "deser", serde(flatten))] #[cfg_attr(feature = "deser", serde(flatten))]
statements: StatementList, statements: StatementList,

3
boa_engine/src/syntax/ast/node/call/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, Node}; use crate::syntax::ast::node::{join_nodes, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -23,7 +22,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-CallExpression /// [spec]: https://tc39.es/ecma262/#prod-CallExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Calling_functions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Calling_functions
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Call { pub struct Call {
expr: Box<Node>, expr: Box<Node>,
args: Box<[Node]>, args: Box<[Node]>,

3
boa_engine/src/syntax/ast/node/conditional/conditional_op/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -20,7 +19,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-ConditionalExpression /// [spec]: https://tc39.es/ecma262/#prod-ConditionalExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Literals /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Literals
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ConditionalOp { pub struct ConditionalOp {
condition: Box<Node>, condition: Box<Node>,
if_true: Box<Node>, if_true: Box<Node>,

3
boa_engine/src/syntax/ast/node/conditional/if_node/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -22,7 +21,7 @@ use serde::{Deserialize, Serialize};
/// [falsy]: https://developer.mozilla.org/en-US/docs/Glossary/falsy /// [falsy]: https://developer.mozilla.org/en-US/docs/Glossary/falsy
/// [expression]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions /// [expression]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct If { pub struct If {
cond: Box<Node>, cond: Box<Node>,
body: Box<Node>, body: Box<Node>,

3
boa_engine/src/syntax/ast/node/declaration/arrow_function_decl/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -19,7 +18,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-ArrowFunction /// [spec]: https://tc39.es/ecma262/#prod-ArrowFunction
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ArrowFunctionDecl { pub struct ArrowFunctionDecl {
name: Option<Sym>, name: Option<Sym>,
params: FormalParameterList, params: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/async_function_decl/mod.rs

@ -1,7 +1,6 @@
//! Async Function Declaration. //! Async Function Declaration.
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -16,7 +15,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#sec-async-function-prototype-properties /// [spec]: https://tc39.es/ecma262/#sec-async-function-prototype-properties
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct AsyncFunctionDecl { pub struct AsyncFunctionDecl {
name: Sym, name: Sym,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/async_function_expr/mod.rs

@ -1,7 +1,6 @@
//! Async Function Expression. //! Async Function Expression.
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -17,7 +16,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-AsyncFunctionExpression /// [spec]: https://tc39.es/ecma262/#prod-AsyncFunctionExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct AsyncFunctionExpr { pub struct AsyncFunctionExpr {
name: Option<Sym>, name: Option<Sym>,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/async_generator_decl/mod.rs

@ -1,7 +1,6 @@
//! Async Generator Declaration //! Async Generator Declaration
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -14,7 +13,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-AsyncGeneratorMethod /// [spec]: https://tc39.es/ecma262/#prod-AsyncGeneratorMethod
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct AsyncGeneratorDecl { pub struct AsyncGeneratorDecl {
name: Sym, name: Sym,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/async_generator_expr/mod.rs

@ -1,7 +1,6 @@
//! Async Generator Expression //! Async Generator Expression
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -16,7 +15,7 @@ use super::block_to_string;
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-AsyncGeneratorExpression /// [spec]: https://tc39.es/ecma262/#prod-AsyncGeneratorExpression
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct AsyncGeneratorExpr { pub struct AsyncGeneratorExpr {
name: Option<Sym>, name: Option<Sym>,
parameters: FormalParameterList, parameters: FormalParameterList,

5
boa_engine/src/syntax/ast/node/declaration/class_decl/mod.rs

@ -7,7 +7,6 @@ use crate::syntax::ast::node::{
object::{MethodDefinition, PropertyName}, object::{MethodDefinition, PropertyName},
Node, StatementList, Node, StatementList,
}; };
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -24,7 +23,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#sec-class-definitions /// [spec]: https://tc39.es/ecma262/#sec-class-definitions
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Class { pub struct Class {
name: Sym, name: Sym,
super_ref: Option<Box<Node>>, super_ref: Option<Box<Node>>,
@ -353,7 +352,7 @@ impl ToInternedString for Class {
/// Class element types. /// Class element types.
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum ClassElement { pub enum ClassElement {
MethodDefinition(PropertyName, MethodDefinition), MethodDefinition(PropertyName, MethodDefinition),
StaticMethodDefinition(PropertyName, MethodDefinition), StaticMethodDefinition(PropertyName, MethodDefinition),

3
boa_engine/src/syntax/ast/node/declaration/function_decl/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -24,7 +23,7 @@ use serde::{Deserialize, Serialize};
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function
/// [func_expr]: ../enum.Node.html#variant.FunctionExpr /// [func_expr]: ../enum.Node.html#variant.FunctionExpr
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct FunctionDecl { pub struct FunctionDecl {
name: Sym, name: Sym,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/function_expr/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -24,7 +23,7 @@ use super::block_to_string;
/// [spec]: https://tc39.es/ecma262/#sec-terms-and-definitions-function /// [spec]: https://tc39.es/ecma262/#sec-terms-and-definitions-function
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct FunctionExpr { pub struct FunctionExpr {
name: Option<Sym>, name: Option<Sym>,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/generator_decl/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -15,7 +14,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-GeneratorDeclaration /// [spec]: https://tc39.es/ecma262/#prod-GeneratorDeclaration
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function* /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct GeneratorDecl { pub struct GeneratorDecl {
name: Sym, name: Sym,
parameters: FormalParameterList, parameters: FormalParameterList,

3
boa_engine/src/syntax/ast/node/declaration/generator_expr/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList}; use crate::syntax::ast::node::{join_nodes, FormalParameterList, Node, StatementList};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -16,7 +15,7 @@ use super::block_to_string;
/// [spec]: https://tc39.es/ecma262/#prod-GeneratorExpression /// [spec]: https://tc39.es/ecma262/#prod-GeneratorExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function* /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function*
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct GeneratorExpr { pub struct GeneratorExpr {
name: Option<Sym>, name: Option<Sym>,
parameters: FormalParameterList, parameters: FormalParameterList,

15
boa_engine/src/syntax/ast/node/declaration/mod.rs

@ -6,7 +6,6 @@ use crate::syntax::ast::node::{
statement_list::StatementList, statement_list::StatementList,
Identifier, Node, Identifier, Node,
}; };
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -34,7 +33,7 @@ pub use self::{
mod tests; mod tests;
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum DeclarationList { pub enum DeclarationList {
/// The `const` statements are block-scoped, much like variables defined using the `let` /// The `const` statements are block-scoped, much like variables defined using the `let`
/// keyword. /// keyword.
@ -154,7 +153,7 @@ impl From<Declaration> for Box<[Declaration]> {
/// [spec2]: https://tc39.es/ecma262/#prod-VariableDeclaration /// [spec2]: https://tc39.es/ecma262/#prod-VariableDeclaration
/// [spec3]: https://tc39.es/ecma262/#sec-declarations-and-the-variable-statement /// [spec3]: https://tc39.es/ecma262/#sec-declarations-and-the-variable-statement
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum Declaration { pub enum Declaration {
Identifier { Identifier {
ident: Identifier, ident: Identifier,
@ -241,7 +240,7 @@ impl Declaration {
/// ///
/// [spec1]: https://tc39.es/ecma262/#prod-BindingPattern /// [spec1]: https://tc39.es/ecma262/#prod-BindingPattern
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum DeclarationPattern { pub enum DeclarationPattern {
Object(DeclarationPatternObject), Object(DeclarationPatternObject),
Array(DeclarationPatternArray), Array(DeclarationPatternArray),
@ -395,7 +394,7 @@ impl DeclarationPattern {
/// ///
/// [spec1]: https://tc39.es/ecma262/#prod-ObjectBindingPattern /// [spec1]: https://tc39.es/ecma262/#prod-ObjectBindingPattern
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct DeclarationPatternObject { pub struct DeclarationPatternObject {
bindings: Vec<BindingPatternTypeObject>, bindings: Vec<BindingPatternTypeObject>,
init: Option<Node>, init: Option<Node>,
@ -494,7 +493,7 @@ impl DeclarationPatternObject {
/// ///
/// [spec1]: https://tc39.es/ecma262/#prod-ArrayBindingPattern /// [spec1]: https://tc39.es/ecma262/#prod-ArrayBindingPattern
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct DeclarationPatternArray { pub struct DeclarationPatternArray {
bindings: Vec<BindingPatternTypeArray>, bindings: Vec<BindingPatternTypeArray>,
init: Option<Node>, init: Option<Node>,
@ -588,7 +587,7 @@ impl DeclarationPatternArray {
/// ///
/// [spec1]: https://tc39.es/ecma262/#prod-ObjectBindingPattern /// [spec1]: https://tc39.es/ecma262/#prod-ObjectBindingPattern
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum BindingPatternTypeObject { pub enum BindingPatternTypeObject {
/// Empty represents an empty object binding pattern e.g. `{ }`. /// Empty represents an empty object binding pattern e.g. `{ }`.
Empty, Empty,
@ -732,7 +731,7 @@ impl ToInternedString for BindingPatternTypeObject {
/// ///
/// [spec1]: https://tc39.es/ecma262/#prod-ArrayBindingPattern /// [spec1]: https://tc39.es/ecma262/#prod-ArrayBindingPattern
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum BindingPatternTypeArray { pub enum BindingPatternTypeArray {
/// Empty represents an empty array binding pattern e.g. `[ ]`. /// Empty represents an empty array binding pattern e.g. `[ ]`.
/// ///

3
boa_engine/src/syntax/ast/node/field/get_const_field/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -27,7 +26,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#sec-property-accessors /// [spec]: https://tc39.es/ecma262/#sec-property-accessors
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Dot_notation /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Dot_notation
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct GetConstField { pub struct GetConstField {
obj: Box<Node>, obj: Box<Node>,
field: Sym, field: Sym,

3
boa_engine/src/syntax/ast/node/field/get_field/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -28,7 +27,7 @@ use serde::{Deserialize, Serialize};
/// [symbol]: https://developer.mozilla.org/en-US/docs/Glossary/Symbol /// [symbol]: https://developer.mozilla.org/en-US/docs/Glossary/Symbol
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bracket_notation /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bracket_notation
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct GetField { pub struct GetField {
obj: Box<Node>, obj: Box<Node>,
field: Box<Node>, field: Box<Node>,

3
boa_engine/src/syntax/ast/node/field/get_private_field/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -17,7 +16,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-MemberExpression /// [spec]: https://tc39.es/ecma262/#prod-MemberExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct GetPrivateField { pub struct GetPrivateField {
obj: Box<Node>, obj: Box<Node>,
field: Sym, field: Sym,

3
boa_engine/src/syntax/ast/node/iteration/do_while_loop/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -18,7 +17,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#sec-do-while-statement /// [spec]: https://tc39.es/ecma262/#sec-do-while-statement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct DoWhileLoop { pub struct DoWhileLoop {
body: Box<Node>, body: Box<Node>,
cond: Box<Node>, cond: Box<Node>,

3
boa_engine/src/syntax/ast/node/iteration/for_in_loop/mod.rs

@ -1,12 +1,11 @@
use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node}; use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ForInLoop { pub struct ForInLoop {
init: Box<IterableLoopInitializer>, init: Box<IterableLoopInitializer>,
expr: Box<Node>, expr: Box<Node>,

5
boa_engine/src/syntax/ast/node/iteration/for_loop/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -17,7 +16,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-ForDeclaration /// [spec]: https://tc39.es/ecma262/#prod-ForDeclaration
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ForLoop { pub struct ForLoop {
#[cfg_attr(feature = "deser", serde(flatten))] #[cfg_attr(feature = "deser", serde(flatten))]
inner: Box<InnerForLoop>, inner: Box<InnerForLoop>,
@ -113,7 +112,7 @@ impl From<ForLoop> for Node {
/// Inner structure to avoid multiple indirections in the heap. /// Inner structure to avoid multiple indirections in the heap.
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
struct InnerForLoop { struct InnerForLoop {
init: Option<Node>, init: Option<Node>,
condition: Option<Node>, condition: Option<Node>,

3
boa_engine/src/syntax/ast/node/iteration/for_of_loop/mod.rs

@ -1,12 +1,11 @@
use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node}; use crate::syntax::ast::node::{iteration::IterableLoopInitializer, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct ForOfLoop { pub struct ForOfLoop {
init: Box<IterableLoopInitializer>, init: Box<IterableLoopInitializer>,
iterable: Box<Node>, iterable: Box<Node>,

3
boa_engine/src/syntax/ast/node/iteration/mod.rs

@ -7,7 +7,6 @@ pub use self::{
use crate::syntax::ast::node::{ use crate::syntax::ast::node::{
declaration::Declaration, identifier::Identifier, DeclarationPattern, declaration::Declaration, identifier::Identifier, DeclarationPattern,
}; };
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -17,7 +16,7 @@ use serde::{Deserialize, Serialize};
mod tests; mod tests;
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum IterableLoopInitializer { pub enum IterableLoopInitializer {
Identifier(Identifier), Identifier(Identifier),
Var(Declaration), Var(Declaration),

3
boa_engine/src/syntax/ast/node/iteration/while_loop/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -17,7 +16,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-grammar-notation-WhileStatement /// [spec]: https://tc39.es/ecma262/#prod-grammar-notation-WhileStatement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct WhileLoop { pub struct WhileLoop {
cond: Box<Node>, cond: Box<Node>,
body: Box<Node>, body: Box<Node>,

5
boa_engine/src/syntax/ast/node/mod.rs

@ -45,7 +45,7 @@ pub use self::{
r#yield::Yield, r#yield::Yield,
return_smt::Return, return_smt::Return,
spread::Spread, spread::Spread,
statement_list::{RcStatementList, StatementList}, statement_list::StatementList,
switch::{Case, Switch}, switch::{Case, Switch},
template::{TaggedTemplate, TemplateLit}, template::{TaggedTemplate, TemplateLit},
throw::Throw, throw::Throw,
@ -60,7 +60,6 @@ use self::{
pub(crate) use self::parameters::FormalParameterListFlags; pub(crate) use self::parameters::FormalParameterListFlags;
use super::Const; use super::Const;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use std::cmp::Ordering; use std::cmp::Ordering;
@ -70,7 +69,7 @@ use serde::{Deserialize, Serialize};
// TODO: This should be split into Expression and Statement. // TODO: This should be split into Expression and Statement.
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum Node { pub enum Node {
/// Array declaration node. [More information](./array/struct.ArrayDecl.html). /// Array declaration node. [More information](./array/struct.ArrayDecl.html).
ArrayDecl(ArrayDecl), ArrayDecl(ArrayDecl),

3
boa_engine/src/syntax/ast/node/new/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{Call, Node}; use crate::syntax::ast::node::{Call, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -24,7 +23,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-NewExpression /// [spec]: https://tc39.es/ecma262/#prod-NewExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct New { pub struct New {
call: Call, call: Call,
} }

19
boa_engine/src/syntax/ast/node/object/mod.rs

@ -7,7 +7,6 @@ use crate::syntax::ast::{
}, },
Const, Const,
}; };
use boa_gc::{unsafe_empty_trace, Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -37,7 +36,7 @@ mod tests;
/// [primitive]: https://developer.mozilla.org/en-US/docs/Glossary/primitive /// [primitive]: https://developer.mozilla.org/en-US/docs/Glossary/primitive
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "deser", serde(transparent))] #[cfg_attr(feature = "deser", serde(transparent))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Object { pub struct Object {
properties: Box<[PropertyDefinition]>, properties: Box<[PropertyDefinition]>,
} }
@ -158,7 +157,7 @@ impl From<Object> for Node {
/// [mdn]: https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript /// [mdn]: https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript
// TODO: Support all features: https://tc39.es/ecma262/#prod-PropertyDefinition // TODO: Support all features: https://tc39.es/ecma262/#prod-PropertyDefinition
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Trace, Finalize)] #[derive(Clone, Debug, PartialEq)]
pub enum PropertyDefinition { pub enum PropertyDefinition {
/// Puts a variable into an object. /// Puts a variable into an object.
/// ///
@ -248,7 +247,7 @@ impl PropertyDefinition {
/// [spec]: https://tc39.es/ecma262/#prod-MethodDefinition /// [spec]: https://tc39.es/ecma262/#prod-MethodDefinition
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Finalize, Trace)] #[derive(Clone, Debug, PartialEq)]
pub enum MethodDefinition { pub enum MethodDefinition {
/// The `get` syntax binds an object property to a function that will be called when that property is looked up. /// The `get` syntax binds an object property to a function that will be called when that property is looked up.
/// ///
@ -329,7 +328,7 @@ pub enum MethodDefinition {
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-PropertyName /// [spec]: https://tc39.es/ecma262/#prod-PropertyName
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Finalize)] #[derive(Clone, Debug, PartialEq)]
pub enum PropertyName { pub enum PropertyName {
/// A `Literal` property name can be either an identifier, a string or a numeric literal. /// A `Literal` property name can be either an identifier, a string or a numeric literal.
/// ///
@ -387,10 +386,6 @@ impl From<Node> for PropertyName {
} }
} }
unsafe impl Trace for PropertyName {
unsafe_empty_trace!();
}
/// `ClassElementName` can be either a property name or a private identifier. /// `ClassElementName` can be either a property name or a private identifier.
/// ///
/// More information: /// More information:
@ -398,12 +393,8 @@ unsafe impl Trace for PropertyName {
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-ClassElementName /// [spec]: https://tc39.es/ecma262/#prod-ClassElementName
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Finalize)] #[derive(Clone, Debug, PartialEq)]
pub(crate) enum ClassElementName { pub(crate) enum ClassElementName {
PropertyName(PropertyName), PropertyName(PropertyName),
PrivateIdentifier(Sym), PrivateIdentifier(Sym),
} }
unsafe impl Trace for ClassElementName {
unsafe_empty_trace!();
}

5
boa_engine/src/syntax/ast/node/operator/assign/mod.rs

@ -10,7 +10,6 @@ use crate::syntax::{
}, },
parser::RESERVED_IDENTIFIERS_STRICT, parser::RESERVED_IDENTIFIERS_STRICT,
}; };
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -28,7 +27,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-AssignmentExpression /// [spec]: https://tc39.es/ecma262/#prod-AssignmentExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Assign { pub struct Assign {
lhs: Box<AssignTarget>, lhs: Box<AssignTarget>,
rhs: Box<Node>, rhs: Box<Node>,
@ -81,7 +80,7 @@ impl From<Assign> for Node {
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-AssignmentExpression /// [spec]: https://tc39.es/ecma262/#prod-AssignmentExpression
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum AssignTarget { pub enum AssignTarget {
Identifier(Identifier), Identifier(Identifier),
GetPrivateField(GetPrivateField), GetPrivateField(GetPrivateField),

3
boa_engine/src/syntax/ast/node/operator/bin_op/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::{node::Node, op}; use crate::syntax::ast::{node::Node, op};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -12,7 +11,7 @@ use serde::{Deserialize, Serialize};
/// ///
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Operators /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Operators
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct BinOp { pub struct BinOp {
op: op::BinOp, op: op::BinOp,
lhs: Box<Node>, lhs: Box<Node>,

3
boa_engine/src/syntax/ast/node/operator/unary_op/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::{node::Node, op}; use crate::syntax::ast::{node::Node, op};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -14,7 +13,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-UnaryExpression /// [spec]: https://tc39.es/ecma262/#prod-UnaryExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Unary_operators /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Unary_operators
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct UnaryOp { pub struct UnaryOp {
op: op::UnaryOp, op: op::UnaryOp,
target: Box<Node>, target: Box<Node>,

6
boa_engine/src/syntax/ast/node/parameters.rs

@ -2,7 +2,6 @@ use crate::syntax::{ast::Position, parser::ParseError};
use super::{Declaration, DeclarationPattern, Node}; use super::{Declaration, DeclarationPattern, Node};
use bitflags::bitflags; use bitflags::bitflags;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -15,10 +14,9 @@ use serde::{Deserialize, Serialize};
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-FormalParameterList /// [spec]: https://tc39.es/ecma262/#prod-FormalParameterList
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Default, PartialEq, Trace, Finalize)] #[derive(Clone, Debug, Default, PartialEq)]
pub struct FormalParameterList { pub struct FormalParameterList {
pub(crate) parameters: Box<[FormalParameter]>, pub(crate) parameters: Box<[FormalParameter]>,
#[unsafe_ignore_trace]
pub(crate) flags: FormalParameterListFlags, pub(crate) flags: FormalParameterListFlags,
pub(crate) length: u32, pub(crate) length: u32,
} }
@ -163,7 +161,7 @@ impl Default for FormalParameterListFlags {
/// [spec]: https://tc39.es/ecma262/#prod-FormalParameter /// [spec]: https://tc39.es/ecma262/#prod-FormalParameter
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_formal_parameter
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Trace, Finalize)] #[derive(Clone, Debug, PartialEq)]
pub struct FormalParameter { pub struct FormalParameter {
declaration: Declaration, declaration: Declaration,
is_rest_param: bool, is_rest_param: bool,

3
boa_engine/src/syntax/ast/node/return_smt/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -27,7 +26,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-ReturnStatement /// [spec]: https://tc39.es/ecma262/#prod-ReturnStatement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Return { pub struct Return {
expr: Option<Box<Node>>, expr: Option<Box<Node>>,
label: Option<Sym>, label: Option<Sym>,

3
boa_engine/src/syntax/ast/node/spread/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -26,7 +25,7 @@ mod tests;
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "deser", serde(transparent))] #[cfg_attr(feature = "deser", serde(transparent))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Spread { pub struct Spread {
val: Box<Node>, val: Box<Node>,
} }

29
boa_engine/src/syntax/ast/node/statement_list/mod.rs

@ -1,9 +1,7 @@
//! Statement list node. //! Statement list node.
use crate::syntax::ast::node::{Declaration, Node}; use crate::syntax::ast::node::{Declaration, Node};
use boa_gc::{unsafe_empty_trace, Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
use std::{ops::Deref, rc::Rc};
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -21,7 +19,7 @@ mod tests;
/// ///
/// [spec]: https://tc39.es/ecma262/#prod-StatementList /// [spec]: https://tc39.es/ecma262/#prod-StatementList
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct StatementList { pub struct StatementList {
items: Box<[Node]>, items: Box<[Node]>,
strict: bool, strict: bool,
@ -192,28 +190,3 @@ impl ToInternedString for StatementList {
self.to_indented_string(interner, 0) self.to_indented_string(interner, 0)
} }
} }
// List of statements wrapped with Rc. We need this for self mutating functions.
// Since we need to cheaply clone the function body and drop the borrow of the function object to
// mutably borrow the function object and call this cloned function body
#[derive(Clone, Debug, Finalize, PartialEq)]
pub struct RcStatementList(Rc<StatementList>);
impl Deref for RcStatementList {
type Target = StatementList;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<StatementList> for RcStatementList {
#[inline]
fn from(statementlist: StatementList) -> Self {
Self(Rc::from(statementlist))
}
}
// SAFETY: This is safe for types not containing any `Trace` types.
unsafe impl Trace for RcStatementList {
unsafe_empty_trace!();
}

5
boa_engine/src/syntax/ast/node/switch/mod.rs

@ -1,7 +1,6 @@
//! Switch node. //! Switch node.
//! //!
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
use crate::syntax::ast::node::StatementList; use crate::syntax::ast::node::StatementList;
@ -13,7 +12,7 @@ use serde::{Deserialize, Serialize};
mod tests; mod tests;
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Case { pub struct Case {
condition: Node, condition: Node,
body: StatementList, body: StatementList,
@ -60,7 +59,7 @@ impl Case {
/// [spec]: https://tc39.es/ecma262/#prod-SwitchStatement /// [spec]: https://tc39.es/ecma262/#prod-SwitchStatement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Switch { pub struct Switch {
val: Box<Node>, val: Box<Node>,
cases: Box<[Case]>, cases: Box<[Case]>,

7
boa_engine/src/syntax/ast/node/template/mod.rs

@ -1,7 +1,6 @@
//! Template literal node. //! Template literal node.
use super::Node; use super::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, Sym, ToInternedString}; use boa_interner::{Interner, Sym, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -19,7 +18,7 @@ mod tests;
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
/// [spec]: https://tc39.es/ecma262/#sec-template-literals /// [spec]: https://tc39.es/ecma262/#sec-template-literals
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct TemplateLit { pub struct TemplateLit {
elements: Box<[TemplateElement]>, elements: Box<[TemplateElement]>,
} }
@ -57,7 +56,7 @@ impl ToInternedString for TemplateLit {
} }
} }
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct TaggedTemplate { pub struct TaggedTemplate {
tag: Box<Node>, tag: Box<Node>,
raws: Box<[Sym]>, raws: Box<[Sym]>,
@ -122,7 +121,7 @@ impl From<TaggedTemplate> for Node {
} }
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum TemplateElement { pub enum TemplateElement {
String(Sym), String(Sym),
Expr(Node), Expr(Node),

3
boa_engine/src/syntax/ast/node/throw/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -23,7 +22,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-ThrowStatement /// [spec]: https://tc39.es/ecma262/#prod-ThrowStatement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Throw { pub struct Throw {
expr: Box<Node>, expr: Box<Node>,
} }

7
boa_engine/src/syntax/ast/node/try_node/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::{Block, Declaration, Node}; use crate::syntax::ast::node::{Block, Declaration, Node};
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -22,7 +21,7 @@ mod tests;
/// [spec]: https://tc39.es/ecma262/#prod-TryStatement /// [spec]: https://tc39.es/ecma262/#prod-TryStatement
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Try { pub struct Try {
block: Block, block: Block,
catch: Option<Catch>, catch: Option<Catch>,
@ -103,7 +102,7 @@ impl From<Try> for Node {
/// Catch block. /// Catch block.
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Catch { pub struct Catch {
parameter: Option<Box<Declaration>>, parameter: Option<Box<Declaration>>,
block: Block, block: Block,
@ -156,7 +155,7 @@ impl ToInternedString for Catch {
/// Finally block. /// Finally block.
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Finally { pub struct Finally {
block: Block, block: Block,
} }

3
boa_engine/src/syntax/ast/node/yield/mod.rs

@ -1,5 +1,4 @@
use crate::syntax::ast::node::Node; use crate::syntax::ast::node::Node;
use boa_gc::{Finalize, Trace};
use boa_interner::{Interner, ToInternedString}; use boa_interner::{Interner, ToInternedString};
#[cfg(feature = "deser")] #[cfg(feature = "deser")]
@ -14,7 +13,7 @@ use serde::{Deserialize, Serialize};
/// [spec]: https://tc39.es/ecma262/#prod-YieldExpression /// [spec]: https://tc39.es/ecma262/#prod-YieldExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
#[cfg_attr(feature = "deser", derive(Serialize, Deserialize))] #[cfg_attr(feature = "deser", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, Trace, Finalize, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct Yield { pub struct Yield {
expr: Option<Box<Node>>, expr: Option<Box<Node>>,
delegate: bool, delegate: bool,

1
boa_engine/src/vm/code_block.rs

@ -69,6 +69,7 @@ pub struct CodeBlock {
pub(crate) this_mode: ThisMode, pub(crate) this_mode: ThisMode,
/// Parameters passed to this function. /// Parameters passed to this function.
#[unsafe_ignore_trace]
pub(crate) params: FormalParameterList, pub(crate) params: FormalParameterList,
/// Bytecode /// Bytecode

Loading…
Cancel
Save