Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eab4328

Browse files
committed
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.
1 parent 2e4cc7e commit eab4328

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Tools/compiler/astgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def get_argprops(self):
7171
if arg.endswith('*'):
7272
arg = self.argnames[i] = arg[:-1]
7373
d[arg] = P_OTHER
74-
hardest_arg = P_OTHER
74+
hardest_arg = max(hardest_arg, P_OTHER)
7575
elif arg.endswith('!'):
7676
arg = self.argnames[i] = arg[:-1]
7777
d[arg] = P_NESTED
78-
hardest_arg = P_NESTED
78+
hardest_arg = max(hardest_arg, P_NESTED)
7979
elif arg.endswith('&'):
8080
arg = self.argnames[i] = arg[:-1]
8181
d[arg] = P_NONE
82-
hardest_arg = P_NONE
82+
hardest_arg = max(hardest_arg, P_NONE)
8383
else:
8484
d[arg] = P_NODE
8585
self.hardest_arg = hardest_arg

Tools/compiler/compiler/astgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def get_argprops(self):
7171
if arg.endswith('*'):
7272
arg = self.argnames[i] = arg[:-1]
7373
d[arg] = P_OTHER
74-
hardest_arg = P_OTHER
74+
hardest_arg = max(hardest_arg, P_OTHER)
7575
elif arg.endswith('!'):
7676
arg = self.argnames[i] = arg[:-1]
7777
d[arg] = P_NESTED
78-
hardest_arg = P_NESTED
78+
hardest_arg = max(hardest_arg, P_NESTED)
7979
elif arg.endswith('&'):
8080
arg = self.argnames[i] = arg[:-1]
8181
d[arg] = P_NONE
82-
hardest_arg = P_NONE
82+
hardest_arg = max(hardest_arg, P_NONE)
8383
else:
8484
d[arg] = P_NODE
8585
self.hardest_arg = hardest_arg

0 commit comments

Comments
 (0)