private BoundExpression Indices(ImmutableArray <BoundExpression> expressions)
        {
            var builder = ArrayBuilder <BoundExpression> .GetInstance();

            foreach (var arg in expressions)
            {
                var index = Visit(arg);
                if (!TypeSymbol.Equals(index.Type, _int32Type, TypeCompareKind.ConsiderEverything2))
                {
                    index = ConvertIndex(index, arg.Type, _int32Type);
                }
                builder.Add(index);
            }

            return(_bound.ArrayOrEmpty(ExpressionType, builder.ToImmutableAndFree()));
        }
Ejemplo n.º 2
0
        private BoundExpression Indices(ImmutableArray <BoundExpression> expressions)
        {
            var builder = ArrayBuilder <BoundExpression> .GetInstance();

            foreach (var arg in expressions)
            {
                var index = Visit(arg);
                if (index.Type != _int32Type)
                {
                    index = ConvertIndex(index, arg.Type, _int32Type);
                }
                builder.Add(index);
            }

            return(_bound.ArrayOrEmpty(ExpressionType, builder.ToImmutableAndFree()));
        }
Ejemplo n.º 3
0
        internal LoweredDynamicOperation MakeDynamicMemberInvocation(
            string name,
            BoundExpression loweredReceiver,
            ImmutableArray <TypeSymbol> typeArguments,
            ImmutableArray <BoundExpression> loweredArguments,
            ImmutableArray <string> argumentNames,
            ImmutableArray <RefKind> refKinds,
            bool hasImplicitReceiver,
            bool resultDiscarded)
        {
            _factory.Syntax = loweredReceiver.Syntax;

            CSharpBinderFlags binderFlags = 0;

            if (hasImplicitReceiver && !_factory.TopLevelMethod.IsStatic)
            {
                binderFlags |= CSharpBinderFlags.InvokeSimpleName;
            }

            TypeSymbol resultType;

            if (resultDiscarded)
            {
                binderFlags |= CSharpBinderFlags.ResultDiscarded;
                resultType   = _factory.SpecialType(SpecialType.System_Void);
            }
            else
            {
                resultType = AssemblySymbol.DynamicType;
            }

            RefKind receiverRefKind;
            bool    receiverIsStaticType;

            if (loweredReceiver.Kind == BoundKind.TypeExpression)
            {
                loweredReceiver      = _factory.Typeof(((BoundTypeExpression)loweredReceiver).Type);
                receiverRefKind      = RefKind.None;
                receiverIsStaticType = true;
            }
            else
            {
                receiverRefKind      = GetReceiverRefKind(loweredReceiver);
                receiverIsStaticType = false;
            }

            MethodSymbol argumentInfoFactory = GetArgumentInfoFactory();
            var          binderConstruction  = ((object)argumentInfoFactory != null) ? MakeBinderConstruction(WellKnownMember.Microsoft_CSharp_RuntimeBinder_Binder__InvokeMember, new[]
            {
                // flags:
                _factory.Literal((int)binderFlags),

                // member name:
                _factory.Literal(name),

                // type arguments:
                typeArguments.IsDefaultOrEmpty ?
                _factory.Null(_factory.WellKnownArrayType(WellKnownType.System_Type)) :
                _factory.ArrayOrEmpty(_factory.WellKnownType(WellKnownType.System_Type), _factory.TypeOfs(typeArguments)),

                // context:
                _factory.TypeofDynamicOperationContextType(),

                // argument infos:
                MakeCallSiteArgumentInfos(argumentInfoFactory, loweredArguments, argumentNames, refKinds, loweredReceiver, receiverRefKind, receiverIsStaticType)
            }) : null;

            return(MakeDynamicOperation(binderConstruction, loweredReceiver, receiverRefKind, loweredArguments, refKinds, null, resultType));
        }