public override void OnSlicingExpression(SlicingExpression node)
        {
            base.OnSlicingExpression(node);

            if (!node.IsComplexSlicing())
                return;

            if (node.IsTargetOfAssignment())
                return;

            CompleteOmittedExpressions(node);
            ExpandComplexSlicing(node);
        }
예제 #2
0
        public override void LeaveSlicingExpression(SlicingExpression node)
        {
            if (node.Target.Entity.IsAmbiguous())
            {
                BindIndexedPropertySlicing(node);
                return;
            }

            // target[indices]
            var targetType = GetExpressionType(node.Target);
            if (IsError(targetType))
            {
                Error(node);
                return;
            }

            if (node.IsComplexSlicing())
            {
                BindExpressionType(node, ResultingTypeForComplexSlicing(node));
                return;
            }

            if (IsIndexedProperty(node.Target))
            {
                BindIndexedPropertySlicing(node);
                return;
            }

            if (targetType.IsArray)
            {
                BindExpressionType(node, targetType.ElementType);
                return;
            }

            var member = TypeSystemServices.GetDefaultMember(targetType);
            if (member == null)
            {
                Error(node, CompilerErrorFactory.TypeDoesNotSupportSlicing(node.Target, targetType));
                return;
            }

            node.Target = new MemberReferenceExpression(node.LexicalInfo, node.Target, member.Name)
                            {
                                Entity = member,
                                ExpressionType = Null.Default // to be resolved later
                            };
            SliceMember(node, member);
        }
예제 #3
0
 void AssertIsNotComplexSlicing(SlicingExpression node)
 {
     if (node.IsComplexSlicing())
         NotImplemented(node, "complex slicing");
 }