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


C# Compiler.LambdaCompiler类代码示例

本文整理汇总了C#中System.Linq.Expressions.Compiler.LambdaCompiler的典型用法代码示例。如果您正苦于以下问题:C# LambdaCompiler类的具体用法?C# LambdaCompiler怎么用?C# LambdaCompiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LambdaCompiler类属于System.Linq.Expressions.Compiler命名空间,在下文中一共展示了LambdaCompiler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LocalStorage

 internal LocalStorage(LambdaCompiler compiler, ParameterExpression v)
     : base(compiler, v) {
     // ByRef variables are supported. This is used internally by
     // the compiler when emitting an inlined lambda invoke, to 
     // handle ByRef parameters. BlockExpression prevents this
     // from being exposed to user created trees.
     _local = compiler.GetNamedLocal(v.IsByRef ? v.Type.MakeByRefType() : v.Type, v.Name);
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:8,代码来源:CompilerScope.Storage.cs

示例2: AllocateLocals

 private void AllocateLocals(LambdaCompiler lc)
 {
     foreach (ParameterExpression expression in this.GetVariables())
     {
         if (((VariableStorageKind) this.Definitions[expression]) == VariableStorageKind.Local)
         {
             Storage storage;
             if (this.IsMethod && lc.Parameters.Contains(expression))
             {
                 storage = new ArgumentStorage(lc, expression);
             }
             else
             {
                 storage = new LocalStorage(lc, expression);
             }
             this._locals.Add(expression, storage);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:CompilerScope.cs

示例3: 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

示例4: LocalStorage

 internal LocalStorage(LambdaCompiler compiler, ParameterExpression variable)
     : base(compiler, variable) {
     _local = compiler.GetNamedLocal(variable.Type, variable.Name);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:4,代码来源:CompilerScope.Storage.cs

示例5: EmitClosureAccess

 private void EmitClosureAccess(LambdaCompiler lc, HoistedLocals locals)
 {
     if (locals != null)
     {
         this.EmitClosureToVariable(lc, locals);
         while ((locals = locals.Parent) != null)
         {
             ParameterExpression selfVariable = locals.SelfVariable;
             LocalStorage storage = new LocalStorage(lc, selfVariable);
             storage.EmitStore(this.ResolveVariable(selfVariable));
             this._locals.Add(selfVariable, storage);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:CompilerScope.cs

示例6: Storage

 internal Storage(LambdaCompiler compiler, ParameterExpression variable)
 {
     this.Compiler = compiler;
     this.Variable = variable;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:5,代码来源:CompilerScope.cs

示例7: LocalBoxStorage

 internal LocalBoxStorage(LambdaCompiler compiler, ParameterExpression variable) : base(compiler, variable)
 {
     this._boxType = typeof(StrongBox<>).MakeGenericType(new Type[] { variable.Type });
     this._boxValueField = this._boxType.GetField("Value");
     this._boxLocal = compiler.GetNamedLocal(this._boxType, variable);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:CompilerScope.cs

示例8: AddLocal

 internal void AddLocal(LambdaCompiler gen, ParameterExpression variable)
 {
     this._locals.Add(variable, new LocalStorage(gen, variable));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:CompilerScope.cs

示例9: SetParent

 private void SetParent(LambdaCompiler lc, CompilerScope parent)
 {
     this._parent = parent;
     if (this.NeedsClosure && (this._parent != null))
     {
         this._closureHoistedLocals = this._parent.NearestHoistedLocals;
     }
     ReadOnlyCollection<ParameterExpression> vars = (from p in this.GetVariables()
         where ((VariableStorageKind) this.Definitions[p]) == VariableStorageKind.Hoisted
         select p).ToReadOnly<ParameterExpression>();
     if (vars.Count > 0)
     {
         this._hoistedLocals = new HoistedLocals(this._closureHoistedLocals, vars);
         this.AddLocal(lc, this._hoistedLocals.SelfVariable);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:CompilerScope.cs

示例10: SetParent

        private void SetParent(LambdaCompiler lc, CompilerScope parent)
        {
            Debug.Assert(_parent == null && parent != this);
            _parent = parent;

            if (NeedsClosure && _parent != null)
            {
                _closureHoistedLocals = _parent.NearestHoistedLocals;
            }

            ReadOnlyCollection<ParameterExpression> hoistedVars = GetVariables().Where(p => Definitions[p] == VariableStorageKind.Hoisted).ToReadOnly();

            if (hoistedVars.Count > 0)
            {
                _hoistedLocals = new HoistedLocals(_closureHoistedLocals, hoistedVars);
                AddLocal(lc, _hoistedLocals.SelfVariable);
            }
        }
开发者ID:AtsushiKan,项目名称:corefx,代码行数:18,代码来源:CompilerScope.cs

示例11: 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

示例12: Enter

        /// <summary>
        /// Called when entering a lambda/block. Performs all variable allocation
        /// needed, including creating hoisted locals and IL locals for accessing
        /// parent locals
        /// </summary>
        internal CompilerScope Enter(LambdaCompiler lc, CompilerScope parent)
        {
            SetParent(lc, parent);

            AllocateLocals(lc);

            if (IsMethod && _closureHoistedLocals != null)
            {
                EmitClosureAccess(lc, _closureHoistedLocals);
            }

            EmitNewHoistedLocals(lc);

            if (IsMethod)
            {
                EmitCachedVariables();
            }

            return this;
        }
开发者ID:AtsushiKan,项目名称:corefx,代码行数:25,代码来源:CompilerScope.cs

示例13: AllocateLocals

 // Allocates slots for IL locals or IL arguments
 private void AllocateLocals(LambdaCompiler lc) {
     foreach (ParameterExpression v in GetVariables()) {
         if (Definitions[v] == VariableStorageKind.Local) {
             Storage s;
             //If v is in lc.Parameters, it is a parameter.
             //Otherwise, it is a local variable.
             if (lc.Parameters.Contains(v)) {
                 s = new ArgumentStorage(lc, v);
             } else {
                 s = new LocalStorage(lc, v);
             }
             _locals.Add(v, s);
         }
     }
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:16,代码来源:CompilerScope.cs

示例14: 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

示例15: 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


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