mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Optimize out function calls to SEF functions with non-SEF arguments.
The function call is removed, and the arguments transformed to a block of expression statements.
This commit is contained in:
parent
df31a69465
commit
9bd66dd6fa
1 changed files with 10 additions and 0 deletions
|
@ -61,6 +61,16 @@ class foldconst(object):
|
|||
if node['nt'] in ('V++', 'V--'):
|
||||
node['nt'] = '++V' if node['nt'] == 'V++' else '--V';
|
||||
|
||||
# Function calls are SEF if both the function and the args are SEF.
|
||||
# If the statement is a function call and the function is marked as SEF
|
||||
# at this point, it means the arguments are not SEF. Replace the node
|
||||
# in that case with a block.
|
||||
if node['nt'] == 'FNCALL' and 'SEF' in self.symtab[0][node['name']] and 'Loc' in self.symtab[0][node['name']]:
|
||||
parent[index] = {'nt':'{}', 't':None, 'ch':
|
||||
[{'nt':'EXPR','t':x['t'],'ch':[x]} for x in node['ch']]}
|
||||
self.FoldTree(parent, index)
|
||||
return
|
||||
|
||||
def IsBool(self, node):
|
||||
"""Some operators return 0 or 1, and that allows simplification of
|
||||
boolean expressions. This function returns whether we know for sure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue