From f524989a1e1039149ec1322eaf51b5598b9285f4 Mon Sep 17 00:00:00 2001 From: de4dot Date: Sat, 5 Nov 2011 07:42:58 +0100 Subject: [PATCH] Re-arrange some code --- de4dot.code/renamer/MemberRefs.cs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/de4dot.code/renamer/MemberRefs.cs b/de4dot.code/renamer/MemberRefs.cs index d947a54d..65d09abd 100644 --- a/de4dot.code/renamer/MemberRefs.cs +++ b/de4dot.code/renamer/MemberRefs.cs @@ -623,20 +623,19 @@ namespace de4dot.renamer { var call = instructions[i]; if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt) continue; - var calledMethod = call.Operand as MethodReference; - if (!isWindowsFormsSetNameMethod(calledMethod)) + if (!isWindowsFormsSetNameMethod(call.Operand as MethodReference)) continue; + var ldstr = instructions[i - 1]; if (ldstr.OpCode.Code != Code.Ldstr) continue; - var ldarg = instructions[i - 2]; - if (DotNetUtils.getArgIndex(methodDef.MethodDefinition, ldarg) != 0) - continue; - var className = ldstr.Operand as string; if (className == null) continue; + if (DotNetUtils.getArgIndex(methodDef.MethodDefinition, instructions[i - 2]) != 0) + continue; + findInitializeComponentMethod(methodDef); return className; } @@ -972,12 +971,16 @@ namespace de4dot.renamer { var call = instructions[i]; if (call.OpCode.Code != Code.Call && call.OpCode.Code != Code.Callvirt) continue; - var calledMethod = call.Operand as MethodReference; - if (!isWindowsFormsSetNameMethod(calledMethod)) + if (!isWindowsFormsSetNameMethod(call.Operand as MethodReference)) continue; + var ldstr = instructions[i - 1]; if (ldstr.OpCode.Code != Code.Ldstr) continue; + var fieldName = ldstr.Operand as string; + if (fieldName == null || !variableNameState.IsValidName(fieldName)) + continue; + var ldfld = instructions[i - 2]; var fieldRef = ldfld.Operand as FieldReference; if (fieldRef == null) @@ -986,10 +989,6 @@ namespace de4dot.renamer { if (!ourFields.TryGetValue(new FieldReferenceAndDeclaringTypeKey(fieldRef), out fieldDef)) continue; - var fieldName = ldstr.Operand as string; - if (fieldName == null || !variableNameState.IsValidName(fieldName)) - continue; - if (fieldDef.Renamed) continue;