internal NewArrayExpression(CsTokenList tokens, ArrayAccessExpression type, ArrayInitializerExpression initializer)
     : base(ExpressionType.NewArray, tokens)
 {
     this.type = type;
     this.initializer = initializer;
     if (type != null)
     {
         base.AddExpression(type);
     }
     if (initializer != null)
     {
         base.AddExpression(initializer);
     }
 }
        /// <summary>
        /// Initializes a new instance of the NewArrayExpression class.
        /// </summary>
        /// <param name="tokens">The list of tokens that form the expression.</param>
        /// <param name="type">The array type.</param>
        /// <param name="initializer">The array initializer expression.</param>
        internal NewArrayExpression(
            CsTokenList tokens, ArrayAccessExpression type, ArrayInitializerExpression initializer)
            : base(ExpressionType.NewArray, tokens)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.Ignore(type, "type");
            Param.Ignore(initializer);

            this.type = type;
            this.initializer = initializer;

            if (type != null)
            {
                this.AddExpression(type);
            }

            if (initializer != null)
            {
                this.AddExpression(initializer);
            }
        }
        /// <summary>
        /// Reads an array access expression.
        /// </summary>
        /// <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(
            Expression array, ExpressionPrecedence previousPrecedence, bool unsafeCode)
        {
            Param.AssertNotNull(array, "array");
            Param.Ignore(previousPrecedence);
            Param.Ignore(unsafeCode);

            ArrayAccessExpression expression = null;

            if (CheckPrecedence(previousPrecedence, ExpressionPrecedence.Primary))
            {
                var expressionReference = new Reference<ICodePart>();

                // The next symbol will be the opening bracket.
                Bracket openingBracket = this.GetBracketToken(CsTokenType.OpenSquareBracket, SymbolType.OpenSquareBracket, expressionReference);
                Node<CsToken> openingBracketNode = this.tokens.InsertLast(openingBracket);

                // Get the argument list now.
                ICollection<Argument> argumentList = this.GetArgumentList(SymbolType.CloseSquareBracket, expressionReference, unsafeCode);

                // Get the closing bracket.
                Bracket closingBracket = this.GetBracketToken(CsTokenType.CloseSquareBracket, SymbolType.CloseSquareBracket, expressionReference);
                Node<CsToken> closingBracketNode = this.tokens.InsertLast(closingBracket);

                openingBracket.MatchingBracketNode = closingBracketNode;
                closingBracket.MatchingBracketNode = openingBracketNode;

                // Pull out the first token from the array.
                Node<CsToken> firstTokenNode = array.Tokens.First;

                // Create the token list for the method invocation expression.
                CsTokenList partialTokens = new CsTokenList(this.tokens, firstTokenNode, this.tokens.Last);

                // Create and return the expression.
                expression = new ArrayAccessExpression(partialTokens, array, argumentList);
                expressionReference.Target = expression;
            }

            return expression;
        }
 private ArrayAccessExpression GetArrayAccessExpression(Expression array, ExpressionPrecedence previousPrecedence, bool unsafeCode)
 {
     ArrayAccessExpression expression = null;
     if (CheckPrecedence(previousPrecedence, ExpressionPrecedence.Primary))
     {
         Bracket bracketToken = this.GetBracketToken(CsTokenType.OpenSquareBracket, SymbolType.OpenSquareBracket);
         Microsoft.StyleCop.Node<CsToken> node = this.tokens.InsertLast(bracketToken);
         ICollection<Expression> argumentList = this.GetArgumentList(SymbolType.CloseSquareBracket, unsafeCode);
         Bracket item = this.GetBracketToken(CsTokenType.CloseSquareBracket, SymbolType.CloseSquareBracket);
         Microsoft.StyleCop.Node<CsToken> node2 = this.tokens.InsertLast(item);
         bracketToken.MatchingBracketNode = node2;
         item.MatchingBracketNode = node;
         Microsoft.StyleCop.Node<CsToken> first = array.Tokens.First;
         CsTokenList tokens = new CsTokenList(this.tokens, first, this.tokens.Last);
         expression = new ArrayAccessExpression(tokens, array, argumentList);
     }
     return expression;
 }
 internal StackallocExpression(CsTokenList tokens, ArrayAccessExpression type)
     : base(ExpressionType.Stackalloc, tokens)
 {
     this.type = type;
     base.AddExpression(type);
 }