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


C# CodeGen.EmitTestTrue方法代码示例

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


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

示例1: Emit

 internal override void Emit(CodeGen cg)
 {
     if (Options.DebugMode) {
         cg.EmitPosition(this);
         cg.EmitTestTrue(test);
         Label endLabel = cg.DefineLabel();
         cg.Emit(OpCodes.Brtrue, endLabel);
         cg.EmitExprOrNone(message);
         cg.EmitConvertFromObject(typeof(string));
         cg.EmitCall(typeof(Ops), "AssertionError", new Type[] { typeof(string) });
         cg.Emit(OpCodes.Throw);
         cg.MarkLabel(endLabel);
     }
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:14,代码来源:Statements.cs

示例2: EmitWithFinallyBlock

        private void EmitWithFinallyBlock(CodeGen cg, Slot exc, Slot exit, Slot isTryYielded)
        {
            // we are certain that Finally will never yield
            cg.PushFinallyBlock(null, null);
            cg.BeginFinallyBlock();

            //finally body
            Label endOfFinally = cg.DefineLabel();

            // isTryYielded == True ?
            isTryYielded.EmitGet(cg);
            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brtrue, endOfFinally);

            // exc == False ?
            exc.EmitGet(cg);
            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brfalse, endOfFinally);

            //exit(None, None, None)
            cg.EmitCallerContext();
            exit.EmitGet(cg);
            cg.Emit(OpCodes.Ldnull);
            cg.Emit(OpCodes.Ldnull);
            cg.Emit(OpCodes.Ldnull);
            cg.EmitCall(typeof(Ops), "CallWithContext", new Type[] { typeof(ICallerContext), typeof(object), typeof(object), typeof(object), typeof(object) });
            cg.Emit(OpCodes.Pop);

            cg.MarkLabel(endOfFinally);
            cg.PopTargets();

            // finally end
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:33,代码来源:Statements.cs

示例3: EmitWithCatchBlock

        private void EmitWithCatchBlock(CodeGen cg, Slot exc, Slot exit)
        {
            cg.BeginCatchBlock(typeof(Exception));
            // Extract state from the carrier exception
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ExtractException",
                new Type[] { typeof(Exception), typeof(ICallerContext) });
            cg.Emit(OpCodes.Pop);

            // except body
            cg.PushExceptionBlock(Targets.TargetBlockType.Catch, null, null);
            cg.EmitConstantBoxed(false);
            exc.EmitSet(cg);

            cg.EmitCallerContext();
            exit.EmitGet(cg);
            cg.EmitObjectArray(new Expression[0]);
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ExtractSysExcInfo");
            cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndContext", new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(object) });

            Label afterRaise = cg.DefineLabel();

            cg.EmitTestTrue();
            cg.Emit(OpCodes.Brtrue, afterRaise);
            cg.EmitCall(typeof(Ops), "Raise", new Type[0]); //, new Type[] { typeof(object), typeof(SymbolId) });
            cg.MarkLabel(afterRaise);
            cg.EmitCallerContext();
            cg.EmitCall(typeof(Ops), "ClearException", new Type[] { typeof(ICallerContext) });
            cg.PopTargets();
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:31,代码来源:Statements.cs

示例4: Emit

 internal override void Emit(CodeGen cg)
 {
     Label eoi = cg.DefineLabel();
     Label next = cg.DefineLabel();
     cg.EmitTestTrue(testExpr);
     cg.Emit(OpCodes.Brfalse, next);
     trueExpr.Emit(cg);
     cg.Emit(OpCodes.Br, eoi);
     cg.MarkLabel(next);
     falseExpr.Emit(cg);
     cg.MarkLabel(eoi);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:12,代码来源:Expressions.cs

示例5: FinishCompare

        internal void FinishCompare(CodeGen cg)
        {
            BinaryExpression bright = (BinaryExpression)right;

            Slot valTmp = cg.GetLocalTmp(typeof(object));
            Slot retTmp = cg.GetLocalTmp(typeof(object));
            bright.left.Emit(cg);
            cg.Emit(OpCodes.Dup);
            valTmp.EmitSet(cg);

            cg.EmitCall(op.Target.Method);
            cg.Emit(OpCodes.Dup);
            retTmp.EmitSet(cg);
            cg.EmitTestTrue();

            Label end = cg.DefineLabel();
            cg.Emit(OpCodes.Brfalse, end);

            valTmp.EmitGet(cg);

            if (IsComparison(bright.right)) {
                bright.FinishCompare(cg);
            } else {
                bright.right.Emit(cg);
                cg.EmitCall(bright.op.Target.Method);
            }

            retTmp.EmitSet(cg);
            cg.MarkLabel(end);
            retTmp.EmitGet(cg);
        }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:31,代码来源:Expressions.cs


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