PERWAPI.CILInstructions.IntInst C# (CSharp) Method

IntInst() public method

Add an IL instruction with an integer parameter
public IntInst ( IntOp inst, int val ) : void
inst IntOp the IL instruction
val int the integer parameter value
return void
        public void IntInst(IntOp inst, int val)
        {
            if ((inst == IntOp.ldc_i4_s) || (inst == IntOp.ldc_i4)) {
                if ((val < 9) && (val >= -1)) {
                    AddToBuffer(new Instr((Op)((int)Op.ldc_i4_0 + val)));
                } else {
                    AddToBuffer(new IntInstr(inst, val));
                }
            } else
                AddToBuffer(new UIntInstr(inst,(uint)val));
        }

Usage Example

Example #1
0
 private static void loadVar(CILInstructions code, int stackType, int index, int paramCount)
 {
     if (index < paramCount)
       {
     switch (index)
     {
       case 0:  code.Inst(Op.ldarg_0); break;
       case 1:  code.Inst(Op.ldarg_1); break;
       case 2:  code.Inst(Op.ldarg_2); break;
       case 3:  code.Inst(Op.ldarg_3); break;
       default: code.IntInst(IntOp.ldarg, index); break;
     }
       }
       else
       {
     index -= paramCount;
     switch (index)
     {
       case 0:  code.Inst(Op.ldloc_0); break;
       case 1:  code.Inst(Op.ldloc_1); break;
       case 2:  code.Inst(Op.ldloc_2); break;
       case 3:  code.Inst(Op.ldloc_3); break;
       default: code.IntInst(IntOp.ldloc, index); break;
     }
       }
 }