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


C# LambdaCompiler.EmitConstantArray方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:AtsushiKan,项目名称:corefx,代码行数:36,代码来源:CompilerScope.cs

示例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));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:CompilerScope.cs

示例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;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:34,代码来源:CompilerScope.cs


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