mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Move PythonType2LSL to the main lsloptimizer script.
This is preparation work for splitting the optimizer.
This commit is contained in:
parent
f3301b07c6
commit
36759cacba
2 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
import lslfuncs
|
import lslfuncs
|
||||||
from lslfuncs import Key, Vector, Quaternion
|
|
||||||
|
|
||||||
class deadcode(object):
|
class deadcode(object):
|
||||||
# Functions that cause the rest of the current block to never be executed
|
# Functions that cause the rest of the current block to never be executed
|
||||||
|
@ -14,11 +13,6 @@ class deadcode(object):
|
||||||
# TODO: check if there are any more than this one.
|
# TODO: check if there are any more than this one.
|
||||||
TerminatorFuncs = ('llResetScript',)
|
TerminatorFuncs = ('llResetScript',)
|
||||||
|
|
||||||
# TODO: Share with lsloptimizer.
|
|
||||||
PythonType2LSL = {int: 'integer', float: 'float',
|
|
||||||
unicode: 'string', Key: 'key', Vector: 'vector',
|
|
||||||
Quaternion: 'rotation', list: 'list'}
|
|
||||||
|
|
||||||
def MarkReferences(self, node):
|
def MarkReferences(self, node):
|
||||||
"""Marks each node it passes through as executed (X), and each variable
|
"""Marks each node it passes through as executed (X), and each variable
|
||||||
as read (R) (with count) and/or written (W) (with node where it is, or
|
as read (R) (with count) and/or written (W) (with node where it is, or
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
import lslfuncs
|
import lslfuncs
|
||||||
|
from lslfuncs import Key, Vector, Quaternion
|
||||||
from lslparse import warning
|
from lslparse import warning
|
||||||
|
|
||||||
from lslrenamer import renamer
|
from lslrenamer import renamer
|
||||||
|
@ -17,9 +18,14 @@ class optimizer(renamer, deadcode):
|
||||||
binary_ops = frozenset(('+','-','*','/','%','<<','>>','<','<=','>','>=',
|
binary_ops = frozenset(('+','-','*','/','%','<<','>>','<','<=','>','>=',
|
||||||
'==','!=','|','^','&','||','&&'))
|
'==','!=','|','^','&','||','&&'))
|
||||||
assign_ops = frozenset(('=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>='))
|
assign_ops = frozenset(('=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>='))
|
||||||
|
|
||||||
LSL2PythonType = {'integer':int, 'float':float, 'string':unicode, 'key':lslfuncs.Key,
|
LSL2PythonType = {'integer':int, 'float':float, 'string':unicode, 'key':lslfuncs.Key,
|
||||||
'vector':lslfuncs.Vector, 'rotation':lslfuncs.Quaternion, 'list':list}
|
'vector':lslfuncs.Vector, 'rotation':lslfuncs.Quaternion, 'list':list}
|
||||||
|
|
||||||
|
PythonType2LSL = {int: 'integer', float: 'float',
|
||||||
|
unicode: 'string', Key: 'key', Vector: 'vector',
|
||||||
|
Quaternion: 'rotation', list: 'list'}
|
||||||
|
|
||||||
def FoldAndRemoveEmptyStmts(self, lst):
|
def FoldAndRemoveEmptyStmts(self, lst):
|
||||||
"""Utility function for elimination of useless expressions in FOR"""
|
"""Utility function for elimination of useless expressions in FOR"""
|
||||||
idx = 0
|
idx = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue