tools: add a function to go through every methods in a program
authorJean-Sebastien Gelinas <calestar@gmail.com>
Fri, 18 Sep 2009 19:50:16 +0000 (15:50 -0400)
committerJean Privat <jean@pryen.org>
Mon, 11 Jan 2010 21:52:25 +0000 (16:52 -0500)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>
Signed-off-by: Jean Privat <jean@pryen.org>

src/program.nit

index 574def7..07c5277 100644 (file)
@@ -191,6 +191,23 @@ class Program
                end
        end
 
+       # This function will call the attached block for each MMMethods
+       # in this program
+       fun with_each_methods
+               !action(m: MMMethod)
+       do
+               for m in module.mhe.greaters_and_self do
+                       for c in m.local_classes do
+                               # Process methods and attributes initialization
+                               for p in c.local_local_properties do
+                                       if p isa MMMethod then
+                                               action(p)
+                                       end
+                               end
+                       end
+               end
+       end
+
        init(m: MMModule, toolcontext: ToolContext) do
                _module = m
                _tc = toolcontext