Make canInline() virtual and move some logic there
This commit is contained in:
parent
f3525d8980
commit
01a893a799
|
@ -40,7 +40,12 @@ namespace de4dot.blocks.cflow {
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canInline(MethodDefinition method) {
|
protected virtual bool canInline(MethodDefinition method) {
|
||||||
|
if (MemberReferenceHelper.compareMethodReferenceAndDeclaringType(method, blocks.Method))
|
||||||
|
return false;
|
||||||
|
if (!MemberReferenceHelper.compareTypes(method.DeclaringType, blocks.Method.DeclaringType))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (method.IsStatic)
|
if (method.IsStatic)
|
||||||
return true;
|
return true;
|
||||||
if (method.IsVirtual)
|
if (method.IsVirtual)
|
||||||
|
@ -52,16 +57,12 @@ namespace de4dot.blocks.cflow {
|
||||||
var methodToInline = callInstr.Operand as MethodDefinition;
|
var methodToInline = callInstr.Operand as MethodDefinition;
|
||||||
if (methodToInline == null)
|
if (methodToInline == null)
|
||||||
return false;
|
return false;
|
||||||
if (MemberReferenceHelper.compareMethodReferenceAndDeclaringType(methodToInline, blocks.Method))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!canInline(methodToInline))
|
if (!canInline(methodToInline))
|
||||||
return false;
|
return false;
|
||||||
var body = methodToInline.Body;
|
var body = methodToInline.Body;
|
||||||
if (body == null)
|
if (body == null)
|
||||||
return false;
|
return false;
|
||||||
if (!MemberReferenceHelper.compareTypes(methodToInline.DeclaringType, blocks.Method.DeclaringType))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
var instr = DotNetUtils.getInstruction(body.Instructions, ref index);
|
var instr = DotNetUtils.getInstruction(body.Instructions, ref index);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user