Пример #1
0
        private Triple GetNilArgumentTriple(Instruction instruction, MethodDefinition parentMethod, string objectInitializerInstanceKey = null)
        {
            var parseResult       = new ParseResult();
            var nilArgumentTriple = new Triple();

            nilArgumentTriple.ParentAssembly = parentMethod.Module.Assembly.Name.Name;
            nilArgumentTriple.ParentMethod   = parentMethod;

            string toInstanceOwnerKey = string.Empty;

            if (objectInitializerInstanceKey != null)
            {
                toInstanceOwnerKey = objectInitializerInstanceKey;
            }
            //else if (MethodArgumentInstructionParser.IsChainedToPreviousInstruction(instruction))
            //    toInstanceOwnerKey = null;
            else
            {
                toInstanceOwnerKey = InstructionKeyService.GetToInstanceOwnerKey(instruction, ObjectType.NilArgument, parentMethod);
            }

            nilArgumentTriple.To              = BuildToTriple(instruction, toInstanceOwnerKey, parentMethod);
            nilArgumentTriple.To.ObjectType   = ObjectType.NilArgument;
            nilArgumentTriple.From            = new TripleObject();
            nilArgumentTriple.From.ObjectType = ObjectType.None;
            return(nilArgumentTriple);
        }
Пример #2
0
        private Triple GetGenericTriple(Instruction instruction,
                                        MethodDefinition parentMethod,
                                        ObjectType toObjectType,
                                        string constructorInstructionKey = null)
        {
            var fromInstruction      = instruction.Previous;
            var fromObjectType       = InstructionKeyService.GetFromObjectType(fromInstruction);
            var fromInstanceOwnerKey = InstructionKeyService.GetFromInstanceOwnerKey(fromInstruction, fromObjectType, parentMethod);

            string toInstanceOwnerKey = string.Empty;

            if (constructorInstructionKey != null)
            {
                toInstanceOwnerKey = null;
            }
            else
            {
                toInstanceOwnerKey = InstructionKeyService.GetToInstanceOwnerKey(instruction, toObjectType, parentMethod);
            }

            var triple = BuildTriple(instruction, toInstanceOwnerKey, fromInstruction, fromInstanceOwnerKey, parentMethod);

            if (constructorInstructionKey != null)
            {
                triple.SetsObjectInitializerMember = true;
                triple.ConstructorInstructionKey   = constructorInstructionKey;
            }

            return(triple);
        }
Пример #3
0
        private List <Triple> GetMethodCallArgumentTriples(MethodDefinition parentMethod, Instruction instruction, string constructorInstructionKey = null)
        {
            var triples      = new List <Triple>();
            var calledMethod = (MethodReference)instruction.Operand;
            var rootNode     = GetInstructionTree(parentMethod, instruction, calledMethod);

            if (rootNode == null)
            {
                return(triples);
            }

            string instanceOwnerKey = string.Empty;

            if (constructorInstructionKey != null)
            {
                instanceOwnerKey = null;
                triples          = TraverseTree(parentMethod, rootNode, instanceOwnerKey, true, constructorInstructionKey);
            }
            else
            {
                instanceOwnerKey = InstructionKeyService.GetToInstanceOwnerKey(instruction, ObjectType.Method, parentMethod);
                triples          = TraverseTree(parentMethod, rootNode, instanceOwnerKey, false);
            }

            return(triples);
        }