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.

Commit dfb1196d authored by Stefan Marr's avatar Stefan Marr
Browse files

Added a main method for execution from shell


Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent e11d4eed
...@@ -8,6 +8,7 @@ from som.vmobjects.symbol import Symbol ...@@ -8,6 +8,7 @@ from som.vmobjects.symbol import Symbol
import som.compiler.sourcecode_compiler as sourcecode_compiler import som.compiler.sourcecode_compiler as sourcecode_compiler
import os import os
import sys
class Universe(object): class Universe(object):
...@@ -55,14 +56,14 @@ class Universe(object): ...@@ -55,14 +56,14 @@ class Universe(object):
def interpret(self, arguments): def interpret(self, arguments):
# Check for command line switches # Check for command line switches
arguments = self.handleArguments(arguments) arguments = self.handle_arguments(arguments)
# Initialize the known universe # Initialize the known universe
self.initialize(arguments) self.initialize(arguments)
self.start() self.start()
def handleArguments(self, arguments): def handle_arguments(self, arguments):
got_classpath = False got_classpath = False
remaining_args = [] remaining_args = []
...@@ -82,7 +83,7 @@ class Universe(object): ...@@ -82,7 +83,7 @@ class Universe(object):
if not got_classpath: if not got_classpath:
# Get the default class path of the appropriate size # Get the default class path of the appropriate size
self._classpath = self._setup_default_classpath(0) self._classpath = self._setup_default_classpath()
# check remaining args for class paths, and strip file extension # check remaining args for class paths, and strip file extension
i = 0 i = 0
...@@ -100,6 +101,9 @@ class Universe(object): ...@@ -100,6 +101,9 @@ class Universe(object):
def setup_classpath(self, cp): def setup_classpath(self, cp):
self._classpath = cp.split(os.pathsep) self._classpath = cp.split(os.pathsep)
def _setup_default_classpath(self):
return ['.']
# take argument of the form "../foo/Test.som" and return # take argument of the form "../foo/Test.som" and return
# "../foo", "Test", "som" # "../foo", "Test", "som"
def _get_path_class_ext(self, path): def _get_path_class_ext(self, path):
...@@ -367,3 +371,12 @@ class Universe(object): ...@@ -367,3 +371,12 @@ class Universe(object):
# The class could not be found. # The class could not be found.
return None return None
def main(args):
u = Universe()
u.interpret(args[1:])
u.exit(0)
if __name__ == '__main__':
main(sys.argv)
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