@ -1,6 +1,5 @@
//! This module implements various structure for logic handling.
use boa_gc ::{ unsafe_empty_trace , Finalize , Trace } ;
use std ::fmt ::{ Display , Formatter , Result } ;
#[ cfg(feature = " deser " ) ]
@ -14,7 +13,7 @@ use serde::{Deserialize, Serialize};
///
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Arithmetic
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum NumOp {
/// The addition operator produces the sum of numeric operands or string concatenation.
///
@ -115,10 +114,6 @@ impl Display for NumOp {
}
}
unsafe impl Trace for NumOp {
unsafe_empty_trace ! ( ) ;
}
/// A unary operator is one that takes a single operand/argument and performs an operation.
///
/// A unary operation is an operation with only one operand. This operand comes either
@ -132,7 +127,7 @@ unsafe impl Trace for NumOp {
/// [spec]: https://tc39.es/ecma262/#prod-UnaryExpression
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Unary
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum UnaryOp {
/// The increment operator increments (adds one to) its operand and returns a value.
///
@ -334,10 +329,6 @@ impl Display for UnaryOp {
}
}
unsafe impl Trace for UnaryOp {
unsafe_empty_trace ! ( ) ;
}
/// A bitwise operator is an operator used to perform bitwise operations
/// on bit patterns or binary numerals that involve the manipulation of individual bits.
///
@ -346,7 +337,7 @@ unsafe impl Trace for UnaryOp {
///
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Bitwise
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum BitOp {
/// Performs the AND operation on each pair of bits. a AND b yields 1 only if both a and b are 1.
///
@ -452,10 +443,6 @@ impl Display for BitOp {
}
}
unsafe impl Trace for BitOp {
unsafe_empty_trace ! ( ) ;
}
/// A comparison operator compares its operands and returns a logical value based on whether the comparison is true.
///
/// The operands can be numerical, string, logical, or object values. Strings are compared based on standard
@ -472,7 +459,7 @@ unsafe impl Trace for BitOp {
/// [spec]: tc39.es/ecma262/#sec-testing-and-comparison-operations
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Comparison
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum CompOp {
/// The equality operator converts the operands if they are not of the same type, then applies
/// strict comparison.
@ -652,10 +639,6 @@ impl Display for CompOp {
}
}
unsafe impl Trace for CompOp {
unsafe_empty_trace ! ( ) ;
}
/// Logical operators are typically used with Boolean (logical) values; when they are, they return a Boolean value.
///
/// However, the `&&` and `||` operators actually return the value of one of the specified operands,
@ -668,7 +651,7 @@ unsafe impl Trace for CompOp {
/// [spec]: https://tc39.es/ecma262/#sec-binary-logical-operators
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum LogOp {
/// The logical AND operator returns the value of the first operand if it can be coerced into `false`;
/// otherwise, it returns the second operand.
@ -727,13 +710,9 @@ impl Display for LogOp {
}
}
unsafe impl Trace for LogOp {
unsafe_empty_trace ! ( ) ;
}
/// This represents a binary operation between two values.
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum BinOp {
/// Numeric operation.
///
@ -814,10 +793,6 @@ impl Display for BinOp {
}
}
unsafe impl Trace for BinOp {
unsafe_empty_trace ! ( ) ;
}
/// An assignment operator assigns a value to its left operand based on the value of its right operand.
///
/// The simple assignment operator is equal (`=`), which assigns the value of its right operand to its
@ -832,7 +807,7 @@ unsafe impl Trace for BinOp {
/// [spec]: https://tc39.es/ecma262/#prod-AssignmentOperator
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Assignment
#[ cfg_attr(feature = " deser " , derive(Serialize, Deserialize)) ]
#[ derive(Clone, Copy, Debug, Finalize, PartialEq, Eq) ]
#[ derive(Clone, Copy, Debug, PartialEq, Eq) ]
pub enum AssignOp {
/// The addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable.
///
@ -1020,10 +995,6 @@ pub enum AssignOp {
Coalesce ,
}
unsafe impl Trace for AssignOp {
unsafe_empty_trace ! ( ) ;
}
impl AssignOp {
/// Retrieves the operation as a static string.
fn as_str ( self ) -> & ' static str {