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

TestAndBranch() public method

Compare the top value on the stack with the specified i4 using the specified relational comparison opcode, and branch to lblBranch if the result is true.
public TestAndBranch ( int i4, Label lblBranch, OpCode opcodeBranch ) : void
i4 int
lblBranch Label
opcodeBranch OpCode
return void
        public void TestAndBranch(int i4, Label lblBranch, OpCode opcodeBranch)
        {
            switch (i4)
            {
                case 0:
                    // Beq or Bne can be shortened to Brfalse or Brtrue if comparing to 0
                    if (opcodeBranch.Value == OpCodes.Beq.Value)
                        opcodeBranch = OpCodes.Brfalse;
                    else if (opcodeBranch.Value == OpCodes.Beq_S.Value)
                        opcodeBranch = OpCodes.Brfalse_S;
                    else if (opcodeBranch.Value == OpCodes.Bne_Un.Value)
                        opcodeBranch = OpCodes.Brtrue;
                    else if (opcodeBranch.Value == OpCodes.Bne_Un_S.Value)
                        opcodeBranch = OpCodes.Brtrue_S;
                    else
                        goto default;
                    break;

                default:
                    // Cannot use shortcut, so push integer onto the stack
                    LoadInteger(i4);
                    break;
            }

            Emit(opcodeBranch, lblBranch);
        }