analysis: add logs to reachable as init analysis
authorJean-Sebastien Gelinas <calestar@gmail.com>
Sat, 21 Nov 2009 21:53:36 +0000 (16:53 -0500)
committerJean Privat <jean@pryen.org>
Mon, 11 Jan 2010 21:52:29 +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/reachable_as_init.nit

index b5f9c09..d0f4773 100644 (file)
@@ -81,6 +81,7 @@ redef class Program
                dump_unreachable_methods(directory_name, tc.global_callgraph)
                dump_instantiated_types(directory_name)
                dump_not_instantiated_types(directory_name)
+               dump_reachable_as_init_methods(directory_name)
        end
 end
 
index 247d49c..fa81128 100644 (file)
@@ -23,6 +23,22 @@ import program
 redef class Program
        # This attribute is the ReachableAsInitAnalysis results
        readable writable var _rai: nullable ReachableAsInitAnalysis = null
+
+       # This method will create a file and output all inits reachable as init in it
+       fun dump_reachable_as_init_methods(directory_name: String) do
+               var f = new OFStream.open("{directory_name}/{module.name}.reachable_methods_as_init.log")
+               with_each_live_local_classes !action(c) do
+                       for g in c.global_properties do
+                               var p = c[g]
+                               if not p.global.is_init_for(c) then continue
+                               assert p isa MMMethod
+                               if rai.is_method_reachable_as_init(p, c) then
+                                       f.write("{p.full_name}\n")
+                               end
+                       end
+               end
+               f.close
+       end
 end
 
 # Subclasses of this class would represent an analysis that produces