Small fixes

master
Salvo 'LtWorf' Tomaselli 2020-06-09 18:26:03 +07:00
parent b3b5afec63
commit b17bb103f6
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
1 changed files with 6 additions and 7 deletions

@ -268,24 +268,23 @@ def subsequent_renames(n: parser.Node) -> Tuple[parser.Node, int]:
n = parser.Unary(RENAME, prop, child)
# Creating a dictionary with the attributes
renames = n.rename_dict()
renames = n.get_rename_prop()
# Scans dictionary to locate things like "a->b,b->c" and replace them
# with "a->c"
changes = False
for key, value in tuple(renames.items()):
if value in renames:
changes = True
if renames[value] != key:
# Double rename on attribute
renames[key] = renames[renames[key]] # Sets value
renames.pop(value) # Removes the unused one
del renames[value] # Removes the unused one
else: # Cycle rename a->b,b->a
renames.pop(value) # Removes the unused one
renames.pop(key) # Removes the unused one
del renames[value] # Removes the unused one
del renames[key] # Removes the unused one
if len(renames) == 0: # Nothing to rename, removing the rename op
return n, 1
return n.child, 1
else:
n.set_rename_prop(renames)
return n, 1