mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Minor cleanups; no functional changes.
lslcleanup: Variables renamed, order changed, comments added. Other changes: remove semicolon at end of sentence, use self.Cast instead of creating a CAST node on the fly.
This commit is contained in:
parent
0a7e2a9e1d
commit
a0d4c77081
3 changed files with 24 additions and 24 deletions
|
@ -72,7 +72,7 @@ def llDetectedName(idx, event=None):
|
|||
assert isinteger(idx)
|
||||
if 0 <= idx <= 15 and (event in DetectionEvents or event is None):
|
||||
raise ELSLCantCompute
|
||||
return NULL_KEY;
|
||||
return NULL_KEY
|
||||
|
||||
def llDetectedOwner(idx, event=None):
|
||||
assert isinteger(idx)
|
||||
|
|
|
@ -195,10 +195,7 @@ def OptimizeFunc(self, parent, index):
|
|||
node['nt'] = 'CAST'
|
||||
del child[1]
|
||||
del node['name']
|
||||
child[0] = {'nt':'CAST', 't':'string',
|
||||
'ch':[child[0]]}
|
||||
if 'SEF' in child[0]['ch'][0]:
|
||||
child[0]['SEF'] = True
|
||||
child[0] = self.Cast(child[0], 'string')
|
||||
return
|
||||
|
||||
# Check for type incompatibility or index out of range
|
||||
|
|
|
@ -45,32 +45,35 @@ class lastpass(object):
|
|||
|
||||
# This transformation makes it difficult to handle lists during
|
||||
# optimization, that's why it's done in a separate pass.
|
||||
top = child[0] if nt == '+' else None
|
||||
elemnode = child[1] if nt == '+' else node
|
||||
if 'SEF' in elemnode:
|
||||
elements = (elemnode['value'] if elemnode['nt'] == 'CONST'
|
||||
else elemnode['ch'])
|
||||
for v in elements:
|
||||
elem = v if elemnode['nt'] != 'CONST' else {
|
||||
'nt':'CONST',
|
||||
't':lslcommon.PythonType2LSL[type(v)],
|
||||
|
||||
# Make listnode be the LIST or CONST element.
|
||||
listnode = child[1] if nt == '+' else node
|
||||
|
||||
# left is the leftmost element in the addition.
|
||||
# left = None means the first element of the list must be
|
||||
# turned into a cast within the loop.
|
||||
left = child[0] if nt == '+' else None
|
||||
if 'SEF' in listnode:
|
||||
for elem in (listnode['value'] if listnode['nt'] == 'CONST'
|
||||
else listnode['ch']):
|
||||
elemnode = {'nt':'CONST',
|
||||
't':lslcommon.PythonType2LSL[type(elem)],
|
||||
'SEF':True,
|
||||
'value':v}
|
||||
top = {'nt':'CAST', 't':'list', 'SEF':True,
|
||||
'ch':[elem]
|
||||
} if top is None else {
|
||||
'value':elem
|
||||
} if listnode['nt'] == 'CONST' else elem
|
||||
left = self.Cast(elemnode, 'list') if left is None else {
|
||||
'nt':'+', 't':'list', 'SEF':True,
|
||||
'ch':[top, elem]
|
||||
'ch':[left, elemnode]
|
||||
}
|
||||
del elem
|
||||
if top is not None:
|
||||
parent[index] = top
|
||||
nt = top['nt']
|
||||
del elemnode
|
||||
if left is not None: # it's none for empty lists
|
||||
parent[index] = left
|
||||
# Do another pass on the result
|
||||
self.RecursiveLastPass(parent, index)
|
||||
del top
|
||||
return
|
||||
|
||||
del listnode, left
|
||||
|
||||
def LastPassPostOrder(self, parent, index):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue