// This method is used during FactGeneration. The above CheckAndAdd methods are used during RTAAnalysis. // Since we are not modifying invoke statments to invoke methods in stubs (whenever stubs are used), we need the below method. public static IMethodDefinition GetMethodToAnalyze(IMethodDefinition m) { // Three cases: m should completely be ignored, should be analyzed as is, or the equivalent stub should be analyzed. IMethodDefinition methToAnalyze = m; bool matches = MatchesSuppressM(m); if (matches) { ITypeDefinition containingType = m.ContainingTypeDefinition; containingType = Stubs.GetStubType(containingType); if (containingType == null) { return(null); // This entire containingType is to be ignored. } if (methToAnalyze is IGenericMethodInstance) { methToAnalyze = GenericMethods.GetTemplate(m); } methToAnalyze = Utils.GetMethodSignMatch(containingType, methToAnalyze); if (methToAnalyze == null) { return(null); // containingType itself is stubbed, but the stub does not define a method equivalent to m. } if (methToAnalyze.IsGeneric) { methToAnalyze = GenericMethods.GetInstantiatedMeth(methToAnalyze, m); } } return(methToAnalyze); }
/**** * Four cases: * 1. Ordinary method (not stubbed and not generic) * 2. Stubbed but not generic * 3. Not stubbed but generic * 4. Stubbed and generic * Note that there are two sub-cases for "is stubbed": "stub present" or "stub absent". * So that makes it a total of 6 cases. ****/ public static IMethodDefinition CheckAndAdd(IMethodDefinition m) { IMethodDefinition lookFor = m; if (m is IGenericMethodInstance) { lookFor = GenericMethods.GetTemplate(m); } ITypeDefinition containingType = m.ContainingTypeDefinition; if (containingType.InternedKey == 0) { return(m); // Ignore methods from Cci's Dummy typeref. } bool matches = MatchesSuppressM(m); if (matches) { containingType = Stubs.GetStubType(containingType); if (containingType == null) { return(null); // This entire containingType is to be ignored. } lookFor = Utils.GetMethodSignMatch(containingType, lookFor); if (lookFor == null) { return(null); // containingType itself is stubbed, but the stub does not define a method equivalent to m. } } IMethodDefinition methToAdd; if (m is IGenericMethodInstance) { // Here, lookFor is a template method methToAdd = GenericMethods.RecordInfo(lookFor, m, matches); } else { methToAdd = lookFor; } if (!rtaAnalyzer.visitedMethods.Contains(methToAdd) && !rtaAnalyzer.methods.Contains(methToAdd)) { rtaAnalyzer.rtaLogSW.WriteLine("SRK_DBG: Adding method: {0}", methToAdd.FullName()); rtaAnalyzer.methods.Add(methToAdd); } return(methToAdd); }