Use frozenset more consistently

This commit is contained in:
Sei Lisa 2020-11-09 02:06:37 +01:00
parent d9938f1a37
commit 4fd4bf71aa
6 changed files with 23 additions and 23 deletions

View file

@ -21,7 +21,7 @@ import sys
from strutil import * from strutil import *
strutil_used 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. # Node Record type. Used for AST nodes.
class nr(object): class nr(object):
@ -102,8 +102,8 @@ DataPath = ''
# These are hardcoded because additions or modifications imply # These are hardcoded because additions or modifications imply
# important changes to the code anyway. # important changes to the code anyway.
types = frozenset(('integer','float','string','key','vector', types = frozenset({'integer','float','string','key','vector',
'quaternion','rotation','list')) 'quaternion','rotation','list'})
# Conversion of LSL types to Python types and vice versa. # Conversion of LSL types to Python types and vice versa.

View file

@ -47,7 +47,7 @@ xp_error_messages = {
18:u'experience permissions request timed out' 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): def llCloud(v):
v = v2f(v) v = v2f(v)

View file

@ -34,9 +34,9 @@ class optimizer(foldconst, renamer, deadcode, lastpass):
} }
# explicitly exclude assignments # explicitly exclude assignments
binary_ops = frozenset(('+','-','*','/','%','<<','>>','<','<=','>','>=', binary_ops = frozenset({'+','-','*','/','%','<<','>>','<','<=','>','>=',
'==','!=','|','^','&','||','&&')) '==','!=','|','^','&','||','&&'})
assign_ops = frozenset(('=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>=')) assign_ops = frozenset({'=','+=','-=','*=','/=','%=','&=','|=','^=','<<=','>>='})
def Cast(self, value, newtype): def Cast(self, value, newtype):
"""Return a CAST node if the types are not equal, otherwise the """Return a CAST node if the types are not equal, otherwise the

View file

@ -26,17 +26,17 @@ debugScopes = False
class outscript(object): class outscript(object):
binary_operators = frozenset(('||','&&','^','|','&','==','!=','<','<=','>', binary_operators = frozenset({'||','&&','^','|','&','==','!=','<','<=','>',
'>=','<<','>>','+','-','*','/','%', '=', '+=', '-=', '*=', '/=','%=', '>=','<<','>>','+','-','*','/','%', '=', '+=', '-=', '*=', '/=','%=',
)) })
extended_assignments = frozenset(('&=', '|=', '^=', '<<=', '>>=')) extended_assignments = frozenset({'&=', '|=', '^=', '<<=', '>>='})
unary_operators = frozenset(('NEG', '!', '~')) unary_operators = frozenset({'NEG', '!', '~'})
op_priority = {'=':0, '+=':0, '-=':0, '*=':0, '/=':0, '%=':0, '&=':0, op_priority = {'=':0, '+=':0, '-=':0, '*=':0, '/=':0, '%=':0, '&=':0,
'|=':0, '^=':0, '<<=':0, '>>=':0, '|=':0, '^=':0, '<<=':0, '>>=':0,
'||':1, '&&':1, '|':2, '^':3, '&':4, '==':5, '!=':5, '||':1, '&&':1, '|':2, '^':3, '&':4, '==':5, '!=':5,
'<':6, '<=':6, '>':6, '>=':6, '<<':7, '>>':7, '+':8, '-':8,# 'NEG':8, '<':6, '<=':6, '>':6, '>=':6, '<<':7, '>>':7, '+':8, '-':8,# 'NEG':8,
'*':9, '/':9, '%':9}#, '!':10, '~':10, '++':10, '--':10, } '*':9, '/':9, '%':9}#, '!':10, '~':10, '++':10, '--':10, }
assignment_ops = ('=', '+=', '-=', '*=', '/=','%=') assignment_ops = frozenset({'=', '+=', '-=', '*=', '/=','%='})
def Value2LSL(self, value): def Value2LSL(self, value):
tvalue = type(value) tvalue = type(value)

View file

@ -221,19 +221,19 @@ class EInternal(Exception):
pass pass
class parser(object): class parser(object):
assignment_toks = frozenset(('=', '+=', '-=', '*=', '/=', '%=')) assignment_toks = frozenset({'=', '+=', '-=', '*=', '/=', '%='})
extassignment_toks = frozenset(('|=', '&=', '^=', '<<=', '>>=')) extassignment_toks = frozenset({'|=', '&=', '^=', '<<=', '>>='})
double_toks = frozenset(('++', '--', '+=', '-=', '*=', '/=', '%=', '==', double_toks = frozenset({'++', '--', '+=', '-=', '*=', '/=', '%=', '==',
'!=', '>=', '<=', '&&', '||', '<<', '>>')) '!=', '>=', '<=', '&&', '||', '<<', '>>'})
extdouble_toks = frozenset(('|=', '&=', '^=')) extdouble_toks = frozenset({'|=', '&=', '^='})
# These are hardcoded because additions or modifications imply # These are hardcoded because additions or modifications imply
# important changes to the code anyway. # important changes to the code anyway.
base_keywords = frozenset(('default', 'state', 'event', 'jump', 'return', base_keywords = frozenset({'default', 'state', 'event', 'jump', 'return',
'if', 'else', 'for', 'do', 'while', 'print', 'TRUE', 'FALSE')) 'if', 'else', 'for', 'do', 'while', 'print', 'TRUE', 'FALSE'})
brkcont_keywords = frozenset(('break', 'continue')) brkcont_keywords = frozenset({'break', 'continue'})
switch_keywords = frozenset(('switch', 'case', 'break', 'default')) switch_keywords = frozenset({'switch', 'case', 'break', 'default'})
PythonType2LSLToken = {int:'INTEGER_VALUE', float:'FLOAT_VALUE', PythonType2LSLToken = {int:'INTEGER_VALUE', float:'FLOAT_VALUE',
unicode:'STRING_VALUE', Key:'KEY_VALUE', Vector:'VECTOR_VALUE', unicode:'STRING_VALUE', Key:'KEY_VALUE', Vector:'VECTOR_VALUE',

View file

@ -373,7 +373,7 @@ break/continue syntax extension (which is inactive by default).
""".format(progname=str2u(progname))) """.format(progname=str2u(progname)))
return return
validoptions = frozenset(('extendedglobalexpr','breakcont','extendedtypecast', validoptions = frozenset({'extendedglobalexpr','breakcont','extendedtypecast',
'extendedassignment','allowkeyconcat','allowmultistrings','duplabels', 'extendedassignment','allowkeyconcat','allowmultistrings','duplabels',
'lazylists','enableswitch','errmissingdefault','funcoverride','optimize', 'lazylists','enableswitch','errmissingdefault','funcoverride','optimize',
'optsigns','optfloats','constfold','dcr','shrinknames','addstrings', 'optsigns','optfloats','constfold','dcr','shrinknames','addstrings',
@ -383,7 +383,7 @@ validoptions = frozenset(('extendedglobalexpr','breakcont','extendedtypecast',
'lso','expr','rsrclimit', 'lso','expr','rsrclimit',
# 'clear' is handled as a special case # 'clear' is handled as a special case
# 'prettify' is internal, as it's a user flag # 'prettify' is internal, as it's a user flag
)) })
def main(argv): def main(argv):
"""Main executable.""" """Main executable."""