mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Fix CompareTrees to not compare unstable functions as equal.
This commit is contained in:
parent
4d92cc8838
commit
e6b23a2d7a
1 changed files with 2 additions and 4 deletions
|
@ -149,10 +149,7 @@ class foldconst(object):
|
|||
|
||||
def CompareTrees(self, node1, node2):
|
||||
"""Try to compare two subtrees to see if they are equivalent."""
|
||||
# They MUST be SEF
|
||||
# FIXME: They must also be stable, i.e. return the same value
|
||||
# in two successive calls with a certain degree of certainty.
|
||||
# Counterexamples are llFrand, llGetTimestamp.
|
||||
# They MUST be SEF and stable.
|
||||
if 'SEF' not in node1 or 'SEF' not in node2:
|
||||
return False
|
||||
# So far it's only accepted if both are identifiers or function calls,
|
||||
|
@ -162,6 +159,7 @@ class foldconst(object):
|
|||
and node1['scope'] == node2['scope']
|
||||
or node1['nt'] == node2['nt'] == 'FNCALL'
|
||||
and node1['name'] == node2['name']
|
||||
and 'uns' not in self.symtab[0][node1['name']]
|
||||
and all(self.CompareTrees(node1['ch'][i],
|
||||
node2['ch'][i])
|
||||
for i in xrange(len(node1['ch'])))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue