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


C# CodeGen.EmitTraceBackFaultBlock方法代码示例

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


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

示例1: Emit


//.........这里部分代码省略.........
                Label testFinally = cg.DefineLabel();
                isCatchYielded.EmitGet(cg);
                cg.EmitUnbox(typeof(bool));
                cg.Emit(OpCodes.Brfalse, testFinally);
                storedException.EmitGet(cg);
                cg.EmitCall(typeof(Ops), "Raise", new Type[] { typeof(object) });
                cg.MarkLabel(testFinally);
            }

            // if Finally yielded, Branch to the end of Try block
            Label endOfTry = cg.DefineLabel();
            EmitOnYieldBranchToLabel(finallyYieldTargets, isFinallyYielded, endOfTry, cg);

            Label beginElseBlock = cg.DefineLabel();
            if (IsBlockYieldable(elseYieldTargets)) {
                // isElseYielded ?
                Debug.Assert(isElseYielded != null);
                isElseYielded.EmitGet(cg);
                cg.EmitUnbox(typeof(bool));
                cg.Emit(OpCodes.Brtrue, beginElseBlock);
            }

            EmitYieldDispatch(tryYieldTargets, isTryYielded, tryChoiceVar, cg);

            // if finally block presents, but no exception handler, we add try-fault
            // to update traceback; otherwise, we update the traceback inside exception handler.
            if (finallyStmt != null && handlers == null) {
                Slot dummySlot = cg.GetLocalTmp(typeof(object));
                cg.EmitTraceBackTryBlockStart(dummySlot);

                body.Emit(cg);

                cg.FreeLocalTmp(dummySlot);
                cg.EmitTraceBackFaultBlock();
            } else {
                body.Emit(cg);
            }

            if (elseStmt != null) {
                if (IsBlockYieldable(elseYieldTargets)) {
                    cg.MarkLabel(beginElseBlock);
                }

                cg.PopTargets(Targets.TargetBlockType.Try);
                cg.PushExceptionBlock(Targets.TargetBlockType.Else, flowControlVar, isElseYielded);

                cg.EmitInt(1);
                isElseBlock.EmitSet(cg);

                EmitYieldDispatch(elseYieldTargets, isElseYielded, elseChoiceVar, cg);

                elseStmt.Emit(cg);
                cg.PopTargets(Targets.TargetBlockType.Else);
                cg.PushExceptionBlock(Targets.TargetBlockType.Try, flowControlVar, isTryYielded);

            }

            cg.MarkLabel(endOfTry);

            // get the exception if there is a yield / return  in finally
            if (IsBlockYieldable(finallyYieldTargets) || returnInFinally) {
                cg.BeginCatchBlock(typeof(Exception));
                exception.EmitSet(cg);
            }

            if (handlers != null) {
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:67,代码来源:Statements.cs

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


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