|
@@ -1,6 +1,8 @@
|
|
|
import TempNode from '../core/TempNode.js';
|
|
import TempNode from '../core/TempNode.js';
|
|
|
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
|
|
|
|
|
|
|
|
|
|
+/** @module OperatorNode **/
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* This node represents basic mathematical and logical operations like addition,
|
|
* This node represents basic mathematical and logical operations like addition,
|
|
|
* subtraction or comparisons (e.g. `equal()`).
|
|
* subtraction or comparisons (e.g. `equal()`).
|
|
@@ -303,26 +305,218 @@ class OperatorNode extends TempNode {
|
|
|
|
|
|
|
|
export default OperatorNode;
|
|
export default OperatorNode;
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Returns the addition of two or more value.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @param {...Node} params - Additional input parameters.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' );
|
|
export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Returns the subraction of two or more value.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @param {...Node} params - Additional input parameters.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' );
|
|
export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Returns the multiplication of two or more value.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @param {...Node} params - Additional input parameters.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' );
|
|
export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Returns the division of two or more value.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @param {...Node} params - Additional input parameters.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' );
|
|
export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Computes the remainder of dividing the first node by the second, for integer values.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const modInt = /*@__PURE__*/ nodeProxy( OperatorNode, '%' );
|
|
export const modInt = /*@__PURE__*/ nodeProxy( OperatorNode, '%' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if two nodes are equal.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' );
|
|
export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if two nodes are not equal.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' );
|
|
export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if the first node is less than the second.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' );
|
|
export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if the first node is greater than the second.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' );
|
|
export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if the first node is less than or equal to the second.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' );
|
|
export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Checks if the first node is greater than or equal to the second.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' );
|
|
export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs logical AND on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' );
|
|
export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs logical OR on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' );
|
|
export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs logical NOT on a node.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' );
|
|
export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs logical XOR on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' );
|
|
export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs bitwise AND on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' );
|
|
export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs bitwise NOT on a node.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' );
|
|
export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs bitwise OR on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' );
|
|
export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Performs bitwise XOR on two nodes.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The first input.
|
|
|
|
|
+ * @param {Node} bNode - The second input.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' );
|
|
export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Shifts a node to the left.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The node to shift.
|
|
|
|
|
+ * @param {Node} bNode - The value to shift.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' );
|
|
export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' );
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * Shifts a node to the right.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @function
|
|
|
|
|
+ * @param {Node} aNode - The node to shift.
|
|
|
|
|
+ * @param {Node} bNode - The value to shift.
|
|
|
|
|
+ * @returns {OperatorNode}
|
|
|
|
|
+ */
|
|
|
export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
|
|
export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
|
|
|
|
|
|
|
|
addMethodChaining( 'add', add );
|
|
addMethodChaining( 'add', add );
|