本文整理汇总了C#中System.Linq.Expressions.Compiler.LambdaCompiler.EmitConstantArray方法的典型用法代码示例。如果您正苦于以下问题:C# LambdaCompiler.EmitConstantArray方法的具体用法?C# LambdaCompiler.EmitConstantArray怎么用?C# LambdaCompiler.EmitConstantArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Compiler.LambdaCompiler
的用法示例。
在下文中一共展示了LambdaCompiler.EmitConstantArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitVariableAccess
internal void EmitVariableAccess(LambdaCompiler lc, ReadOnlyCollection<ParameterExpression> vars)
{
if (NearestHoistedLocals != null && vars.Count > 0)
{
// Find what array each variable is on & its index
var indexes = new ArrayBuilder<long>(vars.Count);
foreach (ParameterExpression variable in vars)
{
// For each variable, find what array it's defined on
ulong parents = 0;
HoistedLocals locals = NearestHoistedLocals;
while (!locals.Indexes.ContainsKey(variable))
{
parents++;
locals = locals.Parent;
Debug.Assert(locals != null);
}
// combine the number of parents we walked, with the
// real index of variable to get the index to emit.
ulong index = (parents << 32) | (uint)locals.Indexes[variable];
indexes.UncheckedAdd((long)index);
}
EmitGet(NearestHoistedLocals.SelfVariable);
lc.EmitConstantArray(indexes.ToArray());
lc.IL.Emit(OpCodes.Call, RuntimeOps_CreateRuntimeVariables_ObjectArray_Int64Array);
}
else
{
// No visible variables
lc.IL.Emit(OpCodes.Call, RuntimeOps_CreateRuntimeVariables);
}
}
示例2: EmitVariableAccess
internal void EmitVariableAccess(LambdaCompiler lc, ReadOnlyCollection<ParameterExpression> vars)
{
if (this.NearestHoistedLocals != null)
{
List<long> list = new List<long>(vars.Count);
foreach (ParameterExpression expression in vars)
{
ulong num = 0L;
HoistedLocals nearestHoistedLocals = this.NearestHoistedLocals;
while (!nearestHoistedLocals.Indexes.ContainsKey(expression))
{
num += (ulong) 1L;
nearestHoistedLocals = nearestHoistedLocals.Parent;
}
ulong num2 = (num << 0x20) | ((ulong) nearestHoistedLocals.Indexes[expression]);
list.Add((long) num2);
}
if (list.Count > 0)
{
this.EmitGet(this.NearestHoistedLocals.SelfVariable);
lc.EmitConstantArray<long>(list.ToArray());
lc.IL.Emit(OpCodes.Call, typeof(RuntimeOps).GetMethod("CreateRuntimeVariables", new Type[] { typeof(object[]), typeof(long[]) }));
return;
}
}
lc.IL.Emit(OpCodes.Call, typeof(RuntimeOps).GetMethod("CreateRuntimeVariables", Type.EmptyTypes));
}
示例3: EmitVariableAccess
internal void EmitVariableAccess(LambdaCompiler lc, ReadOnlyCollection<ParameterExpression> vars) {
if (NearestHoistedLocals != null) {
// Find what array each variable is on & its index
var indexes = new List<long>(vars.Count);
foreach (var variable in vars) {
// For each variable, find what array it's defined on
ulong parents = 0;
HoistedLocals locals = NearestHoistedLocals;
while (!locals.Indexes.ContainsKey(variable)) {
parents++;
locals = locals.Parent;
Debug.Assert(locals != null);
}
// combine the number of parents we walked, with the
// real index of variable to get the index to emit.
ulong index = (parents << 32) | (uint)locals.Indexes[variable];
indexes.Add((long)index);
}
if (indexes.Count > 0) {
EmitGet(NearestHoistedLocals.SelfVariable);
lc.EmitConstantArray(indexes.ToArray());
lc.IL.EmitCall(typeof(RuntimeOps).GetMethod("CreateRuntimeVariables", new[] { typeof(object[]), typeof(long[]) }));
return;
}
}
// No visible variables
lc.IL.EmitCall(typeof(RuntimeOps).GetMethod("CreateRuntimeVariables", Type.EmptyTypes));
return;
}