public static string GetObjectKey(Instruction instruction, ObjectType objectType, MethodReference methodOfArgument, int?argumentIndex = null) { if (objectType == ObjectType.Argument && !argumentIndex.HasValue) { argumentIndex = (int)DecompilerService.GetPosition(instruction); } switch (objectType) { case ObjectType.Argument: return(methodOfArgument.GetKey() + ">>" + argumentIndex); case ObjectType.NilArgument: var nilArgMethodReference = (MethodReference)instruction.Operand; return(nilArgMethodReference.GetKey() + ">>0"); case ObjectType.Field: var fieldReference = (FieldReference)instruction.Operand; return(fieldReference.GetKey()); case ObjectType.LocalVariable: var stackPosition = DecompilerService.GetPosition(instruction); return(methodOfArgument.GetKey() + " StackPosition:" + stackPosition); case ObjectType.ReturnValue: return(methodOfArgument.GetKey() + ">>return"); case ObjectType.Method: var methodReference = (MethodReference)instruction.Operand; return(methodReference.GetKey() + ">>return"); case ObjectType.InlineString: return(instruction.Operand.ToString()); case ObjectType.InlineNumber: var number = DecompilerService.GetPosition(instruction); return(number.ToString()); case ObjectType.None: return(null); default: throw new ILParseException("Unsupported ObjectType: " + objectType); } }
public static string GetFullMethodSignature(MethodReference method) { if (_fullSignatures.ContainsKey(method.FullName)) { return(_fullSignatures[method.FullName]); } var signature = method.GetKey(); _fullSignatures.Add(method.FullName, signature); return(signature); }
//public static string GetLinkKey(Instruction instruction, string objectKey, MethodReference methodOfInstruction) //{ // int arrowIndex = objectKey.IndexOf(">>"); // if (arrowIndex > -1) // { // return objectKey.Substring(0, arrowIndex) + GetInstructionKey(instruction, methodOfInstruction); // } // //else if(objectKey.IndexOf("get_") > -1 || objectKey.IndexOf("set_") > -1) // //{ // // return objectKey.Substring(0, objectKey.LastIndexOf("(")).Replace("set_", "").Replace("get_", "") + "()"; // //} // return objectKey + instruction.Offset + GetInstructionKey(instruction, methodOfInstruction); //} public static string GetInstructionKey(Instruction instruction, MethodReference methodOfInstruction) { return("|" + methodOfInstruction.GetKey().GetHashCode() + "@" + instruction.Offset); }