本文整理汇总了C#中System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaArgument方法的典型用法代码示例。如果您正苦于以下问题:C# LambdaCompiler.EmitLambdaArgument方法的具体用法?C# LambdaCompiler.EmitLambdaArgument怎么用?C# LambdaCompiler.EmitLambdaArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Compiler.LambdaCompiler
的用法示例。
在下文中一共展示了LambdaCompiler.EmitLambdaArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitNewHoistedLocals
private void EmitNewHoistedLocals(LambdaCompiler lc)
{
if (this._hoistedLocals != null)
{
lc.IL.EmitInt(this._hoistedLocals.Variables.Count);
lc.IL.Emit(OpCodes.Newarr, typeof(object));
int num = 0;
foreach (ParameterExpression expression in this._hoistedLocals.Variables)
{
lc.IL.Emit(OpCodes.Dup);
lc.IL.EmitInt(num++);
Type type = typeof(StrongBox<>).MakeGenericType(new Type[] { expression.Type });
if (this.IsMethod && lc.Parameters.Contains(expression))
{
int index = lc.Parameters.IndexOf(expression);
lc.EmitLambdaArgument(index);
lc.IL.Emit(OpCodes.Newobj, type.GetConstructor(new Type[] { expression.Type }));
}
else if (expression == this._hoistedLocals.ParentVariable)
{
this.ResolveVariable(expression, this._closureHoistedLocals).EmitLoad();
lc.IL.Emit(OpCodes.Newobj, type.GetConstructor(new Type[] { expression.Type }));
}
else
{
lc.IL.Emit(OpCodes.Newobj, type.GetConstructor(Type.EmptyTypes));
}
if (this.ShouldCache(expression))
{
lc.IL.Emit(OpCodes.Dup);
this.CacheBoxToLocal(lc, expression);
}
lc.IL.Emit(OpCodes.Stelem_Ref);
}
this.EmitSet(this._hoistedLocals.SelfVariable);
}
}
示例2: EmitNewHoistedLocals
// Emits creation of the hoisted local storage
private void EmitNewHoistedLocals(LambdaCompiler lc)
{
if (_hoistedLocals == null)
{
return;
}
// create the array
lc.IL.EmitInt(_hoistedLocals.Variables.Count);
lc.IL.Emit(OpCodes.Newarr, typeof(object));
// initialize all elements
int i = 0;
foreach (ParameterExpression v in _hoistedLocals.Variables)
{
// array[i] = new StrongBox<T>(...);
lc.IL.Emit(OpCodes.Dup);
lc.IL.EmitInt(i++);
Type boxType = typeof(StrongBox<>).MakeGenericType(v.Type);
if (IsMethod && lc.Parameters.Contains(v))
{
// array[i] = new StrongBox<T>(argument);
int index = lc.Parameters.IndexOf(v);
lc.EmitLambdaArgument(index);
lc.IL.Emit(OpCodes.Newobj, boxType.GetConstructor(new Type[] { v.Type }));
}
else if (v == _hoistedLocals.ParentVariable)
{
// array[i] = new StrongBox<T>(closure.Locals);
ResolveVariable(v, _closureHoistedLocals).EmitLoad();
lc.IL.Emit(OpCodes.Newobj, boxType.GetConstructor(new Type[] { v.Type }));
}
else
{
// array[i] = new StrongBox<T>();
lc.IL.Emit(OpCodes.Newobj, boxType.GetConstructor(Type.EmptyTypes));
}
// if we want to cache this into a local, do it now
if (ShouldCache(v))
{
lc.IL.Emit(OpCodes.Dup);
CacheBoxToLocal(lc, v);
}
lc.IL.Emit(OpCodes.Stelem_Ref);
}
// store it
EmitSet(_hoistedLocals.SelfVariable);
}