mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Rename SymbolReplacedOrDeleted to OKtoRemoveSymbol
It was an awful name but we couldn't think of anything better. That's what we have come up with as a substitute, which is not entirely accurate but it is MUCH more descriptive of what it actually does.
This commit is contained in:
parent
ffe55b38c3
commit
8322284faa
1 changed files with 7 additions and 7 deletions
|
@ -286,7 +286,7 @@ class deadcode(object):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def SymbolReplacedOrDeleted(self, curnode):
|
def OKtoRemoveSymbol(self, curnode):
|
||||||
"""If the given node's name must be simplified, that is, replaced or
|
"""If the given node's name must be simplified, that is, replaced or
|
||||||
deleted (deleted if declaration, replaced if identifier), it returns
|
deleted (deleted if declaration, replaced if identifier), it returns
|
||||||
the symbol table entry. Otherwise it returns False.
|
the symbol table entry. Otherwise it returns False.
|
||||||
|
@ -396,7 +396,7 @@ class deadcode(object):
|
||||||
nt = node.nt
|
nt = node.nt
|
||||||
|
|
||||||
if nt == 'DECL':
|
if nt == 'DECL':
|
||||||
if self.SymbolReplacedOrDeleted(node):
|
if self.OKtoRemoveSymbol(node):
|
||||||
if not node.ch or node.ch[0].SEF:
|
if not node.ch or node.ch[0].SEF:
|
||||||
del curnode.ch[index]
|
del curnode.ch[index]
|
||||||
continue
|
continue
|
||||||
|
@ -404,7 +404,7 @@ class deadcode(object):
|
||||||
ch=[self.Cast(node.ch[0], node.t)])
|
ch=[self.Cast(node.ch[0], node.t)])
|
||||||
|
|
||||||
elif nt == 'FLD':
|
elif nt == 'FLD':
|
||||||
sym = self.SymbolReplacedOrDeleted(node.ch[0])
|
sym = self.OKtoRemoveSymbol(node.ch[0])
|
||||||
if sym:
|
if sym:
|
||||||
value = sym['W']
|
value = sym['W']
|
||||||
# Mark as executed, so it isn't optimized out.
|
# Mark as executed, so it isn't optimized out.
|
||||||
|
@ -416,7 +416,7 @@ class deadcode(object):
|
||||||
t=self.PythonType2LSL[type(value)], value=value)
|
t=self.PythonType2LSL[type(value)], value=value)
|
||||||
value = self.Cast(value, 'float')
|
value = self.Cast(value, 'float')
|
||||||
SEF = True
|
SEF = True
|
||||||
else: # assumed VECTOR or ROTATION per SymbolReplacedOrDeleted
|
else: # assumed VECTOR or ROTATION per OKtoRemoveSymbol
|
||||||
SEF = value.SEF
|
SEF = value.SEF
|
||||||
value = self.Cast(value.ch[fieldidx], 'float')
|
value = self.Cast(value.ch[fieldidx], 'float')
|
||||||
# Replace it
|
# Replace it
|
||||||
|
@ -424,7 +424,7 @@ class deadcode(object):
|
||||||
node.SEF = SEF
|
node.SEF = SEF
|
||||||
|
|
||||||
elif nt == 'IDENT':
|
elif nt == 'IDENT':
|
||||||
sym = self.SymbolReplacedOrDeleted(node)
|
sym = self.OKtoRemoveSymbol(node)
|
||||||
if sym:
|
if sym:
|
||||||
# Mark as executed, so it isn't optimized out.
|
# Mark as executed, so it isn't optimized out.
|
||||||
# Make shallow copy.
|
# Make shallow copy.
|
||||||
|
@ -450,7 +450,7 @@ class deadcode(object):
|
||||||
ident = node.ch[0]
|
ident = node.ch[0]
|
||||||
if ident.nt == 'FLD':
|
if ident.nt == 'FLD':
|
||||||
ident = ident.ch[0]
|
ident = ident.ch[0]
|
||||||
sym = self.SymbolReplacedOrDeleted(ident)
|
sym = self.OKtoRemoveSymbol(ident)
|
||||||
if sym:
|
if sym:
|
||||||
node = curnode.ch[index] = self.Cast(node.ch[1], node.t)
|
node = curnode.ch[index] = self.Cast(node.ch[1], node.t)
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ class deadcode(object):
|
||||||
if not hasattr(node, 'X'):
|
if not hasattr(node, 'X'):
|
||||||
delete = True
|
delete = True
|
||||||
elif node.nt == 'DECL':
|
elif node.nt == 'DECL':
|
||||||
delete = self.SymbolReplacedOrDeleted(node)
|
delete = self.OKtoRemoveSymbol(node)
|
||||||
|
|
||||||
if delete:
|
if delete:
|
||||||
# Mark the symbol for later deletion from symbol table.
|
# Mark the symbol for later deletion from symbol table.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue