System.Xml.Xsl.IlGen.GenerateHelper.ConvBranchToBool C# (CSharp) Method

ConvBranchToBool() public method

Assume a branch instruction has already been issued. If isTrueBranch is true, then the true path is linked to lblBranch. Otherwise, the false path is linked to lblBranch. Convert this "branching" boolean logic into an explicit push of 1 or 0 onto the stack.
public ConvBranchToBool ( Label lblBranch, bool isTrueBranch ) : void
lblBranch Label
isTrueBranch bool
return void
        public void ConvBranchToBool(Label lblBranch, bool isTrueBranch)
        {
            Label lblDone = DefineLabel();

            Emit(isTrueBranch ? OpCodes.Ldc_I4_0 : OpCodes.Ldc_I4_1);
            EmitUnconditionalBranch(OpCodes.Br_S, lblDone);
            MarkLabel(lblBranch);
            Emit(isTrueBranch ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
            MarkLabel(lblDone);
        }