[Mumps2Py:] [137] Another info-screen; What other routines in the file are calling the current routine ? Note that since this parses the entire file, it can take a good while to process.

[ Thread Index | Date Index | More lists.mumps2py.org/discuss Archives ]


Revision: 137
Author:   pgallot
Date:     2008-02-27 19:04:48 +0000 (Wed, 27 Feb 2008)

Log Message:
-----------
Another info-screen; What other routines in the file are calling the current routine ?  Note that since this parses the entire file, it can take a good while to process. 

Modified Paths:
--------------
    trunk/mumps2py_ui.pyw


Modified: trunk/mumps2py_ui.pyw
===================================================================
--- trunk/mumps2py_ui.pyw	2008-02-27 17:30:41 UTC (rev 136)
+++ trunk/mumps2py_ui.pyw	2008-02-27 19:04:48 UTC (rev 137)
@@ -129,8 +129,8 @@
 
 Mumps2Py is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with Mumps2Py.  If not, see <http://www.gnu.org/licenses/>.
@@ -219,6 +219,49 @@
             for ref in entryrefs[ENTRYREF]:
                 rpt_window.insert(END, str(ref) + '\n')
 
+    def refers_rpt(self):
+        """ finds any entryrefs in the file that refer to the current routine"""
+        if not self.current_module or not self.modules:
+            return
+
+        from mumps2py.tokens import ENTRYREF
+        
+        title = "routines referring to %s" % self.current_module.mod_name
+        rpt_window = self.info_window(title)
+        ref_list = []
+        modcnt = 0
+        try:
+            input_file = fileinput.input(self.modules[0].input_file)
+            tstart = time.time()
+            for modcnt, the_module in enumerate(self.modules):
+                if the_module == self.current_module:
+                    continue
+                entryrefs = {}
+                print the_module.mod_name
+                if the_module.tokenlist_isempty():
+                    mumps2py.parseMumps(the_module, input_file)
+                for token in the_module.tokenized():
+                    token.extract_subtokens(entryrefs, (ENTRYREF, ))
+
+                if entryrefs.get(ENTRYREF, None):
+                    for ref in entryrefs[ENTRYREF]:
+                        if ref.__dict__.has_key('routine') and \
+                           isinstance(ref.routine, StringType) and \
+                           ref.routine == self.current_module.mod_name:
+                            ref_list.append((the_module.mod_name, ref))
+
+                the_module.empty_tokenlist() # keep memory usage down
+        except mumps2py.ParseError, err:
+            self.message(err.error_msg())
+        finally:
+            print time.time() - tstart, "seconds to parse %d routines" % \
+                  modcnt
+            fileinput.close()
+
+        for routine, ref in ref_list:
+            rpt_window.insert(END, "%s\n%s\n\n" % (routine, str(ref)))
+            
+
     def parse_fromlinemodule(self, popup):
         """parse from the module containing the line specified by popup"""
         start_line = int(self.entry_val.get())
@@ -484,11 +527,14 @@
                                   underline = 1, command = \
                                   (lambda s = self: s.display_decomposed()))
         run_btn.menu.add_command( label="label report", \
-                                  underline = 1, \
+                                  underline = 2, \
                                   command = lambda s = self: s.label_rpt())
         run_btn.menu.add_command( label="entryref report", \
                                   underline = 1, command = \
                                   lambda s = self: s.entryref_rpt())
+        run_btn.menu.add_command( label="referrals report", \
+                                  underline = 2, command = \
+                                  lambda s = self: s.refers_rpt())
         run_btn.menu.add('separator')
         run_btn.menu.add_command( label="Save and run", \
                                   underline = 1, \


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/