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


C# LambdaCompiler.EmitLambdaArgument方法代码示例

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

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


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