public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node)
        {
            BoundExpression rewrittenExpression = LowerReceiverOfPointerElementAccess(node.Expression);
            BoundExpression rewrittenIndex      = VisitExpression(node.Index);

            return(RewritePointerElementAccess(node, rewrittenExpression, rewrittenIndex));
        }
示例#2
0
        public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node)
        {
            BoundExpression rewrittenExpression = VisitExpression(node.Expression);
            BoundExpression rewrittenIndex      = VisitExpression(node.Index);

            // Optimization: p[0] == *p
            if (rewrittenIndex.IsDefaultValue())
            {
                return(new BoundPointerIndirectionOperator(
                           node.Syntax,
                           rewrittenExpression,
                           node.Type));
            }

            BinaryOperatorKind additionKind = BinaryOperatorKind.Addition;

            switch (rewrittenIndex.Type.SpecialType)
            {
            case SpecialType.System_Int32:
                additionKind |= BinaryOperatorKind.PointerAndIntAddition;
                break;

            case SpecialType.System_UInt32:
                additionKind |= BinaryOperatorKind.PointerAndUIntAddition;
                break;

            case SpecialType.System_Int64:
                additionKind |= BinaryOperatorKind.PointerAndLongAddition;
                break;

            case SpecialType.System_UInt64:
                additionKind |= BinaryOperatorKind.PointerAndULongAddition;
                break;

            default:
                throw ExceptionUtilities.UnexpectedValue(rewrittenIndex.Type.SpecialType);
            }

            if (node.Checked)
            {
                additionKind |= BinaryOperatorKind.Checked;
            }

            return(new BoundPointerIndirectionOperator(
                       node.Syntax,
                       MakeBinaryOperator(
                           node.Syntax,
                           additionKind,
                           rewrittenExpression,
                           rewrittenIndex,
                           rewrittenExpression.Type,
                           method: null,
                           isPointerElementAccess: true), //see RewriterPointerNumericOperator
                       node.Type));
        }
        private BoundExpression RewritePointerElementAccess(BoundPointerElementAccess node, BoundExpression rewrittenExpression, BoundExpression rewrittenIndex)
        {
            // Optimization: p[0] == *p
            if (rewrittenIndex.IsDefaultValue())
            {
                return(new BoundPointerIndirectionOperator(
                           node.Syntax,
                           rewrittenExpression,
                           node.Type));
            }

            BinaryOperatorKind additionKind = BinaryOperatorKind.Addition;

            Debug.Assert(rewrittenExpression.Type is { });
示例#4
0
        public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node)
        {
            BoundSpillSequenceBuilder builder = null;
            var             index             = VisitExpression(ref builder, node.Index);
            BoundExpression expression;

            if (builder == null)
            {
                expression = VisitExpression(ref builder, node.Expression);
            }
            else
            {
                var expressionBuilder = new BoundSpillSequenceBuilder();
                expression = VisitExpression(ref expressionBuilder, node.Expression);
                expression = Spill(expressionBuilder, expression);
                expressionBuilder.Include(builder);
                builder = expressionBuilder;
            }

            return(UpdateExpression(builder, node.Update(expression, index, node.Checked, node.Type)));
        }
示例#5
0
        public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node)
        {
            BoundSpillSequence2 ss = null;
            var             index  = VisitExpression(ref ss, node.Index);
            BoundExpression expression;

            if (ss == null)
            {
                expression = VisitExpression(ref ss, node.Expression);
            }
            else
            {
                // if the right-hand-side has await, spill the left
                var ss2 = new BoundSpillSequence2();
                expression = VisitExpression(ref ss2, node.Expression);
                expression = Spill(ss2, expression);
                ss2.IncludeSequence(ss);
                ss = ss2;
            }

            return(UpdateExpression(ss, node.Update(expression, index, node.Checked, node.Type)));
        }
示例#6
0
 public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess node)
 {
     NoteUnsafe(node);
     return(base.VisitPointerElementAccess(node));
 }
 private static BoundExpression VisitPointerElementAccess(BoundPointerElementAccess node)
 {
     // error should have been reported earlier
     // Diagnostics.Add(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node.Syntax.Location);
     return(new BoundBadExpression(node.Syntax, default(LookupResultKind), ImmutableArray <Symbol> .Empty, ImmutableArray.Create <BoundExpression>(node), node.Type));
 }