Ejemplo n.º 1
0
        /// <summary>
        ///     Construct an <see cref="LSLPostfixOperationNode" /> from a given <see cref="ILSLExprNode" /> and
        ///     <see cref="LSLPostfixOperationType" />.
        /// </summary>
        /// <param name="resultType">The return type of the postfix operation on the given expression.</param>
        /// <param name="rightExpression">The expression the postfix operation occurs on.</param>
        /// <param name="operationType">The postfix operation type.</param>
        /// <exception cref="ArgumentNullException"><paramref name="rightExpression" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="operationType" /> is <see cref="LSLPrefixOperationType.Error" />.</exception>
        public LSLPrefixOperationNode(LSLType resultType, LSLPrefixOperationType operationType,
                                      ILSLExprNode rightExpression)
        {
            if (rightExpression == null)
            {
                throw new ArgumentNullException("rightExpression");
            }

            if (operationType == LSLPrefixOperationType.Error)
            {
                throw new ArgumentException("operationType cannot be LSLPrefixOperationType.Error.");
            }

            Type                   = resultType;
            RightExpression        = rightExpression;
            RightExpression.Parent = this;

            Operation       = operationType;
            OperationString = Operation.ToOperatorString();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Validates and returns the type resulting from a prefix operation.
        /// </summary>
        /// <param name="right">The expression to preform the prefix operation on.</param>
        /// <param name="operation">The prefix operation preformed.</param>
        /// <returns>An <see cref="LSLExpressionValidatorResult" /> object</returns>
        /// <exception cref="ArgumentNullException"><paramref name="right"/> is <c>null</c>.</exception>
        public LSLExpressionValidatorResult ValidatePrefixOperation(LSLPrefixOperationType operation, ILSLReadOnlyExprNode right)
        {
            if (right == null)
            {
                throw new ArgumentNullException("right");
            }

            if (right.HasErrors)
            {
                return(LSLExpressionValidatorResult.Error);
            }

            LSLType t;

            if (_operations.TryGetValue(operation.ToOperatorString() + right.Type, out t))
            {
                return(new LSLExpressionValidatorResult(t, true));
            }

            return(LSLExpressionValidatorResult.Error);
        }
Ejemplo n.º 3
0
 private void AddPrefixOperation(LSLPrefixOperationType operation, LSLType right, LSLType result)
 {
     _operations.Add(operation.ToOperatorString() + right, result);
 }