optimize: add a callgraph builder: CHA
[nit.git] / src / analysis / analysis.nit
index f151f4b..d3b551b 100644 (file)
@@ -31,10 +31,14 @@ import inline_methods
 import instantiated_type_analysis
 import reachable_method_analysis
 
+# Global Analysis implementation
+import cha_analysis
+
 # Global Optimizations
 import dead_method_removal
 
 redef class ToolContext
+       readable writable var _global_callgraph: String = "cha"
        readable writable var _no_dead_method_removal: Bool = false
 end
 
@@ -43,6 +47,12 @@ redef class Program
        fun do_global_analysis do
                assert tc.global
 
+               if tc.global_callgraph == "cha" then
+                       var cha = new ChaBuilder(self)
+                       cha.work
+                       rma = cha.context
+               end
+
                # Ensure we have all analysis created
                if rma == null then rma = new DefaultReachableMethodAnalysis
                if ita == null then ita = new DefaultInstantiatedTypeAnalysis