metamodel: rename 'universal' to 'enum'
[nit.git] / src / analysis / reachable_as_init.nit
index 247d49c..2f65f7a 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Package containing all bases for the reachable from init method analysis
+# Module containing all bases for the reachable from init method analysis
 package reachable_as_init
 
 import icode
@@ -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}/{main_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
@@ -35,7 +51,7 @@ end
 
 # Default behavior is to say that all initializers are called as init
 class DefaultReachableAsInitAnalysis
-special ReachableAsInitAnalysis
+       super ReachableAsInitAnalysis
        redef fun is_method_reachable_as_init(method: MMMethod, c: MMLocalClass): Bool do
                if method.global.is_init and method.global.is_init_for(c) then return true
                return false