当前位置: 首页>>代码示例>>C#>>正文


C# CSharp.BoundCall类代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.BoundCall的典型用法代码示例。如果您正苦于以下问题:C# BoundCall类的具体用法?C# BoundCall怎么用?C# BoundCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BoundCall类属于Microsoft.CodeAnalysis.CSharp命名空间,在下文中一共展示了BoundCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitCall

            public override BoundNode VisitCall(BoundCall node)
            {
                if (node.Method.MethodKind == MethodKind.LocalFunction)
                {
                    BoundExpression receiver;
                    MethodSymbol method;
                    var arguments = node.Arguments;
                    _lambdaRewriter.RemapLocalFunction(node.Syntax, node.Method, out receiver, out method, ref arguments);
                    node = node.Update(receiver, method, arguments);
                }

                return base.VisitCall(node);
            }
开发者ID:jkotas,项目名称:roslyn,代码行数:13,代码来源:LambdaRewriter.LocalFunctionReferenceRewriter.cs

示例2: ErrorCall

        public static BoundCall ErrorCall(
            CSharpSyntaxNode node,
            BoundExpression receiverOpt,
            MethodSymbol method,
            ImmutableArray<BoundExpression> arguments,
            ImmutableArray<string> namedArguments,
            ImmutableArray<RefKind> refKinds,
            bool isDelegateCall,
            bool invokedAsExtensionMethod,
            ImmutableArray<MethodSymbol> originalMethods,
            LookupResultKind resultKind)
        {
            if (!originalMethods.IsEmpty)
                resultKind = resultKind.WorseResultKind(LookupResultKind.OverloadResolutionFailure);

            var call = new BoundCall(node, receiverOpt, method, arguments, namedArguments,
                refKinds, isDelegateCall: isDelegateCall, expanded: false, invokedAsExtensionMethod: invokedAsExtensionMethod, argsToParamsOpt: default(ImmutableArray<int>),
                resultKind: resultKind, type: method.ReturnType, hasErrors: true);
            call.OriginalMethodsOpt = originalMethods;
            return call;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:21,代码来源:Constructors.cs

示例3: VisitCall

 public override BoundNode VisitCall(BoundCall node)
 {
     if (node.Method.MethodKind == MethodKind.LocalFunction)
     {
         // Use OriginalDefinition to strip generic type parameters
         ReferenceVariable(node.Syntax, node.Method.OriginalDefinition);
     }
     return base.VisitCall(node);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:9,代码来源:LambdaRewriter.Analysis.cs

示例4: CheckIsCallVariable

        private bool CheckIsCallVariable(BoundCall call, CSharpSyntaxNode node, BindValueKind kind, bool checkingReceiver, DiagnosticBag diagnostics)
        {
            // A call can only be a variable if it returns by reference. If this is the case,
            // whether or not it is a valid variable depends on whether or not the call is the
            // RHS of a return or an assign by reference:
            // - If call is used in a context demanding ref-returnable reference all of its ref
            //   inputs must be ref-returnable

            var methodSymbol = call.Method;
            if (methodSymbol.RefKind != RefKind.None)
            {
                if (kind == BindValueKind.RefReturn)
                {
                    var args = call.Arguments;
                    var argRefKinds = call.ArgumentRefKindsOpt;
                    if (!argRefKinds.IsDefault)
                    {
                        for (var i = 0; i < args.Length; i++)
                        {
                            if (argRefKinds[i] != RefKind.None && !CheckIsVariable(args[i].Syntax, args[i], kind, false, diagnostics))
                            {
                                var errorCode = checkingReceiver ? ErrorCode.ERR_RefReturnCall2 : ErrorCode.ERR_RefReturnCall;
                                var parameterIndex = call.ArgsToParamsOpt.IsDefault ? i : call.ArgsToParamsOpt[i];
                                var parameterName = methodSymbol.Parameters[parameterIndex].Name;
                                Error(diagnostics, errorCode, call.Syntax, methodSymbol, parameterName);
                                return false;
                            }
                        }
                    }
                }

                return true;
            }

            if (checkingReceiver)
            {
                // Error is associated with expression, not node which may be distinct.
                Error(diagnostics, ErrorCode.ERR_ReturnNotLValue, call.Syntax, methodSymbol);
            }
            else
            {
                Error(diagnostics, GetStandardLvalueError(kind), node);
            }

            return false;
        }
开发者ID:abock,项目名称:roslyn,代码行数:46,代码来源:Binder_Statements.cs

示例5: MakeLiftedUserDefinedConversionConsequence

        private BoundExpression MakeLiftedUserDefinedConversionConsequence(BoundCall call, TypeSymbol resultType)
        {
            if (call.Method.ReturnType.IsNonNullableValueType())
            {
                Debug.Assert(resultType.IsNullableType() && resultType.GetNullableUnderlyingType() == call.Method.ReturnType);
                MethodSymbol ctor = GetNullableMethod(call.Syntax, resultType, SpecialMember.System_Nullable_T__ctor);
                return new BoundObjectCreationExpression(call.Syntax, ctor, call);
            }

            return call;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:11,代码来源:LocalRewriter_Conversion.cs

示例6: VisitCall

 public override BoundNode VisitCall(BoundCall node)
 {
     VisitCall(node.Method, null, node.Arguments, node.ArgumentRefKindsOpt, node.ArgumentNamesOpt, node.Expanded, node);
     CheckReceiverIfField(node.ReceiverOpt);
     return base.VisitCall(node);
 }
开发者ID:abock,项目名称:roslyn,代码行数:6,代码来源:DiagnosticsPass_ExpressionTrees.cs

示例7: ReverseLastTwoParameterOrder

 private static BoundCall ReverseLastTwoParameterOrder(BoundCall result)
 {
     // The input call has its arguments in the appropriate order for the invocation, but its last
     // two argument expressions appear in the reverse order from which they appeared in source.
     // Since we want region analysis to see them in source order, we rewrite the call so that these
     // two arguments are evaluated in source order.
     int n = result.Arguments.Length;
     var arguments = ArrayBuilder<BoundExpression>.GetInstance();
     arguments.AddRange(result.Arguments);
     var lastArgument = arguments[n - 1];
     arguments[n - 1] = arguments[n - 2];
     arguments[n - 2] = lastArgument;
     var argsToParams = ArrayBuilder<int>.GetInstance();
     argsToParams.AddRange(Enumerable.Range(0, n));
     argsToParams[n - 1] = n - 2;
     argsToParams[n - 2] = n - 1;
     return result.Update(
         result.ReceiverOpt, result.Method, arguments.ToImmutableAndFree(), default(ImmutableArray<string>),
         default(ImmutableArray<RefKind>), result.IsDelegateCall, result.Expanded, result.InvokedAsExtensionMethod,
         argsToParams.ToImmutableAndFree(), result.ResultKind, result.Type);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:21,代码来源:Binder_Query.cs

示例8: MakeCall

        private BoundExpression MakeCall(
            SyntaxNode syntax,
            BoundExpression rewrittenReceiver,
            MethodSymbol method,
            ImmutableArray<BoundExpression> rewrittenArguments,
            ImmutableArray<RefKind> argumentRefKindsOpt,
            bool expanded,
            bool invokedAsExtensionMethod,
            ImmutableArray<int> argsToParamsOpt,
            LookupResultKind resultKind,
            TypeSymbol type,
            BoundCall nodeOpt = null)
        {
            // We have already lowered each argument, but we may need some additional rewriting for the arguments,
            // such as generating a params array, re-ordering arguments based on argsToParamsOpt map, inserting arguments for optional parameters, etc.
            ImmutableArray<LocalSymbol> temps;
            rewrittenArguments = MakeArguments(syntax, rewrittenArguments, method, method, expanded, argsToParamsOpt, ref argumentRefKindsOpt, out temps, invokedAsExtensionMethod);

            return MakeCall(nodeOpt, syntax, rewrittenReceiver, method, rewrittenArguments, argumentRefKindsOpt, invokedAsExtensionMethod, resultKind, type, temps);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:20,代码来源:LocalRewriter_Call.cs

示例9: VisitCall

        public override BoundNode VisitCall(BoundCall node)
        {
            Debug.Assert(node != null);

            // Rewrite the receiver
            BoundExpression rewrittenReceiver = VisitExpression(node.ReceiverOpt);

            // Rewrite the arguments.
            // NOTE: We may need additional argument rewriting such as generating a params array, re-ordering arguments based on argsToParamsOpt map, inserting arguments for optional parameters, etc.
            // NOTE: This is done later by MakeArguments, for now we just lower each argument.
            var rewrittenArguments = VisitList(node.Arguments);

            return MakeCall(
                syntax: node.Syntax,
                rewrittenReceiver: rewrittenReceiver,
                method: node.Method,
                rewrittenArguments: rewrittenArguments,
                argumentRefKindsOpt: node.ArgumentRefKindsOpt,
                expanded: node.Expanded,
                invokedAsExtensionMethod: node.InvokedAsExtensionMethod,
                argsToParamsOpt: node.ArgsToParamsOpt,
                resultKind: node.ResultKind,
                type: node.Type,
                nodeOpt: node);
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:25,代码来源:LocalRewriter_Call.cs

示例10: MakeNewT

        private BoundExpression MakeNewT(CSharpSyntaxNode syntax, TypeParameterSymbol typeParameter)
        {
            // "new T()" is rewritten as: "Activator.CreateInstance<T>()".

            // NOTE: DIFFERENCE FROM DEV12
            // Dev12 tried to statically optimize this and would emit default(T) if T happens to be struct
            // However semantics of "new" in C# requires that parameterless constructor be called
            // if struct defines one.
            // Since we cannot know if T has a parameterless constructor statically, 
            // we must call Activator.CreateInstance unconditionally.
            MethodSymbol method;

            if (!this.TryGetWellKnownTypeMember(syntax, WellKnownMember.System_Activator__CreateInstance_T, out method))
            {
                return new BoundDefaultOperator(syntax, null, type: typeParameter, hasErrors: true);
            }

            Debug.Assert((object)method != null);
            method = method.Construct(ImmutableArray.Create<TypeSymbol>(typeParameter));

            var createInstanceCall = new BoundCall(
                syntax,
                null,
                method,
                ImmutableArray<BoundExpression>.Empty,
                default(ImmutableArray<string>),
                default(ImmutableArray<RefKind>),
                isDelegateCall: false,
                expanded: false,
                invokedAsExtensionMethod: false,
                argsToParamsOpt: default(ImmutableArray<int>),
                resultKind: LookupResultKind.Viable,
                type: typeParameter);

            return createInstanceCall;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:36,代码来源:LocalRewriter_ObjectCreationExpression.cs

示例11: VisitCall

        public override BoundNode VisitCall(BoundCall node)
        {
            BoundExpression receiverOpt = (BoundExpression)this.Visit(node.ReceiverOpt);
            ReadOnlyArray<BoundExpression> arguments = this.VisitList(node.Arguments);
            TypeSymbol type = this.VisitType(node.Type);

            if (!RequiresSpill(arguments) && !RequiresSpill(receiverOpt))
            {
                return node.Update(
                    receiverOpt, 
                    node.Method, 
                    arguments, 
                    node.ArgumentNamesOpt, 
                    node.ArgumentRefKindsOpt, 
                    node.IsDelegateCall,
                    node.Expanded, 
                    node.InvokedAsExtensionMethod, 
                    node.ArgsToParamsOpt, 
                    node.ResultKind, type);
            }

            var spillBuilder = new SpillBuilder();
            var spillResult = SpillExpressionsWithReceiver(receiverOpt, arguments, spillBuilder, node.Method.ParameterRefKinds);

            var newCall = node.Update(
                spillResult.Item1,
                node.Method,
                spillResult.Item2,
                node.ArgumentNamesOpt,
                node.ArgumentRefKindsOpt,
                node.IsDelegateCall,
                node.Expanded,
                node.InvokedAsExtensionMethod,
                node.ArgsToParamsOpt,
                node.ResultKind,
                type);

            return spillBuilder.BuildSequenceAndFree(F, newCall);
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:39,代码来源:AwaitLoweringRewriterPass1_ArgExpressions.cs

示例12: MakeNewT

        private BoundExpression MakeNewT(CSharpSyntaxNode syntax, TypeParameterSymbol typeParameter)
        {
            // How "new T()" is rewritten depends on whether T is known to be a value
            // type, a reference type, or neither (see OperatorRewriter::VisitNEWTYVAR).

            if (typeParameter.IsValueType)
            {
                // "new T()" rewritten as: "default(T)".
                return new BoundDefaultOperator(syntax, type: typeParameter);
            }

            // For types not known to be value types, "new T()" requires
            // Activator.CreateInstance<T>().

            MethodSymbol method;

            if (!this.TryGetWellKnownTypeMember(syntax, WellKnownMember.System_Activator__CreateInstance_T, out method))
            {
                return new BoundDefaultOperator(syntax, null, type: typeParameter, hasErrors: true);
            }

            Debug.Assert((object)method != null);
            method = method.Construct(ImmutableArray.Create<TypeSymbol>(typeParameter));

            var createInstanceCall = new BoundCall(
                syntax,
                null,
                method,
                ImmutableArray<BoundExpression>.Empty,
                default(ImmutableArray<string>),
                default(ImmutableArray<RefKind>),
                isDelegateCall: false,
                expanded: false,
                invokedAsExtensionMethod: false,
                argsToParamsOpt: default(ImmutableArray<int>),
                resultKind: LookupResultKind.Viable,
                type: typeParameter);

            if (typeParameter.IsReferenceType)
            {
                // "new T()" is rewritten as: "Activator.CreateInstance<T>()".
                return createInstanceCall;
            }
            else
            {
                // "new T()" is rewritten as: "(null == (object)default(T)) ? Activator.CreateInstance<T>() : default(T)".
                var defaultT = new BoundDefaultOperator(syntax, type: typeParameter);
                return new BoundConditionalOperator(
                    syntax,
                    MakeNullCheck(
                        syntax: syntax,
                        rewrittenExpr: MakeConversion(
                            syntax: syntax,
                            rewrittenOperand: defaultT,
                            conversionKind: ConversionKind.Boxing,
                            rewrittenType: this.compilation.GetSpecialType(SpecialType.System_Object),
                            @checked: false),
                        operatorKind: BinaryOperatorKind.Equal),
                    createInstanceCall,
                    defaultT,
                    constantValueOpt: null,
                    type: typeParameter);
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:64,代码来源:LocalRewriter_ObjectCreationExpression.cs

示例13: ExtractCastInvocation

 private static BoundExpression ExtractCastInvocation(BoundCall invocation)
 {
     int index = invocation.InvokedAsExtensionMethod ? 1 : 0;
     var c1 = invocation.Arguments[index] as BoundConversion;
     var l1 = c1 != null ? c1.Operand as BoundLambda : null;
     var r1 = l1 != null ? l1.Body.Statements[0] as BoundReturnStatement : null;
     var i1 = r1 != null ? r1.ExpressionOpt as BoundCall : null;
     return i1;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:Binder_Query.cs

示例14: VisitCall

        public override BoundNode VisitCall(BoundCall node)
        {
            BoundSpillSequence2 ss = null;
            var arguments = this.VisitExpressionList(ref ss, node.Arguments, node.ArgumentRefKindsOpt);

            BoundExpression receiver = null;
            if (ss == null)
            {
                receiver = VisitExpression(ref ss, node.ReceiverOpt);
            }
            else if (!node.Method.IsStatic)
            {
                // spill the receiver if there were await expressions in the arguments
                var ss2 = new BoundSpillSequence2();
                receiver = Spill(ss2, VisitExpression(ref ss2, node.ReceiverOpt), refKind: node.ReceiverOpt.Type.IsReferenceType ? RefKind.None : RefKind.Ref);
                ss2.IncludeSequence(ss);
                ss = ss2;
            }

            return UpdateExpression(ss, node.Update(receiver, node.Method, arguments));
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:21,代码来源:AwaitLiftingRewriter.cs

示例15: VisitCall

 private BoundExpression VisitCall(BoundCall node)
 {
     if (node.IsDelegateCall)
     {
         // Generate Expression.Invoke(Receiver, arguments)
         return ExprFactory(WellKnownMemberNames.DelegateInvokeName, Visit(node.ReceiverOpt), Expressions(node.Arguments));
     }
     else
     {
         // Generate Expression.Call(Receiver, Method, [typeArguments,] arguments)
         var method = node.Method;
         return ExprFactory(
             "Call",
             method.IsStatic ? _bound.Null(ExpressionType) : Visit(node.ReceiverOpt),
             _bound.MethodInfo(method),
             Expressions(node.Arguments));
     }
 }
开发者ID:MichalStrehovsky,项目名称:roslyn,代码行数:18,代码来源:ExpressionLambdaRewriter.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.BoundCall类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。