]> granicus.if.org Git - python/commitdiff
Fix calculation of hardest_arg.
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 17 Sep 2001 20:16:30 +0000 (20:16 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 17 Sep 2001 20:16:30 +0000 (20:16 +0000)
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.

Tools/compiler/astgen.py
Tools/compiler/compiler/astgen.py

index 245eebd30bbabc150fb16c8350589fab75e6eeb9..90201d31e35f8849e98b0c39139e1b875ed0131a 100644 (file)
@@ -71,15 +71,15 @@ class NodeInfo:
             if arg.endswith('*'):
                 arg = self.argnames[i] = arg[:-1]
                 d[arg] = P_OTHER
-                hardest_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 = P_NESTED
+                hardest_arg = max(hardest_arg, P_NESTED)
             elif arg.endswith('&'):
                 arg = self.argnames[i] = arg[:-1]
                 d[arg] = P_NONE
-                hardest_arg = P_NONE
+                hardest_arg = max(hardest_arg, P_NONE)
             else:
                 d[arg] = P_NODE
         self.hardest_arg = hardest_arg
index 245eebd30bbabc150fb16c8350589fab75e6eeb9..90201d31e35f8849e98b0c39139e1b875ed0131a 100644 (file)
@@ -71,15 +71,15 @@ class NodeInfo:
             if arg.endswith('*'):
                 arg = self.argnames[i] = arg[:-1]
                 d[arg] = P_OTHER
-                hardest_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 = P_NESTED
+                hardest_arg = max(hardest_arg, P_NESTED)
             elif arg.endswith('&'):
                 arg = self.argnames[i] = arg[:-1]
                 d[arg] = P_NONE
-                hardest_arg = P_NONE
+                hardest_arg = max(hardest_arg, P_NONE)
             else:
                 d[arg] = P_NODE
         self.hardest_arg = hardest_arg