From 01a893a7996990b308064d4ee852b5293b03aed4 Mon Sep 17 00:00:00 2001 From: de4dot Date: Thu, 2 Feb 2012 10:38:56 +0100 Subject: [PATCH] Make canInline() virtual and move some logic there --- blocks/cflow/MethodCallInliner.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blocks/cflow/MethodCallInliner.cs b/blocks/cflow/MethodCallInliner.cs index 0e5f0856..e37b2f69 100644 --- a/blocks/cflow/MethodCallInliner.cs +++ b/blocks/cflow/MethodCallInliner.cs @@ -40,7 +40,12 @@ namespace de4dot.blocks.cflow { 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) return true; if (method.IsVirtual) @@ -52,16 +57,12 @@ namespace de4dot.blocks.cflow { var methodToInline = callInstr.Operand as MethodDefinition; if (methodToInline == null) return false; - if (MemberReferenceHelper.compareMethodReferenceAndDeclaringType(methodToInline, blocks.Method)) - return false; if (!canInline(methodToInline)) return false; var body = methodToInline.Body; if (body == null) return false; - if (!MemberReferenceHelper.compareTypes(methodToInline.DeclaringType, blocks.Method.DeclaringType)) - return false; int index = 0; var instr = DotNetUtils.getInstruction(body.Instructions, ref index);