import DataType from "../../../../parser/simple/DataType.js";
import { ReactiveBinaryExpression } from "../ReactiveBinaryExpression.js";

export class ReactiveSubtract extends ReactiveBinaryExpression {
    /**
     *
     * @param {number} left
     * @param {number} right
     * @returns {number}
     */
    transform(left, right) {
        return left - right;
    }

    /**
     *
     * @return {ReactiveSubtract}
     */
    clone() {
        const r = new ReactiveSubtract();

        r.copy(this);

        return r;
    }

    equals(other) {
        return (other.isReactiveSubtract === true) && super.equals(other);
    }

    toCode() {
        return `( ${this.left.toCode()} - ${this.right.toCode()} )`
    }


    /**
     *
     * @param {ReactiveExpression} left
     * @param {ReactiveExpression} right
     * @returns {ReactiveSubtract}
     */
    static from(left, right) {
        const r = new ReactiveSubtract();

        r.connect(left, right);

        return r;
    }

}

/**
 * @readonly
 * @type {DataType|string}
 */
ReactiveSubtract.prototype.dataType = DataType.Number;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveSubtract.prototype.isArithmeticExpression = true;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveSubtract.prototype.isReactiveSubtract = true;

