internal override int GetDeltaDistance()
{
switch ((MethodOp)instr) {
case MethodOp.callvirt:
case MethodOp.call: {
// Add the parameter count to the depth
int depth = (int)meth.GetSig().numPars * -1;
// Check to see if this is an instance method
if (meth.GetSig().HasCallConv(CallConv.Instance)) depth--;
// Check to see if this method uses the optional parameters
if (meth.GetSig().HasCallConv(CallConv.Vararg)) depth += (int)meth.GetSig().numOptPars * -1;
// Check to see if this method uses the generic parameters
if (meth.GetSig().HasCallConv(CallConv.Generic)) depth += (int)meth.GetSig().numGenPars * -1;
// Check if a return value will be placed on the stack.
if (!meth.GetRetType().SameType(PrimitiveType.Void)) depth++;
return depth;
}
case MethodOp.newobj: {
// Add the parameter count to the depth
int depth = (int)meth.GetSig().numPars * -1;
// Check to see if this method uses the optional parameters
if (meth.GetSig().HasCallConv(CallConv.Vararg)) depth += (int)meth.GetSig().numOptPars * -1;
// Check to see if this method uses the generic parameters
if (meth.GetSig().HasCallConv(CallConv.Generic)) depth += (int)meth.GetSig().numGenPars * -1;
// Add the object reference that is loaded onto the stack
depth++;
return depth;
}
case MethodOp.ldtoken:
case MethodOp.ldftn:
return 1;
case MethodOp.jmp:
case MethodOp.ldvirtfn:
return 0;
default:
// Someone has added a new MethodOp and not added a case for it here.
throw new Exception("The MethodOp for this MethoInstr is not supported.");
}
}