tools: add log information about instantiated and not instantiated types
authorJean-Sebastien Gelinas <calestar@gmail.com>
Sun, 20 Sep 2009 14:50:04 +0000 (10:50 -0400)
committerJean Privat <jean@pryen.org>
Mon, 11 Jan 2010 21:52:26 +0000 (16:52 -0500)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/analysis/analysis.nit
src/analysis/instantiated_type_analysis.nit

index 9e77ff0..0c4077d 100644 (file)
@@ -73,6 +73,8 @@ redef class Program
        fun dump_global_analysis_information(directory_name: String) do
                dump_reachable_methods(directory_name, tc.global_callgraph)
                dump_unreachable_methods(directory_name, tc.global_callgraph)
+               dump_instantiated_types(directory_name)
+               dump_not_instantiated_types(directory_name)
        end
 end
 
index ebf5a9e..3650f44 100644 (file)
@@ -23,6 +23,27 @@ redef class Program
        # This attribute is the InstantiatedTypeAnalysis results
        readable writable var _ita: nullable InstantiatedTypeAnalysis = null
 
+       # This method will create a file and output the name of all types that are instantiated in it
+       fun dump_instantiated_types(directory_name: String) do
+               var f = new OFStream.open("{directory_name}/{module.name}.instantiated_types.log")
+               with_each_live_local_classes !action(c) do
+                       f.write("{c}\n")
+               end
+               f.close
+       end
+
+       # This method will create a file and output the names of all types that are not instantiated in it
+       fun dump_not_instantiated_types(directory_name: String) do
+               var f = new OFStream.open("{directory_name}/{module.name}.not_instantiated_types.log")
+               # Must overwrite 'with_each_local_classes' since we are looking at non-instantiated classes
+               for c in module.local_classes do
+                       if not ita.is_class_instantiated(c) then
+                               f.write("{c}\n")
+                       end
+               end
+               f.close
+       end
+
        # We know which are really live, use that information !
        redef fun with_each_live_local_classes
                !action(m: MMLocalClass)