private TripleObject BuildFromTriple(Instruction fromInstruction, string fromInstanceOwnerKey, MethodDefinition parentMethod) { var tripleObj = new TripleObject(); tripleObj.Instruction = fromInstruction; var fromObjectType = InstructionKeyService.GetFromObjectType(fromInstruction); tripleObj.ObjectType = fromObjectType; if (fromObjectType == ObjectType.Argument) { int fromArgumentIndex = (int)DecompilerService.GetPosition(fromInstruction); tripleObj.ObjectKey = InstructionKeyService.GetObjectKey(fromInstruction, fromObjectType, parentMethod, fromArgumentIndex); } else { tripleObj.ObjectKey = InstructionKeyService.GetObjectKey(fromInstruction, fromObjectType, parentMethod); } tripleObj.InstructionKey = InstructionKeyService.GetInstructionKey(fromInstruction, parentMethod); tripleObj.OwnerTypeCategory = InstructionKeyService.GetTypeCategory(fromInstruction); tripleObj.OwnerTypeKey = InstructionKeyService.GetTypeKey(fromInstruction); tripleObj.InheritsFromConcreteClass = InstructionKeyService.GetConcreteInheritance(fromInstruction); tripleObj.InstanceOwnerKey = fromInstanceOwnerKey; return(tripleObj); }
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); } }