コード例 #1
0
        public static ITypeDefinition GetTypeToAnalyze(ITypeDefinition ty)
        {
            ITypeDefinition retTy   = ty;
            bool            matches = MatchesSuppressM(ty);

            if (matches)
            {
                ITypeDefinition stubType = Stubs.GetStubType(ty);
                if (stubType != null)
                {
                    retTy = stubType;
                }
                else
                {
                    retTy = null;
                }
            }
            return(retTy);
        }
コード例 #2
0
        public static bool TypeMatch(ITypeReference t1, ITypeReference t2)
        {
            ITypeDefinition tdef1 = t1.ResolvedType;
            ITypeDefinition tdef2 = t2.ResolvedType;

            if (tdc.Equals(tdef1, tdef2))
            {
                return(true);
            }

            if (Stubber.MatchesSuppressM(tdef1))
            {
                tdef1 = Stubs.GetStubType(tdef1);
            }
            if (Stubber.MatchesSuppressM(tdef2))
            {
                tdef2 = Stubs.GetStubType(tdef2);
            }
            // return (tdef1 != null && tdef2 != null && tdc.Equals(tdef1, tdef2));
            if (tdef1 != null && tdef2 != null)
            {
                if (tdef1 is IGenericTypeInstance)
                {
                    tdef1 = (tdef1 as IGenericTypeInstance).GenericType.ResolvedType;
                }
                if (tdef2 is IGenericTypeInstance)
                {
                    tdef2 = (tdef2 as IGenericTypeInstance).GenericType.ResolvedType;
                }
                return(tdc.Equals(tdef1, tdef2));
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        static void DoRTA(IMetadataHost host, ClassAndMethodVisitor visitor, IModule rootModule, IModule stubsModule)
        {
            bool rootIsExe = false;

            if (rootModule.Kind == ModuleKind.ConsoleApplication)
            {
                rootIsExe = true;
            }
            StreamWriter rtaLogSW = new StreamWriter(Path.Combine(ConfigParams.LogDir, "rta_log.txt"));

            rtaAnalyzer = new RTAAnalyzer(rootIsExe, rtaLogSW, host);
            visitor.SetupRTAAnalyzer(rtaAnalyzer);
            Stubber.SetupRTAAnalyzer(rtaAnalyzer);
            Stubs.SetupInternFactory(host.InternFactory);
            GenericMethods.SetupInternFactory(host.InternFactory);
            Stubs.SetupStubs(stubsModule);

            bool diskLoadSuccessful = false;

            if (ConfigParams.LoadSavedScope)
            {
                diskLoadSuccessful = rtaAnalyzer.LoadSavedScope(host);
            }
            if (!diskLoadSuccessful)
            {
                Initialize(rtaAnalyzer.classes, rtaAnalyzer.entryPtClasses, rootModule, rootIsExe);
            }

            int  iterationCount = 0;
            bool changeInCount = true;
            int  startClassCnt, startMethCnt;

            while (changeInCount)
            {
                rtaLogSW.WriteLine();
                rtaLogSW.WriteLine("Starting RTA ITERATION:{0}", iterationCount);
                startClassCnt = rtaAnalyzer.classes.Count;
                startMethCnt  = rtaAnalyzer.methods.Count;
                rtaLogSW.WriteLine("Counts: classes:{0}   methods:{1}", startClassCnt, startMethCnt);
                rtaAnalyzer.classWorkList.Clear();
                rtaAnalyzer.visitedClasses.Clear();
                rtaAnalyzer.ignoredClasses.Clear();
                rtaAnalyzer.visitedMethods.Clear();
                rtaAnalyzer.ignoredMethods.Clear();
                CopyAll(rtaAnalyzer.classes, rtaAnalyzer.classWorkList);
                while (rtaAnalyzer.classWorkList.Count > 0)
                {
                    ITypeDefinition ty = rtaAnalyzer.classWorkList.First <ITypeDefinition>();
                    rtaAnalyzer.classWorkList.RemoveAt(0);
                    visitor.Traverse(ty);
                }
                if (rtaAnalyzer.classes.Count == startClassCnt && rtaAnalyzer.methods.Count == startMethCnt)
                {
                    changeInCount = false;
                }
                iterationCount++;
            }
            Copy(rtaAnalyzer.allocClasses, rtaAnalyzer.classes);
            rtaLogSW.WriteLine();
            rtaLogSW.WriteLine();
            foreach (IMethodDefinition m in rtaAnalyzer.methods)
            {
                rtaLogSW.WriteLine(m.FullName());
            }
            rtaLogSW.WriteLine();
            rtaLogSW.WriteLine();
            foreach (IMethodDefinition m in rtaAnalyzer.entryPtMethods)
            {
                rtaLogSW.WriteLine(m.FullName());
            }
            rtaLogSW.WriteLine();
            rtaLogSW.WriteLine();
            foreach (ITypeDefinition cl in rtaAnalyzer.classes)
            {
                rtaLogSW.WriteLine(cl.FullName());
            }

            rtaLogSW.WriteLine();
            rtaLogSW.WriteLine("ALLOC CLASSES");
            foreach (ITypeDefinition cl in rtaAnalyzer.allocClasses)
            {
                rtaLogSW.WriteLine(cl.FullName());
            }
            rtaLogSW.WriteLine("+++++++++++++++ RTA DONE ++++++++++++++++++");

            if (!diskLoadSuccessful)
            {
                rtaAnalyzer.SaveScope(host);
            }
            rtaLogSW.Close();
        }