/// <summary> /// Initializes a new instance of the <see cref="UnaryOperatorNode"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="argument">The argument.</param> protected UnaryOperatorNode(NodeTypes type, Node argument) : base(type) { Argument = argument.ThrowIfNull(nameof(argument)); if ((Argument.Properties & NodeProperties.Constant) != 0) { Properties = NodeProperties.Constant; } }
/// <summary> /// Initializes a new instance of the <see cref="BinaryOperatorNode"/> class. /// </summary> /// <param name="type">The node type.</param> /// <param name="left">The left argument.</param> /// <param name="right">The right argument.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="left"/> or <paramref name="right"/> is <c>null</c>.</exception> protected BinaryOperatorNode(NodeTypes type, Node left, Node right) : base(type) { Left = left.ThrowIfNull(nameof(left)); Right = right.ThrowIfNull(nameof(right)); // If both are constant, the result is also constant if ((Left.Properties & NodeProperties.Constant) != 0 && (Right.Properties & NodeProperties.Constant) != 0) { Properties |= NodeProperties.Constant; } }
/// <summary> /// Initializes a new instance of the <see cref="TernaryOperatorNode"/> class. /// </summary> /// <param name="type">The type.</param> /// <param name="condition">The condition.</param> /// <param name="ifTrue">If true.</param> /// <param name="ifFalse">If false.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="condition"/>, <paramref name="ifTrue"/> or <paramref name="ifFalse"/> is <c>null</c>.</exception> protected TernaryOperatorNode(NodeTypes type, Node condition, Node ifTrue, Node ifFalse) : base(type) { Condition = condition.ThrowIfNull(nameof(condition)); IfTrue = ifTrue.ThrowIfNull(nameof(ifTrue)); IfFalse = ifFalse.ThrowIfNull(nameof(ifFalse)); if (((Condition.Properties & NodeProperties.Constant) != 0) && ((IfTrue.Properties & NodeProperties.Constant) != 0) && ((IfFalse.Properties & NodeProperties.Constant) != 0)) { Properties = NodeProperties.Constant; } }