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.7% of users enabled 2FA.

Commit 896885d2 authored by Stefan Marr's avatar Stefan Marr
Browse files

Remove extra symbol table implementation, and adopt RTruffleSOM global handling

- also made other classes immutable in universe
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 0a0b0de8
......@@ -29,8 +29,23 @@ from rlib.exit import Exit
from rlib.osext import path_split
class GlobalVersion(object):
class Assoc(object):
_immutable_fields_ = ["_global_name", "_value?"]
def __init__(self, global_name, value):
self._global_name = global_name
self._value = value
def get_value(self):
return self._value
def set_value(self, value):
self._value = value
def __str__(self):
return "(%s => %s)" % (self._global_name, self._value)
class Universe(object):
......@@ -41,18 +56,27 @@ class Universe(object):
def __init__(self, avoid_exit = False):
self._interpreter = Interpreter(self)
self._symbol_table = SymbolTable()
self._symbol_table = {}
self._globals = {}
self._global_version = GlobalVersion()
self.nilObject = None
self.trueObject = None
......@@ -297,15 +321,16 @@ class Universe(object):
[self._make_block_class(i) for i in [1, 2, 3]]
return system_object
def symbol_for(self, string):
# Lookup the symbol in the symbol table
result = self._symbol_table.lookup(string)
if result:
result = self._symbol_table.get(string, None)
if result is not None:
return result
# Create a new symbol and return it
result = self.new_symbol(string)
result = self._new_symbol(string)
return result
def new_array_with_length(self, length):
......@@ -390,12 +415,12 @@ class Universe(object):
def new_string(embedded_string):
return String(embedded_string)
def new_symbol(self, string):
def _new_symbol(self, string):
result = Symbol(string)
# Insert the new symbol into the symbol table
self._symbol_table[string] = result
return result
def new_system_class(self):
......@@ -436,20 +461,30 @@ class Universe(object):
# Return the global with the given name if it's in the dictionary of globals
# if not, return None
return self._get_global(name, self._global_version)
assoc = self._get_global(name)
if assoc:
return assoc.get_value()
return None
def _get_global(self, name, version):
def _get_global(self, name):
return self._globals.get(name, None)
def set_global(self, name, value):
# Insert the given value into the dictionary of globals
self._globals[name] = value
self._global_version = GlobalVersion()
def has_global(self, name):
return name in self._globals
def get_globals_association(self, name):
assoc = self._globals.get(name, None)
if assoc is None:
assoc = Assoc(name, self.nilObject)
self._globals[name] = assoc
return assoc
def _get_block_class(self, number_of_arguments):
return self.blockClasses[number_of_arguments]
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