本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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));
}
}