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


C# IArgumentProvider.GetArgument方法代码示例

本文整理汇总了C#中IArgumentProvider.GetArgument方法的典型用法代码示例。如果您正苦于以下问题:C# IArgumentProvider.GetArgument方法的具体用法?C# IArgumentProvider.GetArgument怎么用?C# IArgumentProvider.GetArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IArgumentProvider的用法示例。


在下文中一共展示了IArgumentProvider.GetArgument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitArguments

        public static Expression[] VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes)
        {
            Expression[] newNodes = null;
            for (int i = 0, n = nodes.ArgumentCount; i < n; i++)
            {
                Expression curNode = nodes.GetArgument(i);
                Expression node = visitor.Visit(curNode);

                if (newNodes != null)
                {
                    newNodes[i] = node;
                }
                else if (!object.ReferenceEquals(node, curNode))
                {
                    newNodes = new Expression[n];
                    for (int j = 0; j < i; j++)
                    {
                        newNodes[j] = nodes.GetArgument(j);
                    }
                    newNodes[i] = node;
                }
            }
            return newNodes;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:24,代码来源:ExpressionVisitorUtils.cs

示例2: EmitArguments

        /// <summary>
        /// Emits arguments to a call, and returns an array of write-backs that
        /// should happen after the call. For emitting dynamic expressions, we
        /// need to skip the first parameter of the method (the call site).
        /// </summary>
        private List<WriteBack> EmitArguments(MethodBase method, IArgumentProvider args, int skipParameters)
        {
            ParameterInfo[] pis = method.GetParametersCached();
            Debug.Assert(args.ArgumentCount + skipParameters == pis.Length);

            var writeBacks = new List<WriteBack>();
            for (int i = skipParameters, n = pis.Length; i < n; i++)
            {
                ParameterInfo parameter = pis[i];
                Expression argument = args.GetArgument(i - skipParameters);
                Type type = parameter.ParameterType;

                if (type.IsByRef)
                {
                    type = type.GetElementType();

                    WriteBack wb = EmitAddressWriteBack(argument, type);
                    if (wb != null)
                    {
                        writeBacks.Add(wb);
                    }
                }
                else
                {
                    EmitExpression(argument);
                }
            }
            return writeBacks;
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:34,代码来源:LambdaCompiler.Expressions.cs

示例3: EmitMethodCall

        // assumes 'object' of non-static call is already on stack
        private void EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType, CompilationFlags flags)
        {
            // Emit arguments
            List<WriteBack> wb = EmitArguments(mi, args);

            // Emit the actual call
            OpCode callOp = UseVirtual(mi) ? OpCodes.Callvirt : OpCodes.Call;
            if (callOp == OpCodes.Callvirt && objectType.GetTypeInfo().IsValueType)
            {
                // This automatically boxes value types if necessary.
                _ilg.Emit(OpCodes.Constrained, objectType);
            }
            // The method call can be a tail call if 
            // 1) the method call is the last instruction before Ret
            // 2) the method does not have any ByRef parameters, refer to ECMA-335 Partition III Section 2.4.
            //    "Verification requires that no managed pointers are passed to the method being called, since
            //    it does not track pointers into the current frame."
            if ((flags & CompilationFlags.EmitAsTailCallMask) == CompilationFlags.EmitAsTail && !MethodHasByRefParameter(mi))
            {
                _ilg.Emit(OpCodes.Tailcall);
            }
            if (mi.CallingConvention == CallingConventions.VarArgs)
            {
                int count = args.ArgumentCount;
                Type[] types = new Type[count];
                for (int i = 0; i < count; i++)
                {
                    types[i] = args.GetArgument(i).Type;
                }

                _ilg.EmitCall(callOp, mi, types);
            }
            else
            {
                _ilg.Emit(callOp, mi);
            }

            // Emit write-backs for properties passed as "ref" arguments
            EmitWriteBack(wb);
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:41,代码来源:LambdaCompiler.Expressions.cs

示例4: AddArguments

 /// <summary>
 /// Adds child <paramref name="expressions"/> provided through an argument
 /// provider to the rewriter, causing them to be rewritten using the parent
 /// stack spiller, and the evaluation stack state and rewrite action to be
 /// updated accordingly.
 /// </summary>
 /// <param name="expressions">
 /// The argument provider containing the child expression to add.
 /// </param>
 internal void AddArguments(IArgumentProvider expressions)
 {
     for (int i = 0, count = expressions.ArgumentCount; i < count; i++)
     {
         Add(expressions.GetArgument(i));
     }
 }
开发者ID:AtsushiKan,项目名称:corefx,代码行数:16,代码来源:StackSpiller.ChildRewriter.cs


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