WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.6% of users enabled 2FA.

Commit 81bb9103 authored by Tobias Pape's avatar Tobias Pape Committed by Stefan Marr
Browse files

add the Byecode/Symbol names at load/translate time

parent 6690c630
......@@ -32,41 +32,18 @@ class Symbol(object):
Keyword = 28
KeywordSequence = 29
OperatorSequence = 30
_names = ["Integer",
"Not",
"And",
"Or",
"Star",
"Div",
"Mod",
"Plus",
"Minus",
"Equal",
"More",
"Less",
"Comma",
"At",
"Per",
"NewBlock",
"EndBlock",
"Colon",
"Period",
"Exit",
"Assign",
"NewTerm",
"EndTerm",
"Pound",
"Primitive",
"Separator",
"STString",
"Identifier",
"Keyword",
"KeywordSequence",
"OperatorSequence"]
def _sorted_symbols(cls):
"NOT_RPYTHON"
return [key for value, key in \
sorted([(value, key) for key, value in cls.__dict__.items()]) \
if isinstance(value, int)
]
_symbols = _sorted_symbols(Symbol)
def symbol_as_str(symbol):
if symbol == -1:
return "NONE"
index = symbol + 1
if index > len(_symbols):
raise ValueError('No Symbol defined for the value %d.' % symbol)
else:
return Symbol._names[symbol]
return _symbols[index]
from rpython.rlib.unroll import unrolling_iterable
class Bytecodes(object):
# Bytecodes used by the Simple Object Machine (SOM)
......@@ -56,23 +58,7 @@ class Bytecodes(object):
0, # return_local
0 ] # return_non_local
_bytecode_names = ["HALT",
"DUP",
"PUSH_LOCAL",
"PUSH_ARGUMENT",
"PUSH_FIELD",
"PUSH_BLOCK",
"PUSH_CONSTANT",
"PUSH_GLOBAL",
"POP",
"POP_LOCAL",
"POP_ARGUMENT",
"POP_FIELD",
"SEND",
"SUPER_SEND",
"RETURN_LOCAL",
"RETURN_NON_LOCAL"]
def bytecode_length(bytecode):
return Bytecodes._bytecode_length[bytecode]
......@@ -92,5 +78,16 @@ def bytecode_stack_effect_depends_on_send(bytecode):
def bytecode_as_str(bytecode):
if not isinstance(bytecode, int):
raise ValueError('bytecode is expected to be an integer.')
assert bytecode >= 0 and bytecode <= Bytecodes._num_bytecodes
return Bytecodes._bytecode_names[bytecode]
if bytecode > len(_bytecode_names):
raise ValueError('No Bytecode defined for the value %d.' % bytecode)
else:
return _bytecode_names[bytecode]
def _sorted_bytecode_names(cls):
"NOT_RPYTHON"
return [key.upper() for value, key in \
sorted([(value, key) for key, value in cls.__dict__.items()]) \
if isinstance(value, int) and key[0] != "_"
]
_bytecode_names = _sorted_bytecode_names(Bytecodes)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment