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 8be4ea67 authored by Stefan Marr's avatar Stefan Marr
Browse files

Added SystemPrimitives


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 8c75a437
from som.primitives.primitives import Primitives
from som.vmobjects.primitive import Primitive
import time
class SystemPrimitives(Primitives):
def __init__(self, universe):
super(SystemPrimitives, self).__init__(universe)
self._start_time = time.time() # a float of the time in seconds
def install_primitives(self):
def _load(ivkbl, frame, interpreter):
argument = frame.pop()
frame.pop() # not required
result = self._universe.load_class(argument)
frame.push(result if result else self._universe.nilObject)
self._install_instance_primitive(Primitive("load:", self._universe, _load))
def _exit(ivkbl, frame, interpreter):
error = frame.pop()
self._universe.exit(error.get_embedded_integer())
self._install_instance_primitive(Primitive("exit:", self._universe, _exit))
def _global(ivkbl, frame, interpreter):
argument = frame.pop()
frame.pop() # not required
result = self._universe.get_global(argument)
frame.push(result if result else self._universe.nilObject)
self._install_instance_primitive(Primitive("global:", self._universe, _global))
def _global_put(ivkbl, frame, interpreter):
value = frame.pop()
argument = frame.pop()
self._universe.set_global(argument, value)
self._install_instance_primitive(Primitive("global:put:", self._universe, _global_put))
def _print_string(ivkbl, frame, interpreter):
argument = frame.pop()
self._universe.std_print(argument.get_embedded_string())
self._install_instance_primitive(Primitive("printString:", self._universe, _print_string))
def _print_newline(ivkbl, frame, interpreter):
self._universe.std_println()
self._install_instance_primitive(Primitive("printNewline", self._universe, _print_newline))
def _time(ivkbl, frame, interpreter):
frame.pop() # ignore
_time = time.time() - self._start_time
frame.push(self._universe.new_integer(_time * 1000))
self._install_instance_primitive(Primitive("time", self._universe, _time))
def _ticks(ivkbl, frame, interpreter):
frame.pop() # ignore
_time = time.time() - self._start_time
frame.push(self._universe.new_integer(_time * 1000000))
self._install_instance_primitive(Primitive("ticks", self._universe, _ticks))
def _fullGC(ivkbl, frame, interpreter):
# naught - GC is entirely left to Python
pass
self._install_instance_primitive(Primitive("fullGC", self._universe, _fullGC))
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