/// <summary>
        /// Initializes a new instance of the StackallocExpression class.
        /// </summary>
        /// <param name="proxy">Proxy object for the expression.</param>
        /// <param name="type">The array type.</param>
        internal StackallocExpression(CodeUnitProxy proxy, ArrayAccessExpression type)
            : base(proxy, ExpressionType.Stackalloc)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.AssertNotNull(type, "type");

            this.type.Value = type;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the StackallocExpression class.
        /// </summary>
        /// <param name="proxy">Proxy object for the expression.</param>
        /// <param name="type">The array type.</param>
        internal StackallocExpression(CodeUnitProxy proxy, ArrayAccessExpression type)
            : base(proxy, ExpressionType.Stackalloc)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.AssertNotNull(type, "type");

            this.type.Value = type;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the NewArrayExpression class.
        /// </summary>
        /// <param name="proxy">Proxy object for the expression.</param>
        /// <param name="type">The array type.</param>
        /// <param name="initializer">The array initializer expression.</param>
        internal NewArrayExpression(
            CodeUnitProxy proxy, ArrayAccessExpression type, ArrayInitializerExpression initializer)
            : base(proxy, ExpressionType.NewArray)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.Ignore(type, "type");
            Param.Ignore(initializer);

            this.type.Value        = type;
            this.initializer.Value = initializer;
        }
        /// <summary>
        /// Reads an array access expression.
        /// </summary>
        /// <param name="expressionProxy">Proxy object for the expression being created.</param>
        /// <param name="array">The array being accessed.</param>
        /// <param name="previousPrecedence">The precedence of the previous expression.</param>
        /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param>
        /// <returns>Returns the expression.</returns>
        private ArrayAccessExpression GetArrayAccessExpression(
            CodeUnitProxy expressionProxy, Expression array, ExpressionPrecedence previousPrecedence, bool unsafeCode)
        {
            Param.AssertNotNull(expressionProxy, "expressionProxy");
            Param.AssertNotNull(array, "array");
            Param.Ignore(previousPrecedence);
            Param.Ignore(unsafeCode);

            ArrayAccessExpression expression = null;

            if (CheckPrecedence(previousPrecedence, ExpressionPrecedence.Primary))
            {
                // The next symbol will be the opening bracket.
                BracketToken openingBracket = (BracketToken)this.GetToken(expressionProxy, TokenType.OpenSquareBracket, SymbolType.OpenSquareBracket);

                // Get the argument list now.
                this.GetArgumentList(expressionProxy, SymbolType.CloseSquareBracket, unsafeCode);

                // Get the closing bracket.
                BracketToken closingBracket = (BracketToken)this.GetToken(expressionProxy, TokenType.CloseSquareBracket, SymbolType.CloseSquareBracket);

                openingBracket.MatchingBracket = closingBracket;
                closingBracket.MatchingBracket = openingBracket;

                // Create and return the expression.
                expression = new ArrayAccessExpression(expressionProxy, array);
            }

            return expression;
        }