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


C# CodeGen.Finish方法代码示例

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


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

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

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


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