[Python-checkins] CVS: python/dist/src/Tools/compiler/compiler astgen.py,1.5,1.6

Jeremy Hylton jhylton@users.sourceforge.net
Mon, 17 Sep 2001 13:16:32 -0700


Update of /cvsroot/python/python/dist/src/Tools/compiler/compiler
In directory usw-pr-cvs1:/tmp/cvs-serv3509

Modified Files:
	astgen.py 
Log Message:
Fix calculation of hardest_arg.

The argument properties are ordered from easiest to hardest.  The
harder the arg, the more complicated that code that must be generated
to return it from getChildren() and/or getChildNodes().  The old
calculation routine was bogus, because it always set hardest_arg to
the hardness of the last argument.  Now use max() to always set it to
the hardness of the hardest argument.



Index: astgen.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/compiler/compiler/astgen.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** astgen.py	2001/08/29 18:08:02	1.5
--- astgen.py	2001/09/17 20:16:30	1.6
***************
*** 72,84 ****
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_OTHER
!                 hardest_arg = P_OTHER
              elif arg.endswith('!'):
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_NESTED
!                 hardest_arg = P_NESTED
              elif arg.endswith('&'):
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_NONE
!                 hardest_arg = P_NONE
              else:
                  d[arg] = P_NODE
--- 72,84 ----
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_OTHER
!                 hardest_arg = max(hardest_arg, P_OTHER)
              elif arg.endswith('!'):
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_NESTED
!                 hardest_arg = max(hardest_arg, P_NESTED)
              elif arg.endswith('&'):
                  arg = self.argnames[i] = arg[:-1]
                  d[arg] = P_NONE
!                 hardest_arg = max(hardest_arg, P_NONE)
              else:
                  d[arg] = P_NODE