mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix incorrect warning when a global vector/quat/list contains an ident
This commit is contained in:
parent
02c84ca99c
commit
b441c1774f
1 changed files with 8 additions and 1 deletions
|
@ -355,6 +355,13 @@ class optimizer(object):
|
|||
|
||||
raise Exception('Internal error: This should not happen, node = ' + code0) # pragma: no cover
|
||||
|
||||
def IsValidGlobalConstant(self, value):
|
||||
if value[0] == 'EXPR':
|
||||
value = value[2]
|
||||
if value[0] not in ('VECTOR', 'ROTATION', 'LIST'):
|
||||
return False
|
||||
return all(x[0] in (CONSTANT, 'IDENT') for x in value[2:])
|
||||
|
||||
def optimize(self, symtab, functions, options = ('optimize',)):
|
||||
"""Optimize the symbolic table symtab in place. Requires a table of
|
||||
predefined functions for folding constants.
|
||||
|
@ -388,6 +395,6 @@ class optimizer(object):
|
|||
# Unfold constant
|
||||
if val[0] == 'EXPR' and val[2][0] == CONSTANT:
|
||||
symtab[0][name] = entry[:2] + (val[2][2],) + entry[3:]
|
||||
else:
|
||||
elif not self.IsValidGlobalConstant(val):
|
||||
warning('WARNING: Expression does not collapse to a single constant.')
|
||||
self.globalmode = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue