Esempio n. 1
0
 void ILSLSyntaxErrorListener.InvalidPrefixOperationUsedInStaticContext(LSLSourceCodeRange location,
                                                                        LSLPrefixOperationType type)
 {
     _errorActionQueue.Enqueue(location.StartIndex,
                               () =>
                               SyntaxErrorListener.InvalidPrefixOperationUsedInStaticContext(location, type));
 }
Esempio n. 2
0
 void ILSLSyntaxErrorListener.PrefixOperationOnGlobalVariableInStaticContext(LSLSourceCodeRange location,
                                                                             LSLPrefixOperationType type)
 {
     _errorActionQueue.Enqueue(location.StartIndex,
                               () =>
                               SyntaxErrorListener.PrefixOperationOnGlobalVariableInStaticContext(location, type));
 }
Esempio n. 3
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();
        }
Esempio n. 4
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);
        }
        /// <summary>
        ///     Converts the provided <see cref="LSLPrefixOperationType" /> to its source code string representation.
        /// </summary>
        /// <param name="type">The <see cref="LSLPrefixOperationType" /> to convert to a string.</param>
        /// <exception cref="ArgumentException">
        ///     Thrown if the <see cref="LSLPrefixOperationType" /> provided was equal to
        ///     <see cref="LSLPrefixOperationType.Error" />.
        /// </exception>
        /// <returns>The source code string representation of the <see cref="LSLPrefixOperationType" />.</returns>
        public static string ToOperatorString(this LSLPrefixOperationType type)
        {
            switch (type)
            {
            case LSLPrefixOperationType.Decrement:
                return("--");

            case LSLPrefixOperationType.Increment:
                return("++");

            case LSLPrefixOperationType.Negate:
                return("-");

            case LSLPrefixOperationType.BooleanNot:
                return("!");

            case LSLPrefixOperationType.BitwiseNot:
                return("~");
            }

            throw new ArgumentException(
                      string.Format("Could not convert LSLPrefixOperationType.{0} enum value to operator string", type),
                      "type");
        }
 /// <summary>
 ///     Determines whether the given prefix operation is a modifying operation.
 ///     Currently only <see cref="LSLPrefixOperationType.Decrement" /> and <see cref="LSLPrefixOperationType.Increment" />
 ///     are considered modifying operations.
 /// </summary>
 /// <param name="type">If the prefix operation modifies the expression to its right.</param>
 /// <returns><c>true</c> if <paramref name="type"/> is <see cref="LSLPrefixOperationType.Decrement" /> or <see cref="LSLPrefixOperationType.Increment" />.</returns>
 public static bool IsModifying(this LSLPrefixOperationType type)
 {
     return(type == LSLPrefixOperationType.Decrement || type == LSLPrefixOperationType.Increment);
 }
Esempio n. 7
0
 private void AddPrefixOperation(LSLPrefixOperationType operation, LSLType right, LSLType result)
 {
     _operations.Add(operation.ToOperatorString() + right, result);
 }
Esempio n. 8
0
 void ILSLSyntaxErrorListener.ModifyingPrefixOperationOnNonVariable(LSLSourceCodeRange location,
                                                                    LSLPrefixOperationType type)
 {
     _errorActionQueue.Enqueue(location.StartIndex,
                               () => SyntaxErrorListener.ModifyingPrefixOperationOnNonVariable(location, type));
 }