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

Added Shell support

Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 688b44b7
class Shell(object):
def __init__(self, universe, interpreter):
self._universe = universe
self._interpreter = interpreter
self._bootstrap_method = None
def set_bootstrap_method(self, method):
self._bootstrap_method = method
def start(self):
counter = 0
it = self._universe.nilObject
self._universe.std_println("SOM Shell. Type \"quit\" to exit.\n");
# Create a fake bootstrap frame
current_frame = self._interpreter.push_new_frame(self._bootstrap_method)
# Remember the first bytecode index, e.g. index of the halt instruction
bytecode_index = current_frame.get_bytecode_index()
while True:
# Read a statement from the keyboard
stmt = raw_input("---> ")
if stmt == "quit":
# Generate a temporary class with a run method
stmt = ("Shell_Class_" + str(counter) +
" = ( run: it = ( | tmp | tmp := (" + stmt +
" ). 'it = ' print. ^tmp println ) )")
counter += 1
# Compile and load the newly generated class
my_class = self._universe.load_shell_class(stmt)
# If success
if my_class:
current_frame = self._interpreter.get_frame()
# Go back, so we will evaluate the bootstrap frames halt
# instruction again
# Create and push a new instance of our class on the stack
my_object = self._universe.new_instance(my_class)
# Push the old value of "it" on the stack
# Lookup the run: method
initialize = my_class.lookup_invokable(
# Invoke the run method
initialize.invoke(current_frame, self._interpreter)
# Start the interpreter
# Save the result of the run method
it = current_frame.pop()
except Exception, e:
import traceback
self._universe.error_println("Caught exception: " + str(e))
......@@ -15,6 +15,8 @@ from som.vmobjects.frame import Frame
from som.vmobjects.biginteger import BigInteger
from som.vmobjects.double import Double
from som.vm.shell import Shell
import som.compiler.sourcecode_compiler as sourcecode_compiler
import os
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