mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
Simplify a = a = b -> a = b
This commit is contained in:
parent
bdd42199eb
commit
08c69eee0f
1 changed files with 8 additions and 7 deletions
|
@ -1053,13 +1053,14 @@ class foldconst(object):
|
|||
|
||||
# We have a regular assignment either way now. Simplify the RHS.
|
||||
self.FoldTree(node['ch'], 1)
|
||||
if child[0]['nt'] == child[1]['nt'] == 'IDENT' \
|
||||
and child[1]['name'] == child[0]['name'] \
|
||||
and child[1]['scope'] == child[0]['scope'] \
|
||||
or child[0]['nt'] == child[1]['nt'] == 'FLD' \
|
||||
and child[1]['ch'][0]['name'] == child[0]['ch'][0]['name'] \
|
||||
and child[1]['ch'][0]['scope'] == child[0]['ch'][0]['scope'] \
|
||||
and child[1]['fld'] == child[0]['fld']:
|
||||
chkequal = child[1]['ch'][0] if child[1]['nt'] == '=' else child[1]
|
||||
if child[0]['nt'] == chkequal['nt'] == 'IDENT' \
|
||||
and chkequal['name'] == child[0]['name'] \
|
||||
and chkequal['scope'] == child[0]['scope'] \
|
||||
or child[0]['nt'] == chkequal['nt'] == 'FLD' \
|
||||
and chkequal['ch'][0]['name'] == child[0]['ch'][0]['name'] \
|
||||
and chkequal['ch'][0]['scope'] == child[0]['ch'][0]['scope'] \
|
||||
and chkequal['fld'] == child[0]['fld']:
|
||||
parent[index] = child[1]
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue