From 36759cacba2675c5a69ff32f0c21f076a90c0735 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Wed, 13 Aug 2014 13:44:54 +0200 Subject: [PATCH] Move PythonType2LSL to the main lsloptimizer script. This is preparation work for splitting the optimizer. --- lslopt/lsldeadcode.py | 6 ------ lslopt/lsloptimizer.py | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lslopt/lsldeadcode.py b/lslopt/lsldeadcode.py index 65f8cb5..7375240 100644 --- a/lslopt/lsldeadcode.py +++ b/lslopt/lsldeadcode.py @@ -1,6 +1,5 @@ import lslfuncs -from lslfuncs import Key, Vector, Quaternion class deadcode(object): # 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. 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): """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 diff --git a/lslopt/lsloptimizer.py b/lslopt/lsloptimizer.py index a36aad7..210eab4 100644 --- a/lslopt/lsloptimizer.py +++ b/lslopt/lsloptimizer.py @@ -1,5 +1,6 @@ import lslfuncs +from lslfuncs import Key, Vector, Quaternion from lslparse import warning from lslrenamer import renamer @@ -17,9 +18,14 @@ class optimizer(renamer, deadcode): binary_ops = frozenset(('+','-','*','/','%','<<','>>','<','<=','>','>=', '==','!=','|','^','&','||','&&')) assign_ops = frozenset(('=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>=')) + LSL2PythonType = {'integer':int, 'float':float, 'string':unicode, 'key':lslfuncs.Key, '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): """Utility function for elimination of useless expressions in FOR""" idx = 0