mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Copy the node, don't just ref it. Also add comments on the simple_expr issue.
This commit is contained in:
parent
66417276ae
commit
5b401ff9a5
1 changed files with 5 additions and 12 deletions
|
@ -362,25 +362,15 @@ class optimizer(object):
|
|||
# Assume we already were there
|
||||
if 'ch' in defn:
|
||||
val = defn['ch'][0]
|
||||
# TODO: We need some more analysis here.
|
||||
# As is, it "optimizes"
|
||||
# list A = [3,4,5,6,7,8,9];
|
||||
# list B = A;
|
||||
# to
|
||||
# list A = [3,4,5,6,7,8,9];
|
||||
# list B = [3,4,5,6,7,8,9];
|
||||
# which is counter-productive. But if we exclude lists,
|
||||
# we can't do this:
|
||||
# list A = [3,4,5,6,7,8,9];
|
||||
# list B = llList2List(A, 2, 3);
|
||||
if val['nt'] != 'CONST' or ident['t'] == 'key':
|
||||
return
|
||||
val = val.copy()
|
||||
else:
|
||||
val = {'nt':'CONST', 't':defn['t'],
|
||||
'value':self.DefaultValues[defn['t']]}
|
||||
if nt == 'FLD':
|
||||
val = {'nt':'CONST', 't':'float',
|
||||
'value':val['value']['xyzs'.index(node['fld'])]}
|
||||
'value':val['value']['xyzs'.index(node['fld'])]}
|
||||
parent[index] = val
|
||||
return
|
||||
|
||||
|
@ -522,6 +512,9 @@ class optimizer(object):
|
|||
|
||||
if nt == 'DECL':
|
||||
if child:
|
||||
# TODO: Decide if child is a simple_expr.
|
||||
# If it is, then we should keep the original
|
||||
# attached to the folded node and use it in the output.
|
||||
self.FoldTree(child, 0)
|
||||
# Remove assignment if integer zero.
|
||||
if node['t'] == 'integer' and child[0]['nt'] == 'CONST' \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue