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);
}