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


C# CodeGen.FreeLocalTmp方法代码示例

本文整理汇总了C#中CodeGen.FreeLocalTmp方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.FreeLocalTmp方法的具体用法?C# CodeGen.FreeLocalTmp怎么用?C# CodeGen.FreeLocalTmp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGen的用法示例。


在下文中一共展示了CodeGen.FreeLocalTmp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Emit


//.........这里部分代码省略.........

            for (int arg = sigInfo.HasContext ? 1 : 0; arg < sigInfo.ParamNames.Length; arg++) {
                impl.Names.SetSlot(sigInfo.ParamNames[arg], impl.GetArgumentSlot(arg));
            }

            if (sigInfo.HasContext) {
                if (IsClosure) {
                    impl.StaticLinkSlot = impl.GetArgumentSlot(0);
                }
                impl.ContextSlot = impl.GetArgumentSlot(0);
                impl.ModuleSlot = new PropertySlot(impl.ContextSlot, typeof(ICallerContext).GetProperty("Module"));
            }

            // then generate the actual method
            EmitFunctionImplementation(impl, cg);
            impl.Finish();

            if (NeedsWrapperMethod()) impl = MakeWrapperMethodN(cg, impl.MethodInfo, sigInfo.HasContext);

            //  Create instance of the Function? object
            Type funcType, targetType;
            using (impl) {
                GetFunctionType(out funcType, out targetType);
                cg.EmitModuleInstance();
                cg.EmitString(name.GetString());

                cg.EmitDelegate(impl, targetType, sigInfo.ContextSlot);
            }

            int first = sigInfo.HasContext ? 1 : 0;
            //  Emit string array (minus the first environment argument)
            cg.EmitInt(sigInfo.ParamNames.Length - first);
            cg.Emit(OpCodes.Newarr, typeof(string));
            for (int i = first; i < sigInfo.ParamNames.Length; i++) {
                cg.Emit(OpCodes.Dup);
                cg.EmitInt(i - first);
                cg.EmitStringOrNull(sigInfo.ParamNames[i].GetString());
                cg.Emit(OpCodes.Stelem_Ref);
            }
            cg.EmitObjectArray(defaults);

            if (flags == FunctionAttributes.None) {
                cg.Emit(OpCodes.Newobj, funcType.GetConstructor(
                    new Type[] { typeof(PythonModule), typeof(string), targetType, typeof(string[]), typeof(object[]) }));
            } else {
                cg.EmitInt((int)flags);
                cg.Emit(OpCodes.Newobj, funcType.GetConstructor(
                    new Type[] { typeof(PythonModule), typeof(string), targetType, typeof(string[]), typeof(object[]), typeof(FunctionAttributes) }));
            }

            string doc = Body.Documentation;
            if (doc != null) {
                cg.Emit(OpCodes.Dup);
                cg.EmitString(doc);
                cg.EmitCall(typeof(PythonFunction).GetProperty("Documentation").GetSetMethod());
            }

            // update func_code w/ appropriate state.
            cg.Emit(OpCodes.Dup);

            Slot functionCode = cg.GetLocalTmp(typeof(FunctionCode));

            cg.EmitCall(typeof(PythonFunction).GetProperty("FunctionCode").GetGetMethod());
            cg.Emit(OpCodes.Castclass, typeof(FunctionCode));
            cg.Emit(OpCodes.Dup);
            functionCode.EmitSet(cg);
            if (IsExternal) {
                cg.EmitInt(this.ExternalStart.Line);
            } else {
                cg.EmitInt(this.Start.Line);
            }
            cg.EmitCall(typeof(FunctionCode), "SetLineNumber");

            functionCode.EmitGet(cg);
            if (IsExternal) {
                cg.EmitString(ExternalInfo.OriginalFileName);
            } else {
                cg.EmitString(this.filename);
            }
            cg.EmitCall(typeof(FunctionCode), "SetFilename");

            // Only codegen the call into SetFlags if there are flags to set.
            FunctionCode.FuncCodeFlags codeFlags = 0;
            if (cg.Context.TrueDivision) codeFlags |= FunctionCode.FuncCodeFlags.FutureDivision;
            if (this.yieldCount > 0) codeFlags |= FunctionCode.FuncCodeFlags.Generator;
            if (codeFlags != 0) {
                functionCode.EmitGet(cg);
                cg.EmitInt((int)codeFlags);
                cg.EmitCall(typeof(FunctionCode), "SetFlags");
            }

            cg.FreeLocalTmp(functionCode);

            cg.EmitSet(name);

            if (decorators != null) {
                decorators.Emit(cg);
                cg.EmitSet(name);
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:101,代码来源:FuncDef.cs

示例2: EmitSet

        public override void EmitSet(CodeGen cg)
        {
            Contract.RequiresNotNull(cg, "cg");

            Slot val = cg.GetLocalTmp(Type);
            val.EmitSet(cg);
            EmitSet(cg, val);
            cg.FreeLocalTmp(val);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:9,代码来源:IndexSlot.cs

示例3: EmitSet

        // This override assumes that the IL stack already holds the value to be assigned from.
        public virtual void EmitSet(CodeGen cg)
        {
            Contract.RequiresNotNull(cg, "cg");

            // localTmpVal = <top of IL stack>
            Slot localTmpVal = cg.GetLocalTmp(typeof(object));
            localTmpVal.EmitSet(cg);

            // <slot> = localTmpVal
            EmitSet(cg, localTmpVal);

            cg.FreeLocalTmp(localTmpVal);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:14,代码来源:Slot.cs

示例4: EmitSet

 public override void EmitSet(CodeGen cg)
 {
     Slot val = cg.GetLocalTmp(Type);
     val.EmitSet(cg);
     EmitSet(cg, val);
     cg.FreeLocalTmp(val);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:7,代码来源:Slot.cs

示例5: EmitSet

        internal override void EmitSet(CodeGen cg)
        {
            // Disallow "[] = l", "[], a = l, l", "[[]] = [l]", etc
            if (items.Length == 0) {
                cg.Context.AddError("can't assign to " + EmptySequenceString, this);
                return;
            }

            // int leftCount = items.Length;
            Slot leftCount = cg.GetLocalTmp(typeof(int));
            cg.EmitInt(items.Length);
            leftCount.EmitSet(cg);

            // object[] values = new object[leftCount];
            Slot values = cg.GetLocalTmp(typeof(object[]));
            leftCount.EmitGet(cg);
            cg.Emit(OpCodes.Newarr, typeof(object));
            values.EmitSet(cg);

            // ie = Ops.GetEnumerator(<value on stack>)
            Slot ie = cg.GetLocalTmp(typeof(IEnumerator));
            cg.EmitCall(typeof(Ops), "GetEnumeratorForUnpack");
            ie.EmitSet(cg);

            // int rightCount = Ops.GetEnumeratorValues(ie, ref values);
            Slot rightCount = cg.GetLocalTmp(typeof(int));

            ie.EmitGet(cg);
            values.EmitGetAddr(cg);
            cg.EmitCall(typeof(Ops), "GetEnumeratorValues");
            rightCount.EmitSet(cg);

            // if (leftCount != rightCount)
            //      throw Ops.ValueErrorForUnpackMismatch(leftCount, rightCount);
            Label equalSizes = cg.DefineLabel();

            leftCount.EmitGet(cg);
            rightCount.EmitGet(cg);
            cg.Emit(OpCodes.Ceq);
            cg.Emit(OpCodes.Brtrue_S, equalSizes);

            leftCount.EmitGet(cg);
            rightCount.EmitGet(cg);
            cg.EmitCall(typeof(Ops).GetMethod("ValueErrorForUnpackMismatch"));
            cg.Emit(OpCodes.Throw);

            cg.MarkLabel(equalSizes);

            // for (int i = 0; i < leftCount; i++)
            //     items[i].Assign(values[i], env);

            int i = 0;
            foreach (Expression expr in items) {
                values.EmitGet(cg);
                cg.EmitInt(i++);
                cg.Emit(OpCodes.Ldelem_Ref);
                expr.EmitSet(cg);
            }

            cg.FreeLocalTmp(leftCount);
            cg.FreeLocalTmp(rightCount);
            cg.FreeLocalTmp(values);
            cg.FreeLocalTmp(ie);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:64,代码来源:Expressions.cs

示例6: Emit

 internal override void Emit(CodeGen cg)
 {
     cg.EmitPosition(this);
     string suffix = "";
     if (dest != null) suffix = "WithDest";
     if (exprs.Length == 0) {
         cg.EmitSystemState();
         if (dest != null) dest.Emit(cg);
         cg.EmitCall(typeof(Ops), "PrintNewline" + suffix);
     } else {
         Slot destSlot = null;
         if (dest != null) {
             destSlot = cg.GetLocalTmp(typeof(object));
             dest.Emit(cg);
             destSlot.EmitSet(cg);
         }
         for (int i = 0; i < exprs.Length; i++) {
             cg.EmitSystemState();
             if (dest != null) {
                 Debug.Assert(destSlot != null);
                 destSlot.EmitGet(cg);
             }
             exprs[i].Emit(cg);
             if (i < exprs.Length - 1 || trailingComma) cg.EmitCall(typeof(Ops), "PrintComma" + suffix);
             else cg.EmitCall(typeof(Ops), "Print" + suffix);
         }
         if (destSlot != null) {
             cg.FreeLocalTmp(destSlot);
         }
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:31,代码来源:Statements.cs

示例7: EmitNewEnvironment

        public override void EmitNewEnvironment(CodeGen cg)
        {
            ConstructorInfo ctor = EnvironmentType.GetConstructor(
              ScriptDomainManager.Options.DebugMode ?
                new Type[] {
                    StorageType,
                    typeof(SymbolId[]),
                    } :
                new Type[] {
                    StorageType,
                });

            // emit: dict.Tuple[.Item000...].Item000 = dict, and then leave dict on the stack

            cg.EmitNew(ctor);
            cg.Emit(OpCodes.Dup);

            Slot tmp = cg.GetLocalTmp(EnvironmentType);
            tmp.EmitSet(cg);

            cg.EmitPropertyGet(EnvironmentType, "TupleData");

            PropertyInfo last = null;
            foreach (PropertyInfo pi in Tuple.GetAccessPath(StorageType, 0)) {
                if (last != null) {
                    cg.EmitPropertyGet(last);
                }
                last = pi;
            }

            tmp.EmitGet(cg);
            cg.EmitPropertySet(last);

            cg.FreeLocalTmp(tmp);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:35,代码来源:PropertyEnvironmentFactory.cs

示例8: EmitNestedTupleInit

        private static void EmitNestedTupleInit(CodeGen cg, Type storageType)
        {
            if (Tuple.GetSize(storageType) > Tuple.MaxSize)
              {

            Slot tmp = cg.GetLocalTmp(storageType);
            tmp.EmitSet(cg);

            Type[] nestedTuples = storageType.GetGenericArguments();
            for (int i = 0; i < nestedTuples.Length; i++)
            {
              Type t = nestedTuples[i];
              if (t.IsSubclassOf(typeof(Tuple)))
              {
                tmp.EmitGet(cg);

                cg.EmitNew(t.GetConstructor(ArrayUtils.EmptyTypes));
                cg.EmitPropertySet(storageType, String.Format("Item{0:D3}", i));

                tmp.EmitGet(cg);
                cg.EmitPropertyGet(storageType, String.Format("Item{0:D3}", i));

                EmitNestedTupleInit(cg, t);
              }
            }

            cg.FreeLocalTmp(tmp);
              }
              else
              {
            int capacity = 0;
            foreach (Type t in storageType.GetGenericArguments())
            {
              if (t == typeof(None))
              {
                break;
              }
              capacity++;
            }
            cg.EmitInt(capacity);
            cg.EmitCall(typeof(RuntimeHelpers), "UninitializeEnvironmentTuple");
              }
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:43,代码来源:PropertyEnvironmentFactory.cs

示例9: EmitGeneratorTry


//.........这里部分代码省略.........
                    cg.BeginCatchBlock(cb.Test);

                    if (cb.Yield) {
                        // The catch block body contains yield, therefore
                        // delay the body emit till after the try block.
                        Slot slot = cg.GetLocalTmp(cb.Test);
                        slot.EmitSet(cg);
                        catches.Add(new CatchRecord(slot, cb));
                    } else {
                        // Save the exception (if the catch block asked for it) or pop
                        EmitSaveExceptionOrPop(cg, cb);
                        // Emit the body right now, since it doesn't contain yield
                        cb.Body.Emit(cg);
                    }
                }

                cg.PopTargets(TargetBlockType.Catch);
                cg.EndExceptionBlock();
                cg.PopTargets(TargetBlockType.Try);

                //******************************************************************
                // Emit the postponed catch block bodies (with yield in them)
                //******************************************************************
                foreach (CatchRecord cr in catches) {
                    Label next = cg.DefineLabel();
                    cr.Slot.EmitGet(cg);
                    cg.EmitNull();
                    cg.Emit(OpCodes.Beq, next);

                    if (cr.Block.Slot != null) {
                        cr.Block.Slot.EmitSet(cg, cr.Slot);
                    }

                    cg.FreeLocalTmp(cr.Slot);
                    cr.Block.Body.Emit(cg);
                    cg.MarkLabel(next);
                    //cg.EmitSequencePointNone();
                }
            }

            //******************************************************************
            // Emit the finally body
            //******************************************************************

            if (_finally != null) {
                cg.MarkLabel(endFinallyBlock);
                cg.PushExceptionBlock(TargetBlockType.Catch, flowControlFlag);
                cg.BeginCatchBlock(typeof(Exception));
                exception.EmitSet(cg);

                cg.PopTargets(TargetBlockType.Catch);

                cg.PushExceptionBlock(TargetBlockType.Finally, flowControlFlag);
                cg.BeginFinallyBlock();

                Label noExit = cg.DefineLabel();
                cg.GotoRouter.EmitGet(cg);
                cg.EmitInt(CodeGen.GotoRouterYielding);
                cg.Emit(OpCodes.Bne_Un_S, noExit);
                cg.Emit(OpCodes.Endfinally);
                cg.MarkLabel(noExit);

                EmitYieldDispatch(_finallyYields, cg);

                // Emit the finally body
开发者ID:robertlj,项目名称:IronScheme,代码行数:66,代码来源:TryStatement.cs

示例10: EmitSimpleTry


//.........这里部分代码省略.........
                }
            }

            //******************************************************************
            // 1. ENTERING TRY
            //******************************************************************

            cg.PushExceptionBlock(TargetBlockType.Try, flowControlFlag);
            cg.BeginExceptionBlock();

            //******************************************************************
            // 2. Emit the try statement body
            //******************************************************************

            _body.Emit(cg);
            //cg.EmitSequencePointNone();

            //******************************************************************
            // 3. Emit the catch blocks
            //******************************************************************

            if (HaveHandlers()) {
                cg.PushExceptionBlock(TargetBlockType.Catch, flowControlFlag);

                foreach (CatchBlock cb in _handlers) {
                    // Begin the strongly typed exception block
                    cg.BeginCatchBlock(cb.Test);

                    // Save the exception (if the catch block asked for it) or pop
                    EmitSaveExceptionOrPop(cg, cb);

                    //
                    // Emit the catch block body
                    //
                    cb.Body.Emit(cg);
                }

                cg.PopTargets(TargetBlockType.Catch);
            }

            //******************************************************************
            // 4. Emit the finally block
            //******************************************************************

            if (_finally != null) {
                Slot rethrow = null;
                if (flow.Any) {
                    // If there is a control flow in finally, end the catch
                    // statement and emit the catch-all and finally clause
                    // with rethrow at the end.

                    if (HaveHandlers()) {
                        cg.EndExceptionBlock();
                        cg.PopTargets(TargetBlockType.Try);
                    }

                    cg.PushExceptionBlock(TargetBlockType.Catch, flowControlFlag);
                    cg.BeginCatchBlock(typeof(Exception));

                    rethrow = cg.GetLocalTmp(typeof(Exception));
                    rethrow.EmitSet(cg);

                    cg.PopTargets(TargetBlockType.Catch);
                }

                cg.PushExceptionBlock(TargetBlockType.Finally, flowControlFlag);
                cg.BeginFinallyBlock();

                //
                // Emit the finally block body
                //
                _finally.Emit(cg);

                if (flow.Any) {
                    Debug.Assert(rethrow != null);
                    Label noRethrow = cg.DefineLabel();

                    rethrow.EmitGet(cg);
                    cg.EmitNull();
                    cg.Emit(OpCodes.Beq, noRethrow);
                    rethrow.EmitGet(cg);
                    cg.Emit(OpCodes.Throw);
                    cg.MarkLabel(noRethrow);
                }

                cg.EndExceptionBlock();
                cg.PopTargets(TargetBlockType.Finally);
            } else {
                cg.EndExceptionBlock();
            }

            cg.PopTargets(TargetBlockType.Try);

            //
            // Emit the flow control for finally, if there was any.
            //
            EmitFinallyFlowControl(cg, flow, flowControlFlag);

            cg.FreeLocalTmp(flowControlFlag);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:101,代码来源:TryStatement.cs

示例11: EmitIndirectedSymbol

        public void EmitIndirectedSymbol(CodeGen cg, SymbolId id)
        {
            Slot value;
            if (!indirectSymbolIds.TryGetValue(id, out value)) {
                // create field, emit fix-up...

                value = AddStaticField(typeof(int), FieldAttributes.Private, "symbol_" + SymbolTable.IdToString(id));
                CodeGen init = GetOrMakeInitializer();
                Slot localTmp = init.GetLocalTmp(typeof(SymbolId));
                init.EmitString((string)SymbolTable.IdToString(id));
                init.EmitCall(typeof(SymbolTable), "StringToId");
                localTmp.EmitSet(init);
                localTmp.EmitGetAddr(init);
                init.EmitFieldGet(typeof(SymbolId), "Id");
                value.EmitSet(init);

                cg.FreeLocalTmp(localTmp);
                indirectSymbolIds[id] = value;
            }

            value.EmitGet(cg);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:22,代码来源:TypeGen.cs

示例12: EmitFunctionImplementation

        /// <summary>
        /// Emits the raw function implementation into a method body.  Requires both a
        /// code gen for the method and for any initialization that might be required
        /// before the method is run (a module init or type cctor).  True if the method
        /// requires context, false if it doesn't.
        /// </summary>
        /// <param name="cg"></param>
        /// <param name="icg"></param>
        /// <param name="context"></param>
        internal void EmitFunctionImplementation(CodeGen methodCodeGen, CodeGen initCodeGen)
        {
            if (EmitLocalDictionary) {
                PromoteLocalsToEnvironment();
            }

            // emit the actual body
            if (yieldCount > 0) {
                EmitGeneratorBody(methodCodeGen, initCodeGen);
            } else {
                Slot dummySlot = methodCodeGen.GetLocalTmp(typeof(object));
                methodCodeGen.EmitTraceBackTryBlockStart(dummySlot);
                methodCodeGen.FuncOrClassName = name.ToString();
                methodCodeGen.EmitSetTraceBackUpdateStatus(false);

                EmitFunctionBody(methodCodeGen, initCodeGen);

                methodCodeGen.FreeLocalTmp(dummySlot);
                methodCodeGen.EmitTraceBackFaultBlock();
            }
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:30,代码来源:FuncDef.cs

示例13: EmitGenerator

        private void EmitGenerator(CodeGen ncg)
        {
            YieldTarget[] targets = YieldLabelBuilder.BuildYieldTargets(this, ncg);

            Label[] jumpTable = new Label[yieldCount];
            for (int i = 0; i < yieldCount; i++) jumpTable[i] = targets[i].TopBranchTarget;
            ncg.yieldLabels = jumpTable;

            // Generator will ofcourse yield, but we are not interested in the isBlockYielded value
            // hence push a dummySlot to pass the Assertion.

            Slot dummySlot = ncg.GetLocalTmp(typeof(object));
            ncg.PushTryBlock(dummySlot);
            ncg.BeginExceptionBlock();

            ncg.Emit(OpCodes.Ldarg_0);
            ncg.EmitFieldGet(typeof(Generator), "location");
            ncg.Emit(OpCodes.Switch, jumpTable);

            // fall-through on first pass
            // yield statements will insert the needed labels after their returns
            Body.Emit(ncg);
            //free the dummySlot
            ncg.FreeLocalTmp(dummySlot);
            // fall-through is almost always possible in generators, so this
            // is almost always needed
            ncg.EmitReturnInGenerator(null);

            // special handling for StopIteration thrown in body
            ncg.BeginCatchBlock(typeof(StopIterationException));
            ncg.EndExceptionBlock();
            ncg.EmitReturnInGenerator(null);
            ncg.PopTargets();

            ncg.Finish();
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:36,代码来源:FuncDef.cs

示例14: EmitGenerator

        private void EmitGenerator(CodeGen ncg)
        {
            Debug.Assert(_topTargets != null);

            Label[] jumpTable = new Label[_topTargets.Count];
            for (int i = 0; i < jumpTable.Length; i++) {
                jumpTable[i] = _topTargets[i].EnsureLabel(ncg);
            }
            ncg.YieldLabels = jumpTable;

            Slot router = ncg.GetLocalTmp(typeof(int));
            ncg.EmitGetGeneratorLocation();
            router.EmitSet(ncg);
            ncg.GotoRouter = router;
            router.EmitGet(ncg);
            ncg.Emit(OpCodes.Switch, jumpTable);

            // fall-through on first pass
            // yield statements will insert the needed labels after their returns
            Body.Emit(ncg);
            // fall-through is almost always possible in generators, so this
            // is almost always needed
            ncg.EmitReturnInGenerator(null);
            ncg.Finish();

            ncg.GotoRouter = null;
            ncg.FreeLocalTmp(router);
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:28,代码来源:GeneratorCodeBlock.cs

示例15: Emit

        internal override void Emit(CodeGen cg)
        {
            Slot list = cg.GetLocalTmp(typeof(List));
            cg.EmitCall(typeof(Ops), "MakeList", Type.EmptyTypes);
            list.EmitSet(cg);

            // first loop: how many For; initialize labels/slots
            int iFors = 0;
            foreach (ListComprehensionIterator iter in iters) {
                if (iter is ListComprehensionFor) iFors++;
            }

            Label[] continueTargets = new Label[iFors];
            Slot[] enumerators = new Slot[iFors];
            int jIters = iters.Length;
            Label[] exitTargets = new Label[jIters];

            for (int i = 0; i < iFors; i++) {
                continueTargets[i] = cg.DefineLabel();
                enumerators[i] = cg.GetLocalTmp(typeof(IEnumerator));
            }
            for (int i = 0; i < jIters; i++) {
                exitTargets[i] = cg.DefineLabel();
            }

            // second loop: before emiting item
            iFors = jIters = 0;
            foreach (ListComprehensionIterator iter in iters) {
                if (iter is ListComprehensionFor) {
                    ListComprehensionFor cfor = iter as ListComprehensionFor;
                    cfor.List.Emit(cg);
                    cg.EmitCall(typeof(Ops), "GetEnumeratorForIteration");
                    enumerators[iFors].EmitSet(cg);

                    cg.MarkLabel(continueTargets[iFors]);

                    enumerators[iFors].EmitGet(cg);
                    cg.EmitCall(typeof(IEnumerator), "MoveNext", Type.EmptyTypes);
                    cg.Emit(OpCodes.Brfalse, exitTargets[jIters]);

                    enumerators[iFors].EmitGet(cg);
                    cg.EmitCall(typeof(IEnumerator).GetProperty("Current").GetGetMethod());

                    cfor.Left.EmitSet(cg);
                    iFors++;
                } else if (iter is ListComprehensionIf) {
                    ListComprehensionIf cif = iter as ListComprehensionIf;

                    cg.EmitTestTrue(cif.Test);
                    cg.Emit(OpCodes.Brfalse, exitTargets[jIters]);
                }

                jIters++;
            }

            // append the item
            list.EmitGet(cg);
            this.item.Emit(cg);
            cg.EmitCall(typeof(List), "Append");

            // third loop: in reverse order
            iFors = continueTargets.Length - 1;
            jIters = iters.Length - 1;
            while (jIters >= 0) {
                ListComprehensionIterator iter = iters[jIters];
                if (iter is ListComprehensionFor) {
                    cg.Emit(OpCodes.Br, continueTargets[iFors]);
                    cg.FreeLocalTmp(enumerators[iFors]);
                    iFors--;
                }

                cg.MarkLabel(exitTargets[jIters]);
                jIters--;
            }

            list.EmitGet(cg);
            cg.FreeLocalTmp(list);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:78,代码来源:Expressions.cs


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