Beispiel #1
0
        /// <summary>
        /// Registers an analysis on this flow graph.
        /// </summary>
        /// <param name="analysis">The analysis to register.</param>
        /// <typeparam name="T">
        /// The type of result produced by the analysis.
        /// </typeparam>
        /// <returns>
        /// A new flow graph that includes the analysis.
        /// </returns>
        public FlowGraph WithAnalysis <T>(IFlowGraphAnalysis <T> analysis)
        {
            var newGraph = new FlowGraph(this);

            newGraph.analysisCache = analysisCache.WithAnalysis <T>(analysis);
            return(newGraph);
        }
Beispiel #2
0
        /// <summary>
        /// Registers a default analysis for a particular type of analysis result.
        /// </summary>
        /// <param name="analysis">
        /// The analysis to register.
        /// </param>
        /// <typeparam name="T">The type of result produced by the analysis.</typeparam>
        public static void Register <T>(IFlowGraphAnalysis <T> analysis)
        {
            Func <FlowGraph, FlowGraphAnalysisCache> createCache =
                graph => new FlowGraphAnalysisCache <T>(analysis);

            foreach (var type in MacroAnalysisCache.GetAssignableTypes(typeof(T)))
            {
                defaults[type] = createCache;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new analysis cache that incorporates a particular
 /// analysis.
 /// </summary>
 /// <param name="analysis">
 /// The analysis to include in the new analysis cache.
 /// </param>
 /// <typeparam name="T">
 /// The result type of the analysis.
 /// </typeparam>
 /// <returns>
 /// A new analysis cache.
 /// </returns>
 public MacroAnalysisCache WithAnalysis <T>(IFlowGraphAnalysis <T> analysis)
 {
     updateLock.EnterReadLock();
     try
     {
         var cache = new FlowGraphAnalysisCache <T>(analysis);
         return(WithAnalysis(typeof(T), cache, true));
     }
     finally
     {
         updateLock.ExitReadLock();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Registers a flow graph analysis with this graph.
 /// </summary>
 /// <param name="analysis">The analysis to register.</param>
 /// <typeparam name="T">
 /// The type of result produced by the analysis.
 /// </typeparam>
 public void AddAnalysis <T>(IFlowGraphAnalysis <T> analysis)
 {
     ImmutableGraph = ImmutableGraph.WithAnalysis <T>(analysis);
 }