From d45e33da78bcd48a8e88ca6d25384a5a4f822b98 Mon Sep 17 00:00:00 2001 From: HalidOdat Date: Wed, 1 Apr 2020 10:41:01 +0200 Subject: [PATCH] Added documentation to AssignOp --- boa/src/syntax/ast/op.rs | 130 ++++++++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 14 deletions(-) diff --git a/boa/src/syntax/ast/op.rs b/boa/src/syntax/ast/op.rs index 270c7354bd..321f72a135 100644 --- a/boa/src/syntax/ast/op.rs +++ b/boa/src/syntax/ast/op.rs @@ -636,34 +636,136 @@ impl Display for BinOp { } } -/// A binary operation between 2 values +/// 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 +/// left operand. That is, `x = y` assigns the value of `y to x`. /// -/// +/// There are also compound assignment operators that are shorthand for the operations +/// +/// More information: +/// - ECMAScript reference: . +/// - MDN documentation: +/// #[cfg_attr(feature = "serde-ast", derive(Serialize, Deserialize))] #[derive(Clone, Debug, Trace, Finalize, PartialEq)] pub enum AssignOp { - /// `a += b` - Add assign + /// The addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable. + /// + /// Syntax: `x += y` + /// + /// The types of the two operands determine the behavior of the addition assignment operator. Addition or concatenation is possible. + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Add, - /// `a -= b` - Sub assign + + /// The subtraction assignment operator subtracts the value of the right operand from a variable and assigns the result to the variable. + /// + /// Syntax: `x -= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Sub, - /// `a *= b` - Mul assign + + /// The multiplication assignment operator multiplies a variable by the value of the right operand and assigns the result to the variable. + /// + /// Syntax: `x *= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Mul, - /// `a **= b` - Exponent assign - Exp, - /// `a /= b` - Div assign + + /// The division assignment operator divides a variable by the value of the right operand and assigns the result to the variable. + /// + /// Syntax: `x /= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Div, - /// `a %= b` - Modulus assign + + /// The remainder assignment operator divides a variable by the value of the right operand and assigns the remainder to the variable. + /// + /// Syntax: `x %= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Mod, - /// `a &= b` - Bitwise and assign + + /// The exponentiation assignment operator raises the value of a variable to the power of the right operand. + /// + /// Syntax: `x ** y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// + Exp, + + /// The bitwise AND assignment operator uses the binary representation of both operands, does a bitwise AND operation on + /// them and assigns the result to the variable. + /// + /// Syntax: `x &= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// And, - /// `a |= b` - Bitwise or assign + + /// The bitwise OR assignment operator uses the binary representation of both operands, does a bitwise OR operation on + /// them and assigns the result to the variable. + /// + /// Syntax: `x |= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Or, - /// `a ^= b` - Bitwise xor assign + + /// The bitwise XOR assignment operator uses the binary representation of both operands, does a bitwise XOR operation on + /// them and assigns the result to the variable. + /// + /// Syntax: `x ^= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Xor, - /// `a <<= b` - Left shift assign + + /// The left shift assignment operator moves the specified amount of bits to the left and assigns the result to the variable. + /// + /// Syntax: `x <<= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Shl, - /// `a >>= b` - Right shift assign + + /// The right shift assignment operator moves the specified amount of bits to the right and assigns the result to the variable. + /// + /// Syntax: `x >>= y` + /// + /// More information: + /// - ECMAScript reference: . + /// - MDN documentation: + /// Shr, + + // TODO: Add UShl (unsigned shift left). } impl Display for AssignOp {