Esempio n. 1
0
        public static void TraverseForFields(ISet <Assembly> assemblies)
        {
            foreach (Assembly assembly in assemblies)
            {
                foreach (IMethodDefinition methodDefinition in assembly.GetAllDefinedMethods())
                {
                    var disassembler = new TinyBCT.Translators.Disassembler(assembly.Host, methodDefinition, assembly.PdbReader);
                    disassembler.Execute();

                    ReferenceFinder reference = new ReferenceFinder();
                    reference.CollectFields(disassembler.MethodBody);
                }
            }
        }
Esempio n. 2
0
        public IEnumerable <IMethodReference> FindPropertiesCalls(ISet <Assembly> assemblies)
        {
            var allDefinedMethods      = assemblies.GetAllDefinedMethods();
            var definedMethodsWithBody = allDefinedMethods.Where(m => m.Body != null && m.Body.Size > 0);

            Function <IMethodDefinition, MethodBody> disassemble = (method) =>
            {
                var disassembler = new TinyBCT.Translators.Disassembler(assemblies.First().Host, method, assemblies.First().PdbReader);
                disassembler.Execute();
                return(disassembler.MethodBody);
            };

            var methodBodies = definedMethodsWithBody.Select(m => disassemble(m).Instructions);

            return(methodBodies.SelectMany(body => FindPropertiesCalls(body)));
        }
Esempio n. 3
0
        public static void WriteTAC(ISet <Assembly> assemblies)
        {
            foreach (Assembly a in assemblies)
            {
                Open(a.Module.Location);
                foreach (IMethodDefinition methodDefinition in a.GetAllDefinedMethods())
                {
                    if (methodDefinition.Body.Size > 0)
                    {
                        var disassembler = new TinyBCT.Translators.Disassembler(a.Host, methodDefinition, a.PdbReader);
                        disassembler.Execute();

                        TACWriter.AddMethod(disassembler.MethodBody);
                        TACWriter.Write();
                    }
                }
                Close();
            }
        }
Esempio n. 4
0
        public override void TraverseChildren(IMethodDefinition methodDefinition)
        {
            //var signature = MemberHelper.GetMethodSignature(methodDefinition, NameFormattingOptions.Signature | NameFormattingOptions.ParameterName);
            //System.Console.WriteLine(signature);

            if (methodDefinition.IsAbstract || methodDefinition.IsExternal)
            {
                return;
            }

            var disassembler = new TinyBCT.Translators.Disassembler(host, methodDefinition, sourceLocationProvider);

            disassembler.Execute();
            foreach (var instruction in disassembler.MethodBody.Instructions)
            {
                var visitor = new AllocAndDelegateFinderVisitor(this);
                instruction.Accept(visitor);
            }
        }