本文整理汇总了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);
}
}
示例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
}
示例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();
}
示例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);
}
示例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);
}