mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
Use frozenset more consistently
This commit is contained in:
parent
d9938f1a37
commit
4fd4bf71aa
6 changed files with 23 additions and 23 deletions
|
@ -21,7 +21,7 @@ import sys
|
|||
from strutil import *
|
||||
strutil_used
|
||||
|
||||
_exclusions = frozenset(('nt','t','name','value','ch', 'X','SEF'))
|
||||
_exclusions = frozenset({'nt','t','name','value','ch', 'X','SEF'})
|
||||
|
||||
# Node Record type. Used for AST nodes.
|
||||
class nr(object):
|
||||
|
@ -102,8 +102,8 @@ DataPath = ''
|
|||
|
||||
# These are hardcoded because additions or modifications imply
|
||||
# important changes to the code anyway.
|
||||
types = frozenset(('integer','float','string','key','vector',
|
||||
'quaternion','rotation','list'))
|
||||
types = frozenset({'integer','float','string','key','vector',
|
||||
'quaternion','rotation','list'})
|
||||
|
||||
# Conversion of LSL types to Python types and vice versa.
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ xp_error_messages = {
|
|||
18:u'experience permissions request timed out'
|
||||
}
|
||||
|
||||
valid_inventory_kinds = frozenset((0, 1, 3, 5, 6, 7, 10, 13, 20, 21))
|
||||
valid_inventory_kinds = frozenset({0, 1, 3, 5, 6, 7, 10, 13, 20, 21})
|
||||
|
||||
def llCloud(v):
|
||||
v = v2f(v)
|
||||
|
|
|
@ -34,9 +34,9 @@ class optimizer(foldconst, renamer, deadcode, lastpass):
|
|||
}
|
||||
|
||||
# explicitly exclude assignments
|
||||
binary_ops = frozenset(('+','-','*','/','%','<<','>>','<','<=','>','>=',
|
||||
'==','!=','|','^','&','||','&&'))
|
||||
assign_ops = frozenset(('=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>='))
|
||||
binary_ops = frozenset({'+','-','*','/','%','<<','>>','<','<=','>','>=',
|
||||
'==','!=','|','^','&','||','&&'})
|
||||
assign_ops = frozenset({'=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>='})
|
||||
|
||||
def Cast(self, value, newtype):
|
||||
"""Return a CAST node if the types are not equal, otherwise the
|
||||
|
|
|
@ -26,17 +26,17 @@ debugScopes = False
|
|||
|
||||
class outscript(object):
|
||||
|
||||
binary_operators = frozenset(('||','&&','^','|','&','==','!=','<','<=','>',
|
||||
binary_operators = frozenset({'||','&&','^','|','&','==','!=','<','<=','>',
|
||||
'>=','<<','>>','+','-','*','/','%', '=', '+=', '-=', '*=', '/=','%=',
|
||||
))
|
||||
extended_assignments = frozenset(('&=', '|=', '^=', '<<=', '>>='))
|
||||
unary_operators = frozenset(('NEG', '!', '~'))
|
||||
})
|
||||
extended_assignments = frozenset({'&=', '|=', '^=', '<<=', '>>='})
|
||||
unary_operators = frozenset({'NEG', '!', '~'})
|
||||
op_priority = {'=':0, '+=':0, '-=':0, '*=':0, '/=':0, '%=':0, '&=':0,
|
||||
'|=':0, '^=':0, '<<=':0, '>>=':0,
|
||||
'||':1, '&&':1, '|':2, '^':3, '&':4, '==':5, '!=':5,
|
||||
'<':6, '<=':6, '>':6, '>=':6, '<<':7, '>>':7, '+':8, '-':8,# 'NEG':8,
|
||||
'*':9, '/':9, '%':9}#, '!':10, '~':10, '++':10, '--':10, }
|
||||
assignment_ops = ('=', '+=', '-=', '*=', '/=','%=')
|
||||
assignment_ops = frozenset({'=', '+=', '-=', '*=', '/=','%='})
|
||||
|
||||
def Value2LSL(self, value):
|
||||
tvalue = type(value)
|
||||
|
|
|
@ -221,19 +221,19 @@ class EInternal(Exception):
|
|||
pass
|
||||
|
||||
class parser(object):
|
||||
assignment_toks = frozenset(('=', '+=', '-=', '*=', '/=', '%='))
|
||||
extassignment_toks = frozenset(('|=', '&=', '^=', '<<=', '>>='))
|
||||
assignment_toks = frozenset({'=', '+=', '-=', '*=', '/=', '%='})
|
||||
extassignment_toks = frozenset({'|=', '&=', '^=', '<<=', '>>='})
|
||||
|
||||
double_toks = frozenset(('++', '--', '+=', '-=', '*=', '/=', '%=', '==',
|
||||
'!=', '>=', '<=', '&&', '||', '<<', '>>'))
|
||||
extdouble_toks = frozenset(('|=', '&=', '^='))
|
||||
double_toks = frozenset({'++', '--', '+=', '-=', '*=', '/=', '%=', '==',
|
||||
'!=', '>=', '<=', '&&', '||', '<<', '>>'})
|
||||
extdouble_toks = frozenset({'|=', '&=', '^='})
|
||||
|
||||
# These are hardcoded because additions or modifications imply
|
||||
# important changes to the code anyway.
|
||||
base_keywords = frozenset(('default', 'state', 'event', 'jump', 'return',
|
||||
'if', 'else', 'for', 'do', 'while', 'print', 'TRUE', 'FALSE'))
|
||||
brkcont_keywords = frozenset(('break', 'continue'))
|
||||
switch_keywords = frozenset(('switch', 'case', 'break', 'default'))
|
||||
base_keywords = frozenset({'default', 'state', 'event', 'jump', 'return',
|
||||
'if', 'else', 'for', 'do', 'while', 'print', 'TRUE', 'FALSE'})
|
||||
brkcont_keywords = frozenset({'break', 'continue'})
|
||||
switch_keywords = frozenset({'switch', 'case', 'break', 'default'})
|
||||
|
||||
PythonType2LSLToken = {int:'INTEGER_VALUE', float:'FLOAT_VALUE',
|
||||
unicode:'STRING_VALUE', Key:'KEY_VALUE', Vector:'VECTOR_VALUE',
|
||||
|
|
4
main.py
4
main.py
|
@ -373,7 +373,7 @@ break/continue syntax extension (which is inactive by default).
|
|||
""".format(progname=str2u(progname)))
|
||||
return
|
||||
|
||||
validoptions = frozenset(('extendedglobalexpr','breakcont','extendedtypecast',
|
||||
validoptions = frozenset({'extendedglobalexpr','breakcont','extendedtypecast',
|
||||
'extendedassignment','allowkeyconcat','allowmultistrings','duplabels',
|
||||
'lazylists','enableswitch','errmissingdefault','funcoverride','optimize',
|
||||
'optsigns','optfloats','constfold','dcr','shrinknames','addstrings',
|
||||
|
@ -383,7 +383,7 @@ validoptions = frozenset(('extendedglobalexpr','breakcont','extendedtypecast',
|
|||
'lso','expr','rsrclimit',
|
||||
# 'clear' is handled as a special case
|
||||
# 'prettify' is internal, as it's a user flag
|
||||
))
|
||||
})
|
||||
|
||||
def main(argv):
|
||||
"""Main executable."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue