Browse Source

Remove the unused SCCD compilers and runtime

Yentl Van Tendeloo 3 years ago
parent
commit
0d2bd616a5
66 changed files with 0 additions and 16042 deletions
  1. 0 17
      kernel/mvk_server/python_runtime/.project
  2. 0 5
      kernel/mvk_server/python_runtime/.pydevproject
  3. 0 0
      kernel/mvk_server/python_runtime/__init__.py
  4. 0 9
      kernel/mvk_server/python_runtime/accurate_time.py
  5. 0 58
      kernel/mvk_server/python_runtime/event_queue.py
  6. 0 3
      kernel/mvk_server/python_runtime/infinity.py
  7. 0 1
      kernel/mvk_server/python_runtime/libs/__init__.py
  8. 0 59
      kernel/mvk_server/python_runtime/libs/drawing.py
  9. 0 111
      kernel/mvk_server/python_runtime/libs/ui.py
  10. 0 19
      kernel/mvk_server/python_runtime/libs/utils.py
  11. 0 22
      kernel/mvk_server/python_runtime/nextafter.py
  12. 0 945
      kernel/mvk_server/python_runtime/statecharts_core.py
  13. 0 21
      kernel/mvk_server/python_runtime/tkinter_eventloop.py
  14. 0 17
      kernel/mvk_server/python_sccd_compiler/.project
  15. 0 5
      kernel/mvk_server/python_sccd_compiler/.pydevproject
  16. 0 0
      kernel/mvk_server/python_sccd_compiler/__init__.py
  17. 0 14
      kernel/mvk_server/python_sccd_compiler/compiler_exceptions.py
  18. 0 911
      kernel/mvk_server/python_sccd_compiler/generic_generator.py
  19. 0 996
      kernel/mvk_server/python_sccd_compiler/generic_language_constructs.py
  20. 0 285
      kernel/mvk_server/python_sccd_compiler/javascript_writer.py
  21. 0 170
      kernel/mvk_server/python_sccd_compiler/lexer.py
  22. 0 701
      kernel/mvk_server/python_sccd_compiler/old_generators/csharp_generator.py
  23. 0 741
      kernel/mvk_server/python_sccd_compiler/old_generators/javascript_generator.py
  24. 0 644
      kernel/mvk_server/python_sccd_compiler/old_generators/python_generator.py
  25. 0 81
      kernel/mvk_server/python_sccd_compiler/path_calculator.py
  26. 0 353
      kernel/mvk_server/python_sccd_compiler/python_writer.py
  27. 0 1135
      kernel/mvk_server/python_sccd_compiler/sccd_constructs.py
  28. 0 129
      kernel/mvk_server/python_sccd_compiler/sccdc.py
  29. 0 156
      kernel/mvk_server/python_sccd_compiler/state_linker.py
  30. 0 222
      kernel/mvk_server/python_sccd_compiler/stateful_writer.py
  31. 0 52
      kernel/mvk_server/python_sccd_compiler/super_class_linker.py
  32. 0 118
      kernel/mvk_server/python_sccd_compiler/utils.py
  33. 0 30
      kernel/mvk_server/python_sccd_compiler/visitor.py
  34. 0 17
      state/mvs_server/python_runtime/.project
  35. 0 5
      state/mvs_server/python_runtime/.pydevproject
  36. 0 0
      state/mvs_server/python_runtime/__init__.py
  37. 0 9
      state/mvs_server/python_runtime/accurate_time.py
  38. 0 58
      state/mvs_server/python_runtime/event_queue.py
  39. 0 3
      state/mvs_server/python_runtime/infinity.py
  40. 0 1
      state/mvs_server/python_runtime/libs/__init__.py
  41. 0 59
      state/mvs_server/python_runtime/libs/drawing.py
  42. 0 107
      state/mvs_server/python_runtime/libs/ui.py
  43. 0 19
      state/mvs_server/python_runtime/libs/utils.py
  44. 0 22
      state/mvs_server/python_runtime/nextafter.py
  45. 0 941
      state/mvs_server/python_runtime/statecharts_core.py
  46. 0 21
      state/mvs_server/python_runtime/tkinter_eventloop.py
  47. 0 17
      state/mvs_server/python_sccd_compiler/.project
  48. 0 5
      state/mvs_server/python_sccd_compiler/.pydevproject
  49. 0 0
      state/mvs_server/python_sccd_compiler/__init__.py
  50. 0 14
      state/mvs_server/python_sccd_compiler/compiler_exceptions.py
  51. 0 911
      state/mvs_server/python_sccd_compiler/generic_generator.py
  52. 0 990
      state/mvs_server/python_sccd_compiler/generic_language_constructs.py
  53. 0 285
      state/mvs_server/python_sccd_compiler/javascript_writer.py
  54. 0 170
      state/mvs_server/python_sccd_compiler/lexer.py
  55. 0 701
      state/mvs_server/python_sccd_compiler/old_generators/csharp_generator.py
  56. 0 741
      state/mvs_server/python_sccd_compiler/old_generators/javascript_generator.py
  57. 0 644
      state/mvs_server/python_sccd_compiler/old_generators/python_generator.py
  58. 0 81
      state/mvs_server/python_sccd_compiler/path_calculator.py
  59. 0 353
      state/mvs_server/python_sccd_compiler/python_writer.py
  60. 0 1131
      state/mvs_server/python_sccd_compiler/sccd_constructs.py
  61. 0 129
      state/mvs_server/python_sccd_compiler/sccdc.py
  62. 0 156
      state/mvs_server/python_sccd_compiler/state_linker.py
  63. 0 222
      state/mvs_server/python_sccd_compiler/stateful_writer.py
  64. 0 52
      state/mvs_server/python_sccd_compiler/super_class_linker.py
  65. 0 118
      state/mvs_server/python_sccd_compiler/utils.py
  66. 0 30
      state/mvs_server/python_sccd_compiler/visitor.py

+ 0 - 17
kernel/mvk_server/python_runtime/.project

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>python_runtime</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.python.pydev.PyDevBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.python.pydev.pythonNature</nature>
-	</natures>
-</projectDescription>

+ 0 - 5
kernel/mvk_server/python_runtime/.pydevproject

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?><pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
-</pydev_project>

+ 0 - 0
kernel/mvk_server/python_runtime/__init__.py


+ 0 - 9
kernel/mvk_server/python_runtime/accurate_time.py

@@ -1,9 +0,0 @@
-import time as t
-import os
-
-if os.name == 'posix':
-	def time():
-		return t.time()
-elif os.name == 'nt':
-	def time():
-		return t.clock()

+ 0 - 58
kernel/mvk_server/python_runtime/event_queue.py

@@ -1,58 +0,0 @@
-from kernel.mvk_server.python_runtime.infinity import INFINITY
-
-class EventQueue(object):
-    class EventQueueEntry(object):        
-        def __init__(self, event_list, time_offset) :
-            self.event_list = event_list
-            self.time_offset = time_offset
-        
-        def decreaseTime(self, offset) :
-            self.time_offset -= offset;   
-        
-        def getEvents(self) :
-            return self.event_list
-        
-        def getTime (self) :
-            return self.time_offset
-
-    def __init__(self):
-        self.event_list = []
-
-    def add(self, event_list, time_offset) :
-        entry = EventQueue.EventQueueEntry(event_list, time_offset);
-        #We maintain a sorted stable list
-        insert_index = 0;
-        index = len(self.event_list)-1
-        while (index >= 0) :
-            if (self.event_list[index].getTime() <= time_offset) :
-                insert_index = index + 1;
-                break;
-            index -= 1
-        self.event_list.insert(insert_index, entry)
-    
-    def decreaseTime(self, offset) :
-        for event in self.event_list :
-            event.decreaseTime(offset)
-    
-    def isEmpty(self) :
-        return len(self.event_list) == 0
-    
-    def getEarliestTime(self) :
-        """Returns the earliest time. INFINITY if no events are present."""
-        if self.isEmpty() :
-            return INFINITY
-        else :
-            return self.event_list[0].getTime()
-    
-    def popDueEvents(self) :
-        result = []
-        if (self.isEmpty() or self.event_list[0].getTime() > 0.0) :
-            #There are no events, or the earliest event isn't due, so we can already return an emtpy result
-            return result
-
-        index = 0;
-        while (index < len(self.event_list) and self.event_list[index].getTime() <= 0.0) :
-            result.append(self.event_list[index].getEvents()) #Add all events that are due (offset less than 0) to the result
-            index += 1
-        self.event_list = self.event_list[len(result):]
-        return result;

+ 0 - 3
kernel/mvk_server/python_runtime/infinity.py

@@ -1,3 +0,0 @@
-# Instantiate singleton:        
-INFINITY = float('inf')
-

+ 0 - 1
kernel/mvk_server/python_runtime/libs/__init__.py

@@ -1 +0,0 @@
-

+ 0 - 59
kernel/mvk_server/python_runtime/libs/drawing.py

@@ -1,59 +0,0 @@
-"""
- *REALLY* Small framework for creating/manipulating/deleting Tkinter Canvas elements.
- 
- NOTE: keep this synced with svg.js
- 
- Author: Raphael Mannadiar
- Date: 2014/08/21
-"""
-
-from kernel.mvk_server.python_runtime.libs.utils import utils
-
-
-class drawing:
-    class canvas_wrapper:
-        def __init__(self, element):
-            self.element = element
-            self.width = int(element.cget("width"))
-            self.height = int(element.cget("height"))
-
-        def add_circle(self, x, y, r, style):
-            new_element_id = self.element.create_oval(x-r, y-r, x+r, y+r, **style)
-            return drawing.ui_element_wrapper(self, new_element_id, x, y)
-
-        def add_rectangle(self, x, y, w, h, style):
-            new_element_id = self.element.create_rectangle(x-w/2.0, y-h/2.0, x+w/2.0, y+h/2.0, **style)
-            return drawing.ui_element_wrapper(self, new_element_id, x, y)
-
-        def remove_element(self, element):
-            self.element.delete(element.element_id)
-
-
-    class ui_element_wrapper:
-        def __init__(self, canvas_wrapper, element_id, x, y):
-            self.canvas_wrapper = canvas_wrapper
-            self.element_id = element_id
-            self.a = 0
-            self.x = x
-            self.y = y
-
-        def set_position(self, x, y):
-            self.move(x-self.x, y-self.y)
-
-        def get_position(self):
-            return utils._bunch(x=self.x, y=self.y)
-
-        def move(self, dx, dy):
-            self.x += dx
-            self.y += dy
-            self.canvas_wrapper.element.move(self.element_id, dx, dy)
-
-        def set_rotation(self, a):
-            raise Exception("Not implemented yet")
-
-        def rotate(self, a):
-            raise Exception("Not implemented yet")
-
-        def set_color(self, color):
-            self.canvas_wrapper.element.itemconfig(self.element_id, fill=color)
-

+ 0 - 111
kernel/mvk_server/python_runtime/libs/ui.py

@@ -1,111 +0,0 @@
-"""
- *REALLY* Small framework for creating/manipulating/deleting gui elements in Tkinter.
- 
- NOTE: keep this synced with ui.js
- 
- Author: Raphael Mannadiar
- Date: 2014/08/21
-"""
-
-try:
-	import Tkinter as tk
-except ImportError:
-	import tkinter as tk
-
-from kernel.mvk_server.python_runtime.statecharts_core import Event
-from kernel.mvk_server.python_runtime.libs.drawing import drawing
-from kernel.mvk_server.python_runtime.libs.utils import utils
-
-
-class ui:
-	window = None
-	__nextWindowId = 0
-
-	EVENTS = utils._bunch(
-		KEY_PRESS = 			'<Key>',
-		MOUSE_CLICK = 			'<Button>',
-		MOUSE_MOVE = 			'<Motion>',
-		MOUSE_PRESS =			'<ButtonPress>',
-		MOUSE_RELEASE =		'<ButtonRelease>',
-		MOUSE_RIGHT_CLICK =	'<Button-3>',
-		WINDOW_CLOSE = 		'WM_DELETE_WINDOW');
-
-	MOUSE_BUTTONS = utils._bunch(
-		LEFT		= 1,
-		MIDDLE	= 2,
-		RIGHT		= 3);
-
-	KEYCODES	= utils._bunch(
-		DELETE	= 46);
-
-	@staticmethod
-	def append_button(_window,text):
-		button = tk.Button(_window, text=text)
-		button.pack()
-		return ui.wrap_element(button)
-
-
-	@staticmethod
-	def append_canvas(_window,width,height,style):
-		canvas = tk.Canvas(_window,width=width,height=height)
-		canvas.config(**style)
-		canvas.pack()
-		return drawing.canvas_wrapper(canvas)
-
-
-	@staticmethod
-	def bind_event(source,event,controller,raise_name,port="ui",time_offset=0.0):
-
-		def __handle_event(ev=None):
-			if event == ui.EVENTS.KEY_PRESS :
-				controller.addInput(Event(raise_name, port, [ev.keycode,source]),time_offset)
-
-			elif event == ui.EVENTS.MOUSE_CLICK or \
-				  event == ui.EVENTS.MOUSE_MOVE or \
-				  event == ui.EVENTS.MOUSE_PRESS or \
-				  event == ui.EVENTS.MOUSE_RELEASE or \
-		  		  event == ui.EVENTS.MOUSE_RIGHT_CLICK :
-				controller.addInput(Event(raise_name, port, [ev.x, ev.y, ev.num]),time_offset)
-
-			elif event == ui.EVENTS.WINDOW_CLOSE :
-				controller.addInput(Event(raise_name, port, [source]),time_offset)
-
-			else :
-				raise Exception('Unsupported event');
-	
-		if event == ui.EVENTS.WINDOW_CLOSE :
-			source.protocol(event, __handle_event)
-
-		elif issubclass(drawing.ui_element_wrapper,source.__class__) :
-			source.canvas_wrapper.element.tag_bind(source.element_id, event, __handle_event)
-
-		else :
-			source.bind(event, __handle_event)
-
-
-	@staticmethod
-	def close_window(_window):
-		_window.destroy()
-
-
-	@staticmethod
-	def log(value):
-		print(value)
-
-
-	@staticmethod
-	def new_window(width,height):
-		_window = tk.Toplevel(ui.window)
-		_window.geometry(str(width)+"x"+str(height)+"+300+300")
-		return _window
-
-
-	@staticmethod
-	def println(value,target):
-		raise Exception('Not implemented yet');
-
-
-	@staticmethod
-	def wrap_element(element):
-		return utils._bunch(element=element)
-

+ 0 - 19
kernel/mvk_server/python_runtime/libs/utils.py

@@ -1,19 +0,0 @@
-import random
-
-class utils:
-
-	@staticmethod
-	def random():
-		return random.random()
-
-
-	"""
-		provide "." access to dictionaries
-
-		example: d = {'a':1}
-			before: d['a'] => 1, d.a => error
-			after:  d['a'] = d.a
-	"""
-	class _bunch:
-		def __init__(self, **kwds):
-			self.__dict__.update(kwds)

+ 0 - 22
kernel/mvk_server/python_runtime/nextafter.py

@@ -1,22 +0,0 @@
-import imp
-
-try:
-	# if module 'numpy' exists, use it
-	found = imp.find_module('numpy')
-	nextafter = imp.load_module('numpy', *found).nextafter
-
-except ImportError:
-	import math
-	# this ad-hoc implementation won't always give the exact same result as the C implementation used by numpy, but it's good enough for our purposes
-	def nextafter(x, y):
-		m,e = math.frexp(x)
-		exp = e - 53
-		if exp < -1022 or m == 0.0:
-			exp = -1022
-		epsilon = math.ldexp(1.0, exp)
-		if y > x:
-			return x + epsilon
-		elif y < x:
-			return x - epsilon
-		else:
-			return x

+ 0 - 945
kernel/mvk_server/python_runtime/statecharts_core.py

@@ -1,945 +0,0 @@
-import abc
-import re
-from kernel.mvk_server.python_runtime.accurate_time import time
-import threading
-import traceback
-import math
-from kernel.mvk_server.python_runtime.nextafter import nextafter
-from kernel.mvk_server.python_runtime.infinity import INFINITY
-from kernel.mvk_server.python_runtime.event_queue import EventQueue
-
-try:
-	from Queue import Queue, Empty
-except ImportError:
-	from queue import Queue, Empty
-
-class RuntimeException(Exception):
-	def __init__(self, message):
-		self.message = message
-	def __str__(self):
-		return repr(self.message)
-
-class AssociationException(RuntimeException):
-	pass
-
-class AssociationReferenceException(RuntimeException):
-	pass
-
-class ParameterException(RuntimeException):
-	pass
-
-class InputException(RuntimeException):
-	pass
-
-class Association(object):
-	#wrapper object for one association relation
-	def __init__(self, to_class, min_card, max_card):
-		self.to_class = to_class
-		self.min_card = min_card
-		self.max_card = max_card
-		self.instances = {}  # maps index (as string) to instance
-		self.instances_to_ids = {}
-		self.size = 0
-		self.next_id = 0
-		
-
-	def allowedToAdd(self):
-		return self.max_card == -1 or self.size < self.max_card
-		
-	def allowedToRemove(self):
-		return self.min_card == -1 or self.size > self.min_card
-		
-	def addInstance(self, instance):
-		if self.allowedToAdd() :
-			new_id = self.next_id
-			self.next_id += 1
-			self.instances[new_id] = instance
-			self.instances_to_ids[instance] = new_id
-			self.size += 1
-			return new_id
-		else :
-			raise AssociationException("Not allowed to add the instance to the association.")
-		
-	def removeInstance(self, instance):
-		if self.allowedToRemove() :
-			del self.instances[self.instances_to_ids[instance]]
-			del self.instances_to_ids[instance]
-			self.size -= 1
-		else :
-			raise AssociationException("Not allowed to remove the instance from the association.")
-		
-	def getInstance(self, index):
-		try :
-			return self.instances[index]
-		except IndexError :
-			raise AssociationException("Invalid index for fetching instance(s) from association.")
-
-"""class InstanceWrapper(object):
-	#wrapper object for an instance and its relevant information needed in the object manager
-	def __init__(self, instance, associations):
-		self.instance = instance
-		self.associations = {}
-		for association in associations :
-			self.associations[association.getName()] = association  
-		
-	def getAssociation(self, name):
-		try :
-			return self.associations[name]
-		except KeyError :
-			raise AssociationReferenceException("Unknown association %s." % name)
-	
-	def getInstance(self):
-		return self.instance"""
-
-class ObjectManagerBase(object):
-	__metaclass__  = abc.ABCMeta
-	
-	def __init__(self, controller):
-		self.controller = controller
-		self.events = EventQueue()
-		self.instances = set() #a dictionary that maps RuntimeClassBase to InstanceWrapper
-		
-	def addEvent(self, event, time_offset = 0.0):
-		self.events.add(event, time_offset)
-		
-	# Broadcast an event to all instances
-	def broadcast(self, new_event):
-		for i in self.instances:
-			i.addEvent(new_event)
-		
-	def getWaitTime(self):  
-		#first get waiting time of the object manager's events
-		smallest_time = self.events.getEarliestTime()
-		#check all the instances
-		for instance in self.instances:
-			smallest_time = min(smallest_time, instance.getEarliestEventTime())
-		return smallest_time
-	
-	def stepAll(self, delta):
-		self.step(delta)
-		for i in self.instances:
-			i.step(delta)
-
-	def step(self, delta):
-		self.events.decreaseTime(delta)
-		for event in self.events.popDueEvents() :
-			self.handleEvent(event)
-			   
-	def start(self):
-		for i in self.instances:
-			i.start()		  
-			   
-	def handleEvent(self, e):   
-		if e.getName() == "narrow_cast" :
-			self.handleNarrowCastEvent(e.getParameters())
-			
-		elif e.getName() == "broad_cast" :
-			self.handleBroadCastEvent(e.getParameters())
-			
-		elif e.getName() == "create_instance" :
-			self.handleCreateEvent(e.getParameters())
-			
-		elif e.getName() == "associate_instance" :
-			self.handleAssociateEvent(e.getParameters())
-			
-		elif e.getName() == "start_instance" :
-			self.handleStartInstanceEvent(e.getParameters())
-			
-		elif e.getName() == "delete_instance" :
-			self.handleDeleteInstanceEvent(e.getParameters())
-			
-	def processAssociationReference(self, input_string):
-		if len(input_string) == 0 :
-			raise AssociationReferenceException("Empty association reference.")
-		regex_pattern = re.compile("^([a-zA-Z_]\w*)(?:\[(\d+)\])?$")
-		path_string =  input_string.split("/")
-		result = []
-		for piece in path_string :
-			match = regex_pattern.match(piece)
-			if match :
-				name = match.group(1)
-				index = match.group(2)
-				if index is None :
-					index = -1
-				result.append((name,int(index)))
-			else :
-				raise AssociationReferenceException("Invalid entry in association reference. Input string: " + input_string)
-		return result
-	
-	def handleStartInstanceEvent(self, parameters):
-		if len(parameters) != 2 :
-			raise ParameterException ("The start instance event needs 2 parameters.")  
-		else :
-			source = parameters[0]
-			traversal_list = self.processAssociationReference(parameters[1])
-			for i in self.getInstances(source, traversal_list) :
-				i["instance"].start()
-			source.addEvent(Event("instance_started", parameters = [parameters[1]]))
-		
-	def handleBroadCastEvent(self, parameters):
-		if len(parameters) != 1 :
-			raise ParameterException ("The broadcast event needs 1 parameter.")
-		self.broadcast(parameters[0])
-
-	def handleCreateEvent(self, parameters):
-		if len(parameters) < 2 :
-			raise ParameterException ("The create event needs at least 2 parameters.")
-
-		source = parameters[0]
-		association_name = parameters[1]
-		
-		association = source.associations[association_name]
-		#association = self.instances_map[source].getAssociation(association_name)
-		if association.allowedToAdd() :
-			''' allow subclasses to be instantiated '''
-			class_name = association.to_class if len(parameters) == 2 else parameters[2]
-			new_instance = self.createInstance(class_name, parameters[3:])
-			if not new_instance:
-				raise ParameterException("Creating instance: no such class: " + class_name)
-			#index = association.addInstance(new_instance)
-			try:
-				index = association.addInstance(new_instance)
-			except AssociationException as exception:
-				raise RuntimeException("Error adding instance to association '" + association_name + "': " + str(exception))
-			p = new_instance.associations.get("parent")
-			if p:
-				p.addInstance(source)
-			source.addEvent(Event("instance_created", None, [association_name+"["+str(index)+"]"]))
-		else :
-			source.addEvent(Event("instance_creation_error", None, [association_name]))
-
-	def handleDeleteInstanceEvent(self, parameters):
-		if len(parameters) < 2 :
-			raise ParameterException ("The delete event needs at least 2 parameters.")
-		else :
-			source = parameters[0]
-			association_name = parameters[1]
-			traversal_list = self.processAssociationReference(association_name)
-			instances = self.getInstances(source, traversal_list)
-			#association = self.instances_map[source].getAssociation(traversal_list[0][0])
-			association = source.associations[traversal_list[0][0]]
-			for i in instances:
-				try:
-					association.removeInstance(i["instance"])
-					self.instances.discard(i["instance"])
-				except AssociationException as exception:
-					raise RuntimeException("Error removing instance from association '" + association_name + "': " + str(exception))
-				i["instance"].stop()
-				#if hasattr(i.instance, 'user_defined_destructor'):
-				i["instance"].user_defined_destructor()
-			source.addEvent(Event("instance_deleted", parameters = [parameters[1]]))
-				
-	def handleAssociateEvent(self, parameters):
-		if len(parameters) != 3 :
-			raise ParameterException ("The associate_instance event needs 3 parameters.")
-		else :
-			source = parameters[0]
-			to_copy_list = self.getInstances(source,self.processAssociationReference(parameters[1]))
-			if len(to_copy_list) != 1 :
-				raise AssociationReferenceException ("Invalid source association reference.")
-			wrapped_to_copy_instance = to_copy_list[0]["instance"]
-			dest_list = self.processAssociationReference(parameters[2])
-			if len(dest_list) == 0 :
-				raise AssociationReferenceException ("Invalid destination association reference.")
-			last = dest_list.pop()
-			if last[1] != -1 :
-				raise AssociationReferenceException ("Last association name in association reference should not be accompanied by an index.")
-				
-			for i in self.getInstances(source, dest_list) :
-				i["instance"].associations[last[0]].addInstance(wrapped_to_copy_instance)
-		
-	def handleNarrowCastEvent(self, parameters):
-		if len(parameters) != 3 :
-			raise ParameterException ("The associate_instance event needs 3 parameters.")
-		source = parameters[0]
-		traversal_list = self.processAssociationReference(parameters[1])
-		cast_event = parameters[2]
-		for i in self.getInstances(source, traversal_list) :
-			i["instance"].addEvent(cast_event)
-		
-	def getInstances(self, source, traversal_list):
-		currents = [{
-			"instance" : source,
-			"ref" : None,
-			"assoc_name" : None,
-			"assoc_index" : None
-		}]
-		#currents = [source]
-		for (name, index) in traversal_list :
-			nexts = []
-			for current in currents :
-				association = current["instance"].associations[name]
-				if (index >= 0 ) :
-					nexts.append({
-						"instance" : association.instances[index],
-						"ref" : current["instance"],
-						"assoc_name" : name,
-						"assoc_index" : index
-					})
-				elif (index == -1) :
-					for i in association.instances:
-						nexts.append({
-							"instance" : association.instances[i],
-							"ref" : current["instance"],
-							"assoc_name" : name,
-							"assoc_index" : index
-						})
-					#nexts.extend( association.instances.values() )
-				else :
-					raise AssociationReferenceException("Incorrect index in association reference.")
-			currents = nexts
-		return currents
-			
-	@abc.abstractmethod
-	def instantiate(self, class_name, construct_params):
-		pass
-		
-	def createInstance(self, to_class, construct_params = []):
-		instance = self.instantiate(to_class, construct_params)
-		self.instances.add(instance)
-		return instance
-	
-class Event(object):
-	def __init__(self, event_name, port = "", parameters = []):
-		self.name = event_name
-		self.parameters = parameters
-		self.port = port
-
-	def getName(self):
-		return self.name
-
-	def getPort(self):
-		return self.port
-
-	def getParameters(self):
-		return self.parameters
-	
-	def __repr__(self):
-		representation = "(event name : " + str(self.name) + "; port : " + str(self.port)
-		if self.parameters :
-			representation += "; parameters : " + str(self.parameters)
-		representation += ")"
-		return representation
-	
-class OutputListener(object):
-	def __init__(self, port_names):
-		self.port_names = port_names
-		self.queue = Queue()
-
-	def add(self, event):
-		if len(self.port_names) == 0 or event.getPort() in self.port_names :
-			self.queue.put_nowait(event)
-			
-	""" Tries for timeout seconds to fetch an event, returns None if failed.
-		0 as timeout means no waiting (blocking), returns None if queue is empty.
-		-1 as timeout means blocking until an event can be fetched. """
-	def fetch(self, timeout = 0):
-		if timeout < 0:
-			timeout = INFINITY
-		while timeout >= 0:
-			try:
-				# wait in chunks of 100ms because we
-				# can't receive (keyboard)interrupts while waiting
-				return self.queue.get(True, 0.1 if timeout > 0.1 else timeout)
-			except Empty:
-				timeout -= 0.1
-		return None
-
-class InputPortEntry(object):
-	def __init__(self, virtual_name, instance):
-		self.virtual_name = virtual_name
-		self.instance = instance
-		
-class ControllerBase(object):
-
-	def __init__(self, object_manager):
-		self.object_manager = object_manager
-
-		self.private_port_counter = 0
-
-		# Keep track of input ports
-		self.input_ports = {}
-		self.input_queue = EventQueue()
-
-		# Keep track of output ports
-		self.output_ports = []
-		self.output_listeners = []
-
-		# Let statechart run one last time before stopping
-		self.done = False
-			
-	def addInputPort(self, virtual_name, instance = None):
-		if instance == None :
-			port_name = virtual_name
-		else:
-			port_name = "private_" + str(self.private_port_counter) + "_" + virtual_name
-			self.private_port_counter += 1
-		self.input_ports[port_name] = InputPortEntry(virtual_name, instance)
-		return port_name
-		
-	def addOutputPort(self, port_name):
-		self.output_ports.append(port_name)
-
-	def broadcast(self, new_event):
-		self.object_manager.broadcast(new_event)
-		
-	def start(self):
-		self.object_manager.start()
-	
-	def stop(self):
-		pass
-
-	def addInput(self, input_event_list, time_offset = 0.0):
-		if not isinstance(input_event_list, list):
-			input_event_list = [input_event_list]
-
-		for e in input_event_list:
-			if e.getName() == ""  :
-				raise InputException("Input event can't have an empty name.")
-		
-			if e.getPort() not in self.input_ports :
-				raise InputException("Input port mismatch, no such port: " + e.getPort() + ".")	 
-
-		self.input_queue.add(input_event_list, time_offset)
-
-	def getWaitTime(self):
-		return min(self.object_manager.getWaitTime(), self.input_queue.getEarliestTime())
-
-	def handleInput(self, delta):
-		self.input_queue.decreaseTime(delta)
-		for events in self.input_queue.popDueEvents():
-			for e in events:
-				input_port = self.input_ports[e.getPort()]
-				e.port = input_port.virtual_name
-				target_instance = input_port.instance
-				if target_instance == None:
-					self.broadcast(e)
-				else:
-					target_instance.addEvent(e)
-
-	def outputEvent(self, event):
-		for listener in self.output_listeners :
-			listener.add(event)
-
-	def addOutputListener(self, ports):
-		listener = OutputListener(ports)
-		self.output_listeners.append(listener)
-		return listener
-
-	def addMyOwnOutputListener(self, listener):
-		self.output_listeners.append(listener)
-
-	# deprecated, to add multiple events, use addInput instead
-	def addEventList(self, event_list):
-		for (event, time_offset) in event_list :
-			self.addInput(event, time_offset)
-			
-	def getObjectManager(self):
-		return self.object_manager
-		
-class GameLoopControllerBase(ControllerBase):
-	def __init__(self, object_manager):
-		ControllerBase.__init__(self, object_manager)
-		
-	def update(self, delta):
-		self.handleInput(delta)
-		self.object_manager.stepAll(delta)
-
-class EventLoop:
-	# parameters:
-	#  schedule - a callback scheduling another callback in the event loop
-	#      this callback should take 2 parameters: (callback, timeout) and return an ID
-	#  clear - a callback that clears a scheduled callback
-	#      this callback should take an ID that was returned by 'schedule'
-	def __init__(self, schedule, clear):
-		self.schedule_callback = schedule
-		self.clear_callback = clear
-		self.scheduled_id = None
-		self.last_time = None
-		self.next_wakeup = None
-		self.last_print = 0.0
-
-	def getScheduledTimeout(self):
-		if self.last_time and self.next_wakeup:
-			return self.next_wakeup - self.last_time
-		else:
-			return INFINITY
-
-	# schedule relative to last_time
-	#
-	# argument 'wait_time' is the amount of virtual (simulated) time to wait
-	#
-	# NOTE: if the next wakeup (in simulated time) is in the past, the timeout is '0',
-	# but because scheduling '0' timeouts hurts performance, we don't schedule anything
-	# and return False instead
-	def schedule(self, f, wait_time):
-		if self.scheduled_id:
-			# if the following error occurs, it is probably due to a flaw in the logic of EventLoopControllerBase
-			raise RuntimeException("EventLoop class intended to maintain at most 1 scheduled callback.")
-
-		if wait_time == INFINITY:
-			self.last_time = None
-			self.next_wakeup = None
-			is_scheduled = True
-		else:
-			now = time()
-			if not self.last_time:
-				self.last_time = now
-			self.next_wakeup = self.last_time + wait_time
-			# self.last_time is a very large value, and wait_time can be very small, so 
-			if self.next_wakeup - self.last_time < wait_time:
-				# due to floating point imprecision, it is possible for a nonzero wait-time to advance simulated time not enough to pop the next event, potentially even causing the model to hang, so we always take the ceil of the exact result of the addition self.last_time + wait_time.
-				self.next_wakeup = nextafter(self.next_wakeup, INFINITY)
-			remaining = max(self.next_wakeup - now, 0.0)
-			is_scheduled, self.scheduled_id = self.schedule_callback(f, remaining)
-		return is_scheduled
-
-	def clear(self):
-		if self.scheduled_id:
-			self.clear_callback(self.scheduled_id)
-			self.scheduled_id = None
-
-	def nextDelta(self):
-		now = time()
-		if self.next_wakeup:
-			simulated_now = self.next_wakeup
-		else:
-			simulated_now = now
-		if now - self.last_print > 1.0:
-			behind_schedule = now - simulated_now
-			if behind_schedule > 0.1:
-				print("Warning: running %.f ms behind schedule" % (behind_schedule*1000.0))
-				self.last_print = now
-		if self.last_time:
-			delta = simulated_now - self.last_time
-		else:
-			delta = 0.0
-		self.last_time = simulated_now
-		self.next_wakeup = None
-		return delta
-
-	# returns elapsed time since delta
-	def elapsed(self):
-		if self.last_time:
-			return time() - self.last_time
-		else:
-			return 0.0
-
-class EventLoopControllerBase(ControllerBase):
-	def __init__(self, object_manager, event_loop, finished_callback = None):
-		ControllerBase.__init__(self, object_manager)
-		self.event_loop = event_loop
-		self.finished_callback = finished_callback
-
-	def addInput(self, input_event, time_offset = 0.0):
-		elapsed = self.event_loop.elapsed()
-		controller_timeout = time_offset + elapsed
-		ControllerBase.addInput(self, input_event, controller_timeout)
-		if controller_timeout < self.event_loop.getScheduledTimeout():
-			# added event's timeout is sooner than existing timeout -> re-schedule
-			self.event_loop.clear()
-			if not self.event_loop.schedule(self.run, controller_timeout):
-				self.run()
-
-	def start(self):
-		ControllerBase.start(self)
-		self.run()
-
-	def stop(self):
-		self.event_loop.clear()
-		ControllerBase.stop(self)
-
-	def run(self):
-		while True:
-			# clear existing timeout
-			self.event_loop.clear()
-			# calculate last time since simulation
-			delta = self.event_loop.nextDelta()
-			# simulate
-			self.handleInput(delta)
-			self.object_manager.stepAll(delta)
-			# schedule next timeout
-			wait_time = self.getWaitTime()
-			scheduled = self.event_loop.schedule(self.run, wait_time)
-			if wait_time == INFINITY:
-				if self.finished_callback:
-					self.finished_callback()
-			if scheduled:
-				break
-		
-class ThreadsControllerBase(ControllerBase):
-	def __init__(self, object_manager, keep_running):
-		ControllerBase.__init__(self, object_manager)
-		self.keep_running = keep_running
-		self.input_condition = threading.Condition()
-		self.stop_thread = False
-		self.thread = threading.Thread(target=self.run)
-		
-	def handleInput(self, delta):
-		with self.input_condition:
-		    ControllerBase.handleInput(self, delta)
-		
-	def start(self):
-		self.thread.start()
-		
-	def stop(self):
-		with self.input_condition:
-		    self.stop_thread = True
-		    self.input_condition.notifyAll()
-
-	def getWaitTime(self):
-		"""Compute time untill earliest next event"""
-		with self.input_condition:
-		    wait_time = ControllerBase.getWaitTime(self)
-
-		if wait_time == INFINITY :
-			if self.done :
-				self.done = False
-			else :
-				self.done = True
-				return 0.0
-		return wait_time
-
-	def handleWaiting(self):
-		with self.input_condition:
-		    wait_time = self.getWaitTime()
-		    if(wait_time <= 0.0):
-			    return
-		    
-		    if wait_time == INFINITY :
-			    if self.keep_running :
-				    self.input_condition.wait() #Wait for a signals
-			    else :
-				    self.stop_thread = True
-		    
-		    elif wait_time != 0.0 :
-			    reduced_wait_time = wait_time - (time() - self.last_recorded_time)
-			    if reduced_wait_time > 0.0 :
-				    self.input_condition.wait(reduced_wait_time)    
-
-	def run(self):
-		self.last_recorded_time  = time()
-		super(ThreadsControllerBase, self).start()
-		last_iteration_time = 0.0
-		
-		while True:
-			with self.input_condition:
-			    self.handleInput(last_iteration_time)
-			#Compute the new state based on internal events
-			self.object_manager.stepAll(last_iteration_time)
-			
-			self.handleWaiting()
-			
-			with self.input_condition:
-			    if self.stop_thread : 
-				    break
-			
-			previous_recorded_time = self.last_recorded_time
-			self.last_recorded_time = time()
-			last_iteration_time = self.last_recorded_time - previous_recorded_time
-		
-	def join(self):
-		self.thread.join()
-
-	def addInput(self, input_event, time_offset = 0.0):
-		with self.input_condition:
-			super(ThreadsControllerBase, self).addInput(input_event, time_offset)
-			self.input_condition.notifyAll()
-
-	def addEventList(self, event_list):
-		with self.input_condition:
-			super(ThreadsControllerBase, self).addEventList(event_list)
-
-class StatechartSemantics:
-	# Big Step Maximality
-	TakeOne = 0
-	TakeMany = 1
-	# Concurrency - not implemented yet
-	Single = 0
-	Many = 1
-	# Preemption - not implemented yet
-	NonPreemptive = 0
-	Preemptive = 1
-	# Internal Event Lifeline
-	Queue = 0
-	NextSmallStep = 1
-	NextComboStep = 2
-	# Input Event Lifeline
-	Whole = 0
-	FirstSmallStep = 1
-	FirstComboStep = 2
-	# Priority
-	SourceParent = 0
-	SourceChild = 1
-	# TODO: add Memory Protocol options
-	
-	def __init__(self):
-		# default semantics:
-		self.big_step_maximality = self.TakeMany
-		self.concurrency = self.Single
-		self.internal_event_lifeline = self.Queue
-		#self.input_event_lifeline = self.FirstComboStep
-		self.input_event_lifeline = self.FirstSmallStep
-		self.priority = self.SourceParent
-
-class RuntimeClassBase(object):
-	__metaclass__  = abc.ABCMeta
-	
-	def __init__(self, controller):
-		self.active = False
-		self.is_stable = True
-		self.events = EventQueue()
-
-		self.controller = controller
-
-		self.timers = None
-		self.inports = {}
-
-		self.semantics = StatechartSemantics()
-
-	def start(self):
-		self.current_state = {}
-		self.history_state = {}
-		self.timers = {}
-
-		self.big_step = BigStepState()
-		self.combo_step = ComboStepState()
-		self.small_step = SmallStepState()
-
-		self.active = True
-		self.is_stable = False
-
-		self.initializeStatechart()
-		self.processBigStepOutput()
-	
-	def stop(self):
-		self.active = False
-		
-	def addEvent(self, event_list, time_offset = 0.0):
-		if not isinstance(event_list, list):
-			event_list = [event_list]
-		self.events.add(event_list, time_offset)
-		
-	def getEarliestEventTime(self) :
-		if not self.active:
-			return INFINITY
-		if not self.is_stable:
-			return 0.0
-		if self.timers:
-			return min(self.events.getEarliestTime(), min(self.timers.values()))
-		return self.events.getEarliestTime()
-
-	def processBigStepOutput(self):
-		for e in self.big_step.getOutputEvents():
-			self.controller.outputEvent(e)
-		for e in self.big_step.getOutputEventsOM():
-			self.controller.object_manager.addEvent(e)
-
-	def step(self, delta):
-		if not self.active :
-			return
-		
-		# decrease event queue time
-		self.events.decreaseTime(delta)
-
-		# decrease timers time
-		next_timers = {}
-		for (key,value) in list(self.timers.items()):
-			time = value - delta
-			if time <= 0.0 :
-				self.addEvent( Event("_" + str(key) + "after"), time)
-			else :
-				next_timers[key] = time
-		self.timers = next_timers
-
-		# execute big step(s)
-		due = self.events.popDueEvents()
-		if not due and not self.is_stable:
-			due = [[]]
-		for input_events in due:
-			# perform 1 big step per slot in 'due'
-			self.is_stable = not self.bigStep(input_events)
-			self.processBigStepOutput()
-
-	def inState(self, nodes):
-		for c in list(self.current_state.values()):
-			new_nodes = []
-			for n in nodes:
-				if not (n in c):
-					new_nodes.append(n)
-			nodes = new_nodes
-			if len(nodes) == 0:
-				return True
-		return False
-
-	def bigStep(self, input_events):
-		#print "new big step"
-		self.big_step.next(input_events)
-		self.small_step.reset()
-		self.combo_step.reset()
-		while self.comboStep():
-			self.big_step.setStepped()
-			if self.semantics.big_step_maximality == StatechartSemantics.TakeOne:
-				break # Take One -> only one combo step allowed
-		return self.big_step.hasStepped()
-
-	def comboStep(self):
-		#print "new combo step"
-		self.combo_step.next()
-		while self.smallStep():
-			self.combo_step.setStepped()
-		return self.combo_step.hasStepped()
-
-	def smallStep(self):
-		if self.small_step.hasStepped():
-			self.small_step.next()
-		self.generateCandidates()
-		if self.small_step.hasCandidates():
-			#print "new small step, have " + str(len(self.small_step.getCandidates())) + " candidates"
-			if self.semantics.concurrency == StatechartSemantics.Single:
-				transition, parameters = self.small_step.getCandidates()[0] # execute first of candidates
-				transition(parameters)
-			elif self.semantics.concurrency == StatechartSemantics.Many:
-				pass # TODO: implement
-			self.small_step.setStepped()
-		return self.small_step.hasStepped()
-
-	def getEnabledEvents(self):
-		result = self.small_step.getCurrentEvents() + self.combo_step.getCurrentEvents()
-		if self.semantics.input_event_lifeline == StatechartSemantics.Whole or (
-			not self.big_step.hasStepped() and
-				(self.semantics.input_event_lifeline == StatechartSemantics.FirstComboStep or (
-				not self.combo_step.hasStepped() and
-					self.semantics.input_event_lifeline == StatechartSemantics.FirstSmallStep))):
-			result += self.big_step.getInputEvents()
-		return result
-
-	def raiseInternalEvent(self, event):
-		if self.semantics.internal_event_lifeline == StatechartSemantics.NextSmallStep:
-			self.small_step.addNextEvent(event)
-		elif self.semantics.internal_event_lifeline == StatechartSemantics.NextComboStep:
-			self.combo_step.addNextEvent(event)
-		elif self.semantics.internal_event_lifeline == StatechartSemantics.Queue:
-			self.events.add([event], 0.0)
-
-	@abc.abstractmethod
-	def initializeStatechart(self):
-		pass
-
-	@abc.abstractmethod
-	def generateCandidates(self):
-		pass
-
-
-class BigStepState(object):
-	def __init__(self):
-		self.input_events = [] # input events received from environment before beginning of big step (e.g. from object manager, from input port)
-		self.output_events_port = [] # output events to be sent to output port after big step ends.
-		self.output_events_om = [] # output events to be sent to object manager after big step ends.
-		self.has_stepped = True
-
-	def next(self, input_events):
-		self.input_events = input_events
-		self.output_events_port = []
-		self.output_events_om = []
-		self.has_stepped = False
-
-	def getInputEvents(self):
-		return self.input_events
-
-	def getOutputEvents(self):
-		return self.output_events_port
-
-	def getOutputEventsOM(self):
-		return self.output_events_om
-
-	def outputEvent(self, event):
-		self.output_events_port.append(event)
-
-	def outputEventOM(self, event):
-		self.output_events_om.append(event)
-
-	def setStepped(self):
-		self.has_stepped = True
-
-	def hasStepped(self):
-		return self.has_stepped
-
-
-class ComboStepState(object):
-	def __init__(self):
-		self.current_events = [] # set of enabled events during combo step
-		self.next_events = [] # internal events that were raised during combo step
-		self.changed = [] # set of all or-states that were the arena of a triggered transition during big step.
-		self.has_stepped = True
-
-	def reset(self):
-		self.current_events = []
-		self.next_events = []
-
-	def next(self):
-		self.current_events = self.next_events
-		self.next_events = []
-		self.changed = []
-		self.has_stepped = False
-
-	def addNextEvent(self, event):
-		self.next_events.append(event)
-
-	def getCurrentEvents(self):
-		return self.current_events
-
-	def setArenaChanged(self, arena):
-		self.changed.append(arena)
-
-	def isArenaChanged(self, arena):
-		return (arena in self.changed)
-
-	def isStable(self):
-		return (len(self.changed) == 0)
-
-	def setStepped(self):
-		self.has_stepped = True
-
-	def hasStepped(self):
-		return self.has_stepped
-
-
-class SmallStepState(object):
-	def __init__(self):
-		self.current_events = [] # set of enabled events during small step
-		self.next_events = [] # events to become 'current' in the next small step
-		self.candidates = [] # document-ordered(!) list of transitions that can potentially be executed concurrently, or preempt each other, depending on concurrency semantics. If no concurrency is used and there are multiple candidates, the first one is chosen. Source states of candidates are *always* orthogonal to each other.
-		self.has_stepped = True
-
-	def reset(self):
-		self.current_events = []
-		self.next_events = []
-
-	def next(self):
-		self.current_events = self.next_events # raised events from previous small step
-		self.next_events = []
-		self.candidates = []
-		self.has_stepped = False
-
-	def addNextEvent(self, event):
-		self.next_events.append(event)
-
-	def getCurrentEvents(self):
-		return self.current_events
-
-	def addCandidate(self, t, p):
-		self.candidates.append((t, p))
-
-	def getCandidates(self):
-		return self.candidates
-
-	def hasCandidates(self):
-		return len(self.candidates) > 0
-
-	def setStepped(self):
-		self.has_stepped = True
-
-	def hasStepped(self):
-		return self.has_stepped
-

+ 0 - 21
kernel/mvk_server/python_runtime/tkinter_eventloop.py

@@ -1,21 +0,0 @@
-from kernel.mvk_server.python_runtime.statecharts_core import EventLoop
-import math
-
-class TkEventLoop(EventLoop):
-	def __init__(self, tk):
-	
-		tk.sccd_force_update = False
-
-		# bind scheduler callback
-		def schedule(callback, timeout):
-			if timeout == 0:
-			# tk considers updating the window an 'idle' task, only to be done if no events are scheduled for a while. But this has the downside of the interface becoming completely unresponsive while the model is performing steps with no gaps in between. Thus we insert an 'update_idletasks()' to obtain "javascript event loop"-like behavior.
-				if tk.sccd_force_update:
-					tk.update_idletasks()
-					tk.sccd_force_update = False
-				else:
-					return (False, None) # don't schedule 0-timeout, it's more performant to just keep running
-			return (True, tk.after(int(math.ceil(timeout*1000.0)), callback))
-
-		EventLoop.__init__(self, schedule, tk.after_cancel)
-

+ 0 - 17
kernel/mvk_server/python_sccd_compiler/.project

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>python_sccd_compiler</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.python.pydev.PyDevBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.python.pydev.pythonNature</nature>
-	</natures>
-</projectDescription>

+ 0 - 5
kernel/mvk_server/python_sccd_compiler/.pydevproject

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse-pydev version="1.0"?><pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
-</pydev_project>

+ 0 - 0
kernel/mvk_server/python_sccd_compiler/__init__.py


+ 0 - 14
kernel/mvk_server/python_sccd_compiler/compiler_exceptions.py

@@ -1,14 +0,0 @@
-class CompilerException(Exception):
-	def __init__(self, message):
-		self.message = message
-	def __str__(self):
-		return repr(self.message)
-	
-class TransitionException(CompilerException):
-	pass
-
-class UnprocessedException(CompilerException):
-	pass
-
-class CodeBlockException(CompilerException):
-	pass

+ 0 - 911
kernel/mvk_server/python_sccd_compiler/generic_generator.py

@@ -1,911 +0,0 @@
-# Generic Generator by Joeri Exelmans
-#
-# Visits SCCD-domain constructs (see sccd_constructs.py) and converts them
-# to a generic language AST (see generic_language_constructs.py), that can
-# then be visited by a target language writer.
-
-import traceback
-
-import time
-from kernel.mvk_server.python_sccd_compiler.utils import Enum, Logger
-
-from kernel.mvk_server.python_sccd_compiler.visitor import Visitor
-from kernel.mvk_server.python_sccd_compiler.sccd_constructs import FormalParameter
-from kernel.mvk_server.python_sccd_compiler.stateful_writer import StatefulWriter
-import kernel.mvk_server.python_sccd_compiler.generic_language_constructs as GLC
-
-Platforms = Enum("Threads","GameLoop","EventLoop") 
-
-class GenericGenerator(Visitor):
-	
-	def __init__(self, platform):
-		self.platform = platform
-		self.writer = StatefulWriter()
-
-	def generic_visit(self, node):
-		Logger.showWarning("GenericGenerator has no visit method for node of type '" + str(type(node)) + "'.")
-
-	def get(self):
-		return self.writer.get()
-
-	def visit_ClassDiagram(self, class_diagram):
-		header = ("Generated by Statechart compiler by Glenn De Jonghe and Joeri Exelmans\n"
-		          "\n"
-		          "Date:   " + time.asctime() + "\n")
-		if class_diagram.name or class_diagram.author or class_diagram.description:
-			header += "\n"
-		if class_diagram.author:
-			header += "Model author: " + class_diagram.author + "\n"
-		if class_diagram.name:
-			header += "Model name:   " + class_diagram.name + "\n"
-		if class_diagram.description.strip():
-			header += "Model description:\n"
-			header += class_diagram.description.strip()
-
-		self.writer.addMultiLineComment(header)
-		self.writer.addVSpace()
-		self.writer.addInclude(([GLC.RuntimeModuleIdentifier(), "statecharts_core"]))
-		if class_diagram.top.strip():
-			self.writer.addRawCode(class_diagram.top)
-		self.writer.addVSpace()
-
-		self.writer.beginPackage(class_diagram.name)
-		
-		#visit children
-		for c in class_diagram.classes :
-			c.accept(self)
-		 
-		self.writer.beginClass("ObjectManager", ["ObjectManagerBase"])
-
-		self.writer.beginConstructor()
-		self.writer.addFormalParameter("controller")
-		self.writer.beginMethodBody()
-		self.writer.beginSuperClassConstructorCall("ObjectManagerBase")
-		self.writer.addActualParameter("controller")
-		self.writer.endSuperClassConstructorCall()
-		self.writer.endMethodBody()
-		self.writer.endConstructor()
-
-		self.writer.beginMethod("instantiate")
-		self.writer.addFormalParameter("class_name")
-		self.writer.addFormalParameter("construct_params")
-		self.writer.beginMethodBody()
-		for index,c in enumerate(class_diagram.classes):
-			self.writer.beginElseIf(GLC.EqualsExpression("class_name", GLC.String(c.name)))
-			if c.isAbstract():
-				# cannot instantiate abstract class
-				self.writer.add(GLC.ThrowExceptionStatement(GLC.String("Cannot instantiate abstract class \"" + c.name + "\" with unimplemented methods \"" + "\", \"".join(c.abstract_method_names) + "\".")))
-			else:
-				new_expr = GLC.NewExpression(c.name, [GLC.SelfProperty("controller")])
-				param_count = 0
-				for p in c.constructors[0].parameters:
-					new_expr.getActualParameters().add(GLC.ArrayIndexedExpression("construct_params", str(param_count)))
-					param_count += 1
-				self.writer.addAssignment(
-					GLC.LocalVariableDeclaration("instance"),
-					new_expr)
-				self.writer.addAssignment(
-					GLC.Property("instance", "associations"),
-					GLC.MapExpression())
-				for a in c.associations:
-					a.accept(self)
-			self.writer.endElseIf()
-		self.writer.add(GLC.ReturnStatement("instance"))
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		self.writer.endClass() # ObjectManager
-
-		if self.platform == Platforms.Threads:
-			controller_sub_class = "ThreadsControllerBase"
-		if self.platform == Platforms.EventLoop :
-			controller_sub_class = "EventLoopControllerBase"
-		elif self.platform == Platforms.GameLoop :
-			controller_sub_class = "GameLoopControllerBase"
-
-		self.writer.beginClass("Controller", [controller_sub_class])
-		self.writer.beginConstructor()
-		for p in class_diagram.default_class.constructors[0].parameters:
-			p.accept(self)
-		if self.platform == Platforms.EventLoop:
-			self.writer.addFormalParameter("event_loop_callbacks")
-			self.writer.addFormalParameter("finished_callback", GLC.NoneExpression())
-		elif self.platform == Platforms.Threads:
-			self.writer.addFormalParameter("keep_running", GLC.TrueExpression())
-		self.writer.beginMethodBody()
-		self.writer.beginSuperClassConstructorCall(controller_sub_class)
-		self.writer.addActualParameter(GLC.NewExpression("ObjectManager", [GLC.SelfExpression()]))
-		if self.platform == Platforms.EventLoop:
-			self.writer.addActualParameter("event_loop_callbacks")
-			self.writer.addActualParameter("finished_callback")
-		elif self.platform == Platforms.Threads:
-			self.writer.addActualParameter("keep_running")
-		self.writer.endSuperClassConstructorCall()
-		for i in class_diagram.inports:
-			self.writer.add(GLC.FunctionCall(GLC.SelfProperty("addInputPort"), [GLC.String(i)]))
-		for o in class_diagram.outports:
-			self.writer.add(GLC.FunctionCall(GLC.SelfProperty("addOutputPort"), [GLC.String(o)]))
-		actual_parameters = [p.getIdent() for p in class_diagram.default_class.constructors[0].parameters]
-		self.writer.add(GLC.FunctionCall(GLC.Property(GLC.SelfProperty("object_manager"), "createInstance"), [GLC.String(class_diagram.default_class.name), GLC.ArrayExpression(actual_parameters)]))
-		self.writer.endMethodBody()
-		self.writer.endConstructor()
-		self.writer.endClass() # Controller
-
-		# Visit test node if there is one
-		if class_diagram.test:
-			class_diagram.test.accept(self)
-
-		self.writer.endPackage()
-
-	def visit_DiagramTest(self, test):
-		# helper class
-		self.writer.beginClass("InputEvent")
-		self.writer.beginConstructor()
-		self.writer.addFormalParameter("name")
-		self.writer.addFormalParameter("port")
-		self.writer.addFormalParameter("parameters")
-		self.writer.addFormalParameter("time_offset")
-		self.writer.beginMethodBody()
-		self.writer.addAssignment(GLC.SelfProperty("name"), "name")
-		self.writer.addAssignment(GLC.SelfProperty("port"), "port")
-		self.writer.addAssignment(GLC.SelfProperty("parameters"), "parameters")
-		self.writer.addAssignment(GLC.SelfProperty("time_offset"), "time_offset")
-		self.writer.endMethodBody()
-		self.writer.endConstructor()
-		self.writer.endClass()
-		self.writer.beginClass("Test")
-		if test.input:
-			test.input.accept(self)
-		else:
-			self.writer.addStaticAttribute("input_events", GLC.ArrayExpression())
-		if test.expected:
-			test.expected.accept(self)
-		else:
-			self.writer.addStaticAttribute("expected_events", GLC.ArrayExpression())
-		self.writer.endClass()
-
-	def visit_DiagramTestInput(self, test_input):
-		# write array of input events
-		self.writer.startRecordingExpression()
-		self.writer.beginArray()
-		for e in test_input.input_events:
-			e.accept(self)
-		self.writer.endArray()
-		array_expr = self.writer.stopRecordingExpression()
-		self.writer.addStaticAttribute("input_events", array_expr)
-
-	def visit_DiagramTestInputEvent(self, event):
-		self.writer.add(GLC.NewExpression("InputEvent", [GLC.String(event.name), GLC.String(event.port), GLC.ArrayExpression(event.parameters), event.time]))
-
-	def visit_DiagramTestExpected(self, test_expected):
-		# write array of slots containing expected events
-		self.writer.startRecordingExpression()
-		self.writer.beginArray()
-		for s in test_expected.slots:
-			s.accept(self)
-		self.writer.endArray()
-		array_expr = self.writer.stopRecordingExpression()
-		self.writer.addStaticAttribute("expected_events", array_expr)
-
-	def visit_DiagramTestExpectedSlot(self, slot):
-		# write slot
-		self.writer.beginArray()
-		for e in slot.expected_events:
-			e.accept(self)
-		self.writer.endArray()
-
-	def visit_DiagramTestEvent(self, event):
-		self.writer.add(GLC.NewExpression("Event", [GLC.String(event.name), GLC.String(event.port), GLC.ArrayExpression(event.parameters)]))
-
-	def visit_Class(self, class_node):
-		"""
-		Generate code for Class construct
-		"""
-
-		super_classes = []
-		if not class_node.super_class_objs:
-			# if none of the class' super classes is defined in the diagram,
-			# we have to inherit RuntimeClassBase
-			if class_node.statechart:
-				# only inherit RuntimeClassBase if class has a statechart
-				super_classes.append("RuntimeClassBase")
-		if class_node.super_classes:
-			for super_class in class_node.super_classes:
-				super_classes.append(super_class)
-
-		self.writer.beginClass(class_node.name, super_classes)
-
-		#visit constructor
-		for i in class_node.constructors :
-			i.accept(self)
-
-		self.writer.beginMethod("user_defined_constructor")
-		for p in class_node.constructors[0].getParams():
-			p.accept(self)
-		self.writer.beginMethodBody()
-		for super_class in class_node.super_classes:
-			# begin call
-			if super_class in class_node.super_class_objs:
-				self.writer.beginSuperClassMethodCall(super_class, "user_defined_constructor")
-			else:
-				self.writer.beginSuperClassConstructorCall(super_class)
-			# write actual parameters
-			if super_class in class_node.constructors[0].super_class_parameters:
-				for p in class_node.constructors[0].super_class_parameters[super_class]:
-					self.writer.addActualParameter(p)
-			# end call
-			if super_class in class_node.super_class_objs:
-				self.writer.endSuperClassMethodCall()
-			else:
-				self.writer.endSuperClassConstructorCall()
-		self.writer.addRawCode(class_node.constructors[0].body)
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-
-
-		#visit children
-		for i in class_node.destructors :
-			i.accept(self)
-		for i in class_node.methods :
-			i.accept(self)
-
-		if class_node.statechart:
-			self.writer.beginMethod("initializeStatechart")
-			self.writer.beginMethodBody()
-
-			for c in class_node.statechart.composites :
-				self.writer.addAssignment(GLC.MapIndexedExpression(GLC.SelfProperty("current_state"), GLC.SelfProperty(c.full_name)), GLC.ArrayExpression())
-
-			if class_node.statechart.histories:
-				self.writer.addVSpace()
-				for node in class_node.statechart.combined_history_parents:
-					self.writer.addAssignment(GLC.MapIndexedExpression(GLC.SelfProperty("history_state"), GLC.SelfProperty(node.full_name)), GLC.ArrayExpression())
-
-			self.writer.addVSpace()
-			self.writer.addComment("Enter default state")	
-			for default_node in class_node.statechart.root.defaults:
-				if default_node.is_composite:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterDefault_"+default_node.full_name)))
-				elif default_node.is_basic:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+default_node.full_name)))
-			self.writer.endMethodBody()
-			self.writer.endMethod()
-
-			class_node.statechart.accept(self)
-
-		self.writer.endClass()
-
-
-	def visit_FormalParameter(self, formal_parameter):
-		self.writer.addFormalParameter(formal_parameter.getIdent(), formal_parameter.getDefault())
-		
-	def visit_Constructor(self, constructor):
-		self.writer.beginConstructor()
-		if constructor.parent_class.statechart:
-			self.writer.addFormalParameter("controller")
-		for p in constructor.getParams():
-			self.writer.addFormalParameter(p.getIdent(), p.getDefault())
-		self.writer.beginMethodBody() # constructor body
-
-		if constructor.parent_class.statechart:
-			self.writer.beginSuperClassConstructorCall("RuntimeClassBase")
-			self.writer.addActualParameter("controller")
-			self.writer.endSuperClassConstructorCall()
-
-			self.writer.addVSpace()
-
-			if constructor.parent_class.statechart.big_step_maximality == "take_one":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "big_step_maximality"), GLC.Property("StatechartSemantics", "TakeOne"))
-			elif constructor.parent_class.statechart.big_step_maximality == "take_many":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "big_step_maximality"), GLC.Property("StatechartSemantics", "TakeMany"))
-
-			if constructor.parent_class.statechart.internal_event_lifeline == "queue":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "internal_event_lifeline"), GLC.Property("StatechartSemantics", "Queue"))
-			elif constructor.parent_class.statechart.internal_event_lifeline == "next_small_step":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "internal_event_lifeline"), GLC.Property("StatechartSemantics", "NextSmallStep"))
-			elif constructor.parent_class.statechart.internal_event_lifeline == "next_combo_step":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "internal_event_lifeline"), GLC.Property("StatechartSemantics", "NextComboStep"))
-
-			if constructor.parent_class.statechart.input_event_lifeline == "first_small_step":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "input_event_lifeline"), GLC.Property("StatechartSemantics", "FirstSmallStep"))
-			elif constructor.parent_class.statechart.input_event_lifeline == "first_combo_step":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "input_event_lifeline"), GLC.Property("StatechartSemantics", "FirstComboStep"))
-			elif constructor.parent_class.statechart.input_event_lifeline == "whole":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "input_event_lifeline"), GLC.Property("StatechartSemantics", "Whole"))
-
-			if constructor.parent_class.statechart.priority == "source_parent":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "priority"), GLC.Property("StatechartSemantics", "SourceParent"))
-			elif constructor.parent_class.statechart.priority == "source_child":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "priority"), GLC.Property("StatechartSemantics", "SourceChild"))
-
-
-			if constructor.parent_class.statechart.concurrency == "single":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "concurrency"), GLC.Property("StatechartSemantics", "Single"))
-			elif constructor.parent_class.statechart.concurrency == "many":
-				self.writer.addAssignment(GLC.Property(GLC.SelfProperty("semantics"), "concurrency"), GLC.Property("StatechartSemantics", "Many"))
-
-		for p in constructor.parent_class.inports:
-			self.writer.addAssignment(
-				GLC.MapIndexedExpression(GLC.SelfProperty("inports"), GLC.String(p)),
-				GLC.FunctionCall(GLC.Property("controller", "addInputPort"), [GLC.String(p), GLC.SelfExpression()]))
-
-		if constructor.parent_class.attributes:
-			self.writer.addVSpace()
-			self.writer.addComment("User defined attributes")
-			for attribute in constructor.parent_class.attributes:
-				if attribute.init_value is None :
-					self.writer.addAssignment(GLC.SelfProperty(attribute.name), GLC.NoneExpression())
-				else :
-					self.writer.addAssignment(GLC.SelfProperty(attribute.name), attribute.init_value)
-
-		self.writer.addVSpace()
-		self.writer.addComment("Call user defined constructor")
-		self.writer.beginSuperClassMethodCall(constructor.parent_class.name, "user_defined_constructor")
-		for p in constructor.getParams():
-			# we can't do p.accept(self) here because 'p' is a FormalParameter
-			# and we want to write it as an actual parameter
-			self.writer.addActualParameter(p.getIdent())
-		self.writer.endSuperClassMethodCall()
-		self.writer.endMethodBody()
-		self.writer.endConstructor()
-
-	def visit_Destructor(self, destructor):
-		self.writer.beginMethod("user_defined_destructor")
-		self.writer.beginMethodBody()
-		if destructor.body.strip():
-			self.writer.addRawCode(destructor.body)
-		if destructor.parent_class.super_classes:
-			self.writer.addComment("Call super class destructors")
-			for super_class in destructor.parent_class.super_classes:
-				# begin call
-				if super_class in destructor.parent_class.super_class_objs:
-					self.writer.beginSuperClassMethodCall(super_class, "user_defined_destructor")
-					self.writer.endSuperClassMethodCall()
-				else:
-					self.writer.beginSuperClassDestructorCall(super_class)
-					self.writer.endSuperClassDestructorCall()
-					pass
-
-				#self.writer.beginSuperClassMethodCall(super_class, "user_defined_destructor")
-				#self.writer.endSuperClassMethodCall()
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		
-	def visit_Method(self, method):
-		self.writer.addVSpace()
-		self.writer.beginMethod(method.name, "User defined method")
-		for p in method.parameters:
-			p.accept(self)
-		self.writer.beginMethodBody()
-		self.writer.addRawCode(method.body)
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		
-	def visit_Association(self, association):
-		self.writer.addAssignment(
-			GLC.MapIndexedExpression(
-				GLC.Property("instance", "associations"),
-				GLC.String(association.name)),
-			GLC.NewExpression("Association", [GLC.String(association.to_class), str(association.min), str(association.max)]))
-
-	#helper method
-	def writeTransitionsRecursively(self, current_node):
-		valid_children = []
-		for child in current_node.children :
-			if child.is_composite or child.is_basic :
-				valid_children.append(child)
-
-		has_candidates_children = (len(valid_children) > 0)
-		has_candidates_current = (len(current_node.transitions) > 0)
-
-		if has_candidates_children:
-			self.writer.beginMethod("generateCandidatesChildren_" + current_node.full_name)
-			self.writer.beginMethodBody()
-			if current_node.is_parallel_state:
-				self.writer.addAssignment(
-					GLC.LocalVariableDeclaration("branch_done"),
-					GLC.FalseExpression())
-				for child in valid_children :
-					self.writer.addAssignment(
-						"branch_done",
-						GLC.OrExpression(
-							GLC.FunctionCall(GLC.SelfProperty("generateCandidates_" + child.full_name)),
-							"branch_done"))
-				self.writer.add(GLC.ReturnStatement("branch_done"))
-			elif current_node.is_composite:
-				for i, child in enumerate(valid_children) :
-					self.writer.beginElseIf(GLC.EqualsExpression(
-						GLC.ArrayIndexedExpression(
-							GLC.MapIndexedExpression(
-								GLC.SelfProperty("current_state"),
-								GLC.SelfProperty(current_node.full_name)),
-							"0"),
-						GLC.SelfProperty(child.full_name)))
-					self.writer.add(GLC.ReturnStatement(GLC.FunctionCall(GLC.SelfProperty("generateCandidates_"+child.full_name))))
-					self.writer.endElseIf()
-				self.writer.add(GLC.ReturnStatement(GLC.FalseExpression()))
-			self.writer.endMethodBody()
-			self.writer.endMethod()
-
-		if has_candidates_current:
-			self.writer.beginMethod("generateCandidatesCurrent_" + current_node.full_name)
-			self.writer.beginMethodBody()
-			self.writeFromTransitions(current_node)
-			self.writer.add(GLC.ReturnStatement(GLC.FalseExpression()))
-			self.writer.endMethodBody()
-			self.writer.endMethod()
-
-		self.writer.beginMethod("generateCandidates_" + current_node.full_name)
-		self.writer.beginMethodBody()
-
-		if not has_candidates_children and not has_candidates_current:
-			self.writer.add(GLC.ReturnStatement(GLC.FalseExpression()))
-		else:
-			self.writer.beginIf(
-				GLC.NotExpression(GLC.FunctionCall(
-					GLC.Property(GLC.SelfProperty("combo_step"), "isArenaChanged"),
-					[GLC.SelfProperty(current_node.full_name)])))
-
-			if has_candidates_children and has_candidates_current:
-				self.writer.addAssignment(
-					GLC.LocalVariableDeclaration("branch_done"),
-					GLC.FalseExpression())
-
-			if not has_candidates_children and has_candidates_current:
-				self.writer.add(GLC.ReturnStatement(GLC.FunctionCall(GLC.SelfProperty("generateCandidatesCurrent_" + current_node.full_name))))
-			elif not has_candidates_current and has_candidates_children:
-				self.writer.add(GLC.ReturnStatement(GLC.FunctionCall(GLC.SelfProperty("generateCandidatesChildren_" + current_node.full_name))))
-			else:
-				self.writer.beginElseIf(GLC.EqualsExpression(
-					GLC.Property(GLC.SelfProperty("semantics"), "priority"),
-					GLC.Property("StatechartSemantics", "SourceParent")))
-				if has_candidates_current:
-					self.writer.addAssignment("branch_done", GLC.FunctionCall(GLC.SelfProperty("generateCandidatesCurrent_" + current_node.full_name)))
-				if has_candidates_children:
-					self.writer.beginIf(GLC.NotExpression("branch_done"))
-					self.writer.addAssignment("branch_done", GLC.FunctionCall(GLC.SelfProperty("generateCandidatesChildren_" + current_node.full_name)))
-					self.writer.endIf()
-				self.writer.endElseIf()
-				self.writer.beginElseIf(GLC.EqualsExpression(
-					GLC.Property(GLC.SelfProperty("semantics"), "priority"),
-					GLC.Property("StatechartSemantics", "SourceChild")))
-				if has_candidates_children:
-					self.writer.addAssignment("branch_done", GLC.FunctionCall(GLC.SelfProperty("generateCandidatesChildren_" + current_node.full_name)))
-				if has_candidates_current:
-					self.writer.beginIf(GLC.NotExpression("branch_done"))
-					self.writer.addAssignment("branch_done", GLC.FunctionCall(GLC.SelfProperty("generateCandidatesCurrent_" + current_node.full_name)))
-					self.writer.endIf()
-				self.writer.endElseIf()
-
-			if has_candidates_children and has_candidates_current:
-				self.writer.add(GLC.ReturnStatement("branch_done"))
-			self.writer.endIf()
-			self.writer.beginElse()
-			self.writer.add(GLC.ReturnStatement(GLC.TrueExpression()))
-			self.writer.endElse()
-
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-
-		for index, transition in enumerate(current_node.transitions, start=1):
-			self.writeTransitionAction(transition, index)
-		
-		for child in valid_children :
-			self.writeTransitionsRecursively(child)
-				
-	#helper method
-	def writeFromTransitions(self, current_node): 
-		# get all transition out of this state
-		out_transitions = current_node.transitions
-		if len(out_transitions) == 0 :
-			return
-		
-		for index, transition in enumerate(out_transitions, start=1):
-			self.writeTransitionCondition(transition, index)
-		
-	def visit_FormalEventParameter(self, formal_event_parameter):
-		self.writer.add(formal_event_parameter.name)
-		
-	def writeFormalEventParameters(self, transition):
-		parameters = transition.getTrigger().getParameters()
-		if(len(parameters) > 0) :
-			for index, parameter in enumerate(parameters):
-				self.writer.startRecordingExpression()
-				parameter.accept(self)
-				parameter_expr = self.writer.stopRecordingExpression()
-				self.writer.addAssignment(
-					GLC.LocalVariableDeclaration(parameter_expr),
-					GLC.ArrayIndexedExpression("parameters", str(index)))
-		
-		
-	def writeTransitionAction(self, transition, index):
-		self.writer.beginMethod("transition_" + transition.parent_node.full_name + "_" + str(index))
-		self.writer.addFormalParameter("parameters")
-		self.writer.beginMethodBody()
-
-		# handle parameters to actually use them
-		self.writeFormalEventParameters(transition)
-		
-		exits = transition.getExitNodes()
-		
-		# write exit actions
-		if not exits[-1].is_basic:
-			self.writer.add(GLC.FunctionCall(GLC.SelfProperty("exit_"+exits[-1].full_name)))
-		else:
-			for node in exits:
-				if node.is_basic:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("exit_"+node.full_name)))
-					
-		# write trigger actions
-		transition.getAction().accept(self)
-
-		# add arena of transition to list of 'changed' states,
-		# this may prevent other transitions whose arenas overlap to be taken
-		self.writer.add(
-			GLC.FunctionCall(
-				GLC.Property(GLC.SelfProperty("combo_step"), "setArenaChanged"),
-				[GLC.SelfProperty(transition.arena.full_name)]))
-
-		# write enter actions
-		for (entering_node, is_ending_node) in transition.getEnterNodes() : 
-			if is_ending_node :
-				if entering_node.is_composite:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterDefault_" + entering_node.full_name)))
-				elif entering_node.is_history:
-					if (entering_node.is_history_deep) :
-						self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterHistoryDeep_" + entering_node.parent.full_name)))
-					else :
-						self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterHistoryShallow_" + entering_node.parent.full_name)))
-				else:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_" + entering_node.full_name)))
-			else :
-				if entering_node.is_composite:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_" + entering_node.full_name)))
-
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-						
-	def writeTransitionCondition(self, transition, index):
-		trigger = transition.getTrigger()
-
-		self.writer.addAssignment(
-			GLC.LocalVariableDeclaration("enabled_events"),
-			GLC.FunctionCall(GLC.SelfProperty("getEnabledEvents")))
-
-		if not trigger.isUC():
-			self.writer.beginForLoopIterateArray("enabled_events", "e")
-			condition = GLC.EqualsExpression(
-				GLC.Property(GLC.ForLoopCurrentElement("enabled_events", "e"), "name"),
-					GLC.String(trigger.getEvent()))
-			if trigger.getPort() != "":
-				condition = GLC.AndExpression(
-					condition,
-					GLC.EqualsExpression(
-						GLC.Property(GLC.ForLoopCurrentElement("enabled_events", "e"), "port"),
-						GLC.String(trigger.getPort())))
-			self.writer.beginIf(condition)
-		# evaluate guard
-		if transition.hasGuard() :
-			# handle parameters for guard evaluation
-			if not transition.getTrigger().isUC():
-				self.writer.addAssignment(GLC.LocalVariableDeclaration("parameters"), GLC.Property(GLC.ForLoopCurrentElement("enabled_events", "e"), "parameters"))
-				self.writeFormalEventParameters(transition)
-			self.writer.startRecordingExpression()
-			transition.getGuard().accept(self) # --> visit_Expression
-			expr = self.writer.stopRecordingExpression()
-			self.writer.beginIf(expr)
-
-		if trigger.isUC():
-			params_expr = GLC.ArrayExpression()
-		else:
-			params_expr = GLC.Property(GLC.ForLoopCurrentElement("enabled_events", "e"), "parameters")
-		self.writer.add(GLC.FunctionCall(GLC.Property(GLC.SelfProperty("small_step"), "addCandidate"), [GLC.SelfProperty("transition_" + transition.parent_node.full_name + "_" + str(index)), params_expr]))
-
-		self.writer.add(GLC.ReturnStatement(GLC.TrueExpression()))
-
-		if transition.hasGuard() :
-			self.writer.endIf()
-		if not trigger.isUC() :
-			self.writer.endIf()
-			self.writer.endForLoopIterateArray()
-	
-	def visit_EnterAction(self, enter_method):
-		parent_node = enter_method.parent_node
-		self.writer.beginMethod("enter_" + parent_node.full_name)
-		self.writer.beginMethodBody()
-
-		# take care of any AFTER events
-		for transition in parent_node.transitions :
-			trigger = transition.getTrigger()
-			if trigger.isAfter() :
-				self.writer.startRecordingExpression()
-				trigger.after.accept(self)
-				after = self.writer.stopRecordingExpression()
-				
-				self.writer.addAssignment(
-					GLC.MapIndexedExpression(GLC.SelfProperty("timers"), str(trigger.getAfterIndex())),
-					after)
-
-		if enter_method.action:
-			enter_method.action.accept(self)
-		self.writer.add(
-			GLC.ArrayPushBack(
-					GLC.MapIndexedExpression(
-						GLC.SelfProperty("current_state"),
-						GLC.SelfProperty(parent_node.parent.full_name)),
-					GLC.SelfProperty(parent_node.full_name)))
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		
-	#helper method
-	def writeEnterDefault(self, entered_node):
-		self.writer.beginMethod("enterDefault_" + entered_node.full_name)
-		self.writer.beginMethodBody()
-		self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+entered_node.full_name)))
-		if entered_node.is_composite:
-			l = entered_node.defaults
-			for i in l:
-				if i.is_composite:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterDefault_" + i.full_name)))
-				elif i.is_basic:
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_" + i.full_name)))
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		 
-	def visit_ExitAction(self, exit_method):
-		exited_node = exit_method.parent_node
-		self.writer.beginMethod("exit_" + exited_node.full_name)
-		self.writer.beginMethodBody()
-
-		#If the exited node is composite take care of potential history and the leaving of descendants
-		if exited_node.is_composite :
-			#handle history
-			if exited_node.save_state_on_exit :
-				self.writer.addAssignment(
-					GLC.MapIndexedExpression(
-						GLC.SelfProperty("history_state"),
-						GLC.SelfProperty(exited_node.full_name)),
-					GLC.MapIndexedExpression(
-						GLC.SelfProperty("current_state"),
-						GLC.SelfProperty(exited_node.full_name)))
-			
-			#Take care of leaving children
-			children = exited_node.children
-			if exited_node.is_parallel_state:
-				for child in children:
-					if not child.is_history :
-						self.writer.add(GLC.FunctionCall(GLC.SelfProperty("exit_"+child.full_name)))
-			else:
-				for child in children:
-					if not child.is_history :
-						self.writer.beginIf(GLC.ArrayContains(
-								GLC.MapIndexedExpression(
-									GLC.SelfProperty("current_state"),
-									GLC.SelfProperty(exited_node.full_name)),
-								GLC.SelfProperty(child.full_name)))
-						self.writer.add(GLC.FunctionCall(GLC.SelfProperty("exit_"+child.full_name)))
-						self.writer.endIf()
-		
-		# take care of any AFTER events
-		for transition in exited_node.transitions :
-			trigger = transition.getTrigger()
-			if trigger.isAfter() :
-				self.writer.add(GLC.MapRemoveElement(
-					GLC.SelfProperty("timers"),
-					str(trigger.getAfterIndex())))
-				
-		#Execute user-defined exit action if present
-		if exit_method.action:
-			exit_method.action.accept(self)
-			
-		#Adjust state
-		self.writer.addAssignment(
-			GLC.MapIndexedExpression(
-				GLC.SelfProperty("current_state"),
-				GLC.SelfProperty(exited_node.parent.full_name)),
-			GLC.ArrayExpression()) # SPECIAL CASE FOR ORTHOGONAL??
-		
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-		
-			
-	#helper method
-	def writeEnterHistory(self, entered_node, is_deep):
-		self.writer.beginMethod("enterHistory" + ("Deep" if is_deep else "Shallow") + "_" + entered_node.full_name)
-		self.writer.beginMethodBody()
-
-		self.writer.beginIf(GLC.EqualsExpression(
-			GLC.ArrayLength(
-				GLC.MapIndexedExpression(
-					GLC.SelfProperty("history_state"),
-					GLC.SelfProperty(entered_node.full_name))),
-			"0"))
-		"""self.writer.beginIfBlock(GLC.EqualsExpression(
-			GLC.ArrayLength(
-				GLC.MapIndexedExpression(
-					GLC.SelfProperty("history_state"),
-					GLC.SelfProperty(entered_node.full_name))),
-			"0"))"""
-		defaults = entered_node.defaults
-
-		for node in defaults:
-			if node.is_basic :
-				self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+node.full_name)))
-			elif node.is_composite :
-				self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterDefault_"+node.full_name)))
-
-		self.writer.endIf()
-		self.writer.beginElse()
-		children = entered_node.children
-		if entered_node.is_parallel_state:
-			for child in children:
-				if not child.is_history :
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+child.full_name)))
-					self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterHistory"+("Deep" if is_deep else "Shallow")+"_"+child.full_name)))
-		else:
-			for child in children:
-				if not child.is_history :
-					self.writer.beginIf(GLC.ArrayContains(
-						GLC.MapIndexedExpression(
-							GLC.SelfProperty("history_state"),
-							GLC.SelfProperty(entered_node.full_name)),
-						GLC.SelfProperty(child.full_name)))
-					if child.is_composite:
-						if is_deep :
-							self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+child.full_name)))
-							self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterHistoryDeep_"+child.full_name)))
-						else :
-							self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enterDefault_"+child.full_name)))
-					else:
-						self.writer.add(GLC.FunctionCall(GLC.SelfProperty("enter_"+child.full_name)))
-					self.writer.endIf()
-		self.writer.endElse()
-
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-
-	def visit_StateChart(self, statechart):
-
-		# assign each node a unique ID
-		self.writer.addVSpace()
-		self.writer.addComment("Unique IDs for all statechart nodes")
-		for (i,node) in enumerate(statechart.composites + statechart.basics):
-			self.writer.addStaticAttribute(node.full_name, str(i))
-
-
-
-		self.writer.addVSpace()
-		self.writer.addComment("Statechart enter/exit action method(s)")
-		
-		#visit enter and exit action of children
-		for i in statechart.composites + statechart.basics:
-			if i is not statechart.root :
-				i.enter_action.accept(self)
-				i.exit_action.accept(self)
-
-		# write out statecharts methods for enter/exit state
-		if len(statechart.composites) > 1 :
-			self.writer.addVSpace()
-			self.writer.addComment("Statechart enter/exit default method(s)")
-			for i in statechart.composites :
-				if i is not statechart.root :
-					self.writeEnterDefault(i)
-
-		# write out statecharts methods for enter/exit history
-		if statechart.histories:
-			self.writer.addVSpace()
-			self.writer.addComment("Statechart enter/exit history method(s)")
-			for i in statechart.shallow_history_parents:
-				self.writeEnterHistory(i, False)
-			for i in statechart.deep_history_parents:
-				self.writeEnterHistory(i, True) 
-
-		self.writer.addVSpace()
-		self.writer.addComment("Statechart transitions")
-		self.writeTransitionsRecursively(statechart.root)			
-				
-		# write out transition function
-		self.writer.beginMethod("generateCandidates", "Generate transition candidates for current small step")
-		self.writer.beginMethodBody()
-		self.writer.add(GLC.FunctionCall(
-				GLC.SelfProperty("generateCandidates_"+statechart.root.full_name)))
-		self.writer.endMethodBody()
-		self.writer.endMethod()
-
-	def visit_SelfReference(self, self_reference):
-		self.writer.add(GLC.SelfExpression())
-
-	def visit_StateReference(self, state_ref):
-		self.writer.beginArray()
-		for node in state_ref.getNodes():
-			self.writer.add(GLC.SelfProperty(node.full_name))
-		self.writer.endArray()
-
-	def visit_InStateCall(self, in_state_call):
-		self.writer.beginFunctionCall(GLC.SelfProperty("inState"))
-		self.writer.startRecordingExpression()
-		in_state_call.target.accept(self)
-		expr = self.writer.stopRecordingExpression()
-		self.writer.addActualParameter(expr)
-		self.writer.endFunctionCall()
-
-	def visit_Expression(self, expression):
-		self.writer.startRecordingExpression()
-		self.writer.beginGlue()
-		for part in expression.expression_parts:
-			part.accept(self)
-		self.writer.endGlue()
-		expr = self.writer.stopRecordingExpression()
-		self.writer.add(expr)
-
-	def visit_ExpressionPartString(self, e):
-		self.writer.add(e.string)
-		
-	def visit_RaiseEvent(self, raise_event):
-		self.writer.startRecordingExpression()
-		self.writer.begin(GLC.NewExpression("Event"))
-
-		self.writer.addActualParameter(GLC.String(raise_event.getEventName()))
-		if raise_event.isOutput():
-			self.writer.addActualParameter(GLC.String(raise_event.getPort()))
-		else:
-			self.writer.addActualParameter(GLC.NoneExpression())
-
-		self.writer.end()
-		new_event_expr = self.writer.stopRecordingExpression()
-
-		self.writer.startRecordingExpression()
-		self.writer.beginArray()
-		if raise_event.isCD():
-			self.writer.add(GLC.SelfExpression())
-		for param in raise_event.getParameters() :
-			param.accept(self) # -> visit_Expression will cause expressions to be added to array
-		self.writer.endArray()
-		parameters_array_expr = self.writer.stopRecordingExpression()
-		new_event_expr.getActualParameters().add(parameters_array_expr)
-
-		if raise_event.isNarrow():
-			self.writer.add(GLC.FunctionCall(
-				GLC.Property(GLC.SelfProperty("big_step"), "outputEventOM"), [
-					GLC.NewExpression("Event", [
-						GLC.String("narrow_cast"),
-						GLC.NoneExpression(),
-						GLC.ArrayExpression([
-							GLC.SelfExpression(),
-							raise_event.getTarget(),
-							new_event_expr])])]))
-		elif raise_event.isLocal():
-			self.writer.add(GLC.FunctionCall(
-				GLC.SelfProperty("raiseInternalEvent"),
-				[new_event_expr]))
-		elif raise_event.isOutput():
-			self.writer.add(GLC.FunctionCall(
-				GLC.Property(GLC.SelfProperty("big_step"), "outputEvent"),
-				[new_event_expr]))
-		elif raise_event.isCD():
-			self.writer.add(GLC.FunctionCall(
-				GLC.Property(GLC.SelfProperty("big_step"), "outputEventOM"),
-				[new_event_expr]))
-		elif raise_event.isBroad():
-			self.writer.add(GLC.FunctionCall(
-				GLC.Property(GLC.SelfProperty("big_step"), "outputEventOM"),
-				[GLC.NewExpression("Event", [
-					GLC.String("broad_cast"),
-					GLC.NoneExpression(),
-					GLC.ArrayExpression([
-						new_event_expr])])]))
-			
-	def visit_Script(self, script):
-		self.writer.addRawCode(script.code)
-		
-	def visit_Log(self, log):
-		self.writer.add(GLC.LogStatement(log.message))
-		
-	def visit_Assign(self, assign):
-		self.writer.startRecordingExpression()
-		assign.lvalue.accept(self) # --> visit_Expression
-		lvalue = self.writer.stopRecordingExpression()
-		self.writer.startRecordingExpression()
-		assign.expression.accept(self) # --> visit_Expression
-		rvalue = self.writer.stopRecordingExpression()
-		self.writer.addAssignment(lvalue, rvalue)
-

+ 0 - 996
kernel/mvk_server/python_sccd_compiler/generic_language_constructs.py

@@ -1,996 +0,0 @@
-import abc
-from visitor import Visitor, Visitable
-
-
-class GenericConstruct(Visitable):
-	__metaclass__ = abc.ABCMeta
-
-
-# base class for constructs that are a collection of other constructs
-class AbstractList:
-	__metaclass__ = abc.ABCMeta
-
-	@abc.abstractmethod
-	def add(self, generic_construct):
-		pass
-
-
-class BlockEntry(GenericConstruct):
-	__metaclass__ = abc.ABCMeta
-
-	@abc.abstractmethod
-	def isEmpty(self):
-		pass
-
-
-class DeclarationBase:
-	def __init__(self, identifier, description = None):
-		self.identifier = identifier
-		self.description = description # string describing declared artifact
-
-	def getIdentifier(self):
-		return self.identifier
-
-	def getDescription(self):
-		return self.description
-
-
-class Statement(BlockEntry):
-	pass
-
-
-class Package(Statement, AbstractList, DeclarationBase):
-	def __init__(self, identifier, description = None):
-		DeclarationBase.__init__(self, identifier, description)
-		self.declarations = []
-
-	def add(self, item):
-		self.declarations.append(MakeDeclaration(item))
-
-	def getDeclarations(self):
-		return self.declarations
-
-	def isEmpty(self):
-		return False
-
-
-class FormalParameters(GenericConstruct, AbstractList):
-	def __init__(self, parameter_list = None):
-		if parameter_list is None: parameter_list = []
-		self.parameter_list = parameter_list
-
-	def add(self, parameter):
-		self.parameter_list.append(parameter)
-
-	def getParameterList(self):
-		return self.parameter_list
-
-class AST(GenericConstruct, AbstractList):
-	def __init__(self):
-		self.entries = []
-
-	def add(self, entry):
-		self.entries.append(MakeBlockEntry(entry))
-
-	def getEntries(self):
-		return self.entries
-
-
-class Block(AST):
-	def __init__(self):
-		AST.__init__(self)
-
-	def isEmpty(self):
-		for e in self.getEntries():
-			if not e.isEmpty():
-				return False
-		return True
-
-
-class ForLoopBody(Block):
-	def __init__(self, for_loop):
-		Block.__init__(self)
-		self.for_loop = for_loop
-
-	def getForLoop(self):
-		return self.for_loop
-
-
-class MethodBody(Block):
-	def __init__(self, method):
-		Block.__init__(self)
-		self.method = method
-
-	def getMethod(self):
-		return self.method
-
-
-#class ConstructorBody(MethodBody):
-#	def __init__(self, method):
-#		MethodBody.__init__(self, method)
-
-#class DestructorBody(MethodBody):
-#	def __init__(self, method):
-#		MethodBody.__init__(self, method)
-
-
-class ClassMember(GenericConstruct, DeclarationBase):
-	def __init__(self, c, identifier, description = None):
-		DeclarationBase.__init__(self, identifier, description)
-		self.c = c # Class
-
-	def getClass(self):
-		return self.c
-
-
-class MethodBase(ClassMember):
-	def __init__(self, c, identifier, description = None):
-		ClassMember.__init__(self, c, identifier, description)
-		self.formal_parameters = FormalParameters()
-		self.body = MethodBody(self)
-
-	def getBody(self):
-		return self.body
-
-	def getFormalParameters(self):
-		return self.formal_parameters
-
-
-class Method(MethodBase):
-	def __init__(self, c, identifier, description = None):
-		MethodBase.__init__(self, c, identifier, description)
-
-
-class Constructor(MethodBase):
-	def __init__(self, c, description = None):
-		MethodBase.__init__(self, c, None, description)
-
-
-class Destructor(MethodBase):
-	def __init__(self, c, description = None):
-		MethodBase.__init__(self, c, None, description)
-
-
-class Class(GenericConstruct, AbstractList, DeclarationBase):
-	def __init__(self, identifier, super_class_identifier_list = None, description = None):
-		DeclarationBase.__init__(self, identifier, description)
-		self.super_class_identifier_list = super_class_identifier_list # string
-		self.constructor = Constructor(self)
-		self.destructor = Destructor(self)
-		self.members = []
-
-	def getSuperClassIdentifierList(self):
-		return self.super_class_identifier_list
-
-	def getConstructor(self):
-		return self.constructor
-
-	def getDestructor(self):
-		return self.destructor
-
-	def add(self, class_member):
-		self.members.append(class_member)
-
-	def getMembers(self):
-		return self.members
-
-
-class AttributeBase(ClassMember):
-	def __init__(self, c, identifier, init_value = None):
-		ClassMember.__init__(self, c, identifier)
-		self.init_value = MakeExpression(init_value)
-
-	def getInitValue(self):
-		return self.init_value
-
-
-class Attribute(AttributeBase):
-	def __init__(self, c, identifier, init_value = None):
-		AttributeBase.__init__(self, c, identifier, init_value)
-
-
-class StaticAttribute(AttributeBase):
-	def __init__(self, c, name, init_value = None):
-		AttributeBase.__init__(self, c, name, init_value)
-
-
-class FormalParameter(GenericConstruct, DeclarationBase):
-	def __init__(self, identifier, default_value = None, description = None):
-		DeclarationBase.__init__(self, identifier, description)
-		#self.identifier = identifier
-		self.default_value = MakeExpression(default_value)
-
-	def getDefaultValue(self):
-		return self.default_value
-
-
-class IncludeStatement(Statement):
-	def __init__(self, module_path, imported_symbols = None):
-		if imported_symbols is None: imported_symbols = []
-		self.module_path = MakeExpressionList(module_path) # list of modules
-		self.imported_symbols = imported_symbols
-
-	def getModulePath(self):
-		return self.module_path
-
-	def getImportedSymbols(self):
-		return self.imported_symbols
-
-	def isEmpty(self):
-		return False
-
-
-class ReturnStatement(Statement):
-	def __init__(self, expr):
-		self.expr = MakeExpression(expr)
-
-	def getExpression(self):
-		return self.expr
-
-	def isEmpty(self):
-		return False
-
-class BreakStatement(Statement):
-	def isEmpty(self):
-		return False	
-
-class ThrowExceptionStatement(Statement):
-	def __init__(self, expr):
-		self.expr = MakeExpression(expr)
-
-	def getExpression(self):
-		return self.expr
-
-	def isEmpty(self):
-		return False
-
-
-class VSpace(BlockEntry):
-	def isEmpty(self):
-		return True
-
-
-class CommentBase(BlockEntry):
-	def __init__(self, text):
-		self.text = text
-
-	def isEmpty(self):
-		return True
-
-	def getText(self):
-		return self.text
-
-
-class SingleLineComment(CommentBase):
-	def __init__(self, text):
-		CommentBase.__init__(self,text)
-
-
-class MultiLineComment(CommentBase):
-	def __init__(self, text):
-		CommentBase.__init__(self,text)
-
-
-class ConditionalStatementBase(Statement, AbstractList):
-	def __init__(self, body = None):
-		if body is None: body = Block()
-		self.body = body
-
-	def add(self, stmt):
-		self.body.add(stmt)
-
-	def getBody(self):
-		return self.body
-
-	def isEmpty(self):
-		return False
-
-
-class IfStatement(ConditionalStatementBase):
-	def __init__(self, condition):
-		ConditionalStatementBase.__init__(self)
-		self.condition = MakeExpression(condition)
-
-	def getCondition(self):
-		return self.condition
-
-
-class ElseStatement(ConditionalStatementBase):
-	def __init__(self):
-		ConditionalStatementBase.__init__(self)
-
-
-class ElseIfStatement(IfStatement):
-	def __init__(self, condition, is_first = False):
-		IfStatement.__init__(self, condition)
-		self.is_first = is_first
-
-	# in a series of ElseIfStatements, the first ElseIfStatement will be a normal if statement
-	def isFirst(self):
-		return self.is_first
-
-
-class ForLoopIterateBase(ConditionalStatementBase):
-	def __init__(self, collection_expr, iterator_identifier):
-		ConditionalStatementBase.__init__(self, ForLoopBody(self))
-		self.collection_expr = MakeExpression(collection_expr)
-		self.iterator_identifier = iterator_identifier
-
-	def getCollectionExpression(self):
-		return self.collection_expr
-
-	def getIteratorIdentifier(self):
-		return self.iterator_identifier
-
-
-class ForLoopIterateArray(ForLoopIterateBase):
-	def __init__(self, array_expr, iterator_identifier):
-		ForLoopIterateBase.__init__(self, array_expr, iterator_identifier)
-
-
-class ForLoopIterateMapValues(ForLoopIterateBase):
-	def __init__(self, map_expr, iterator_identifier):
-		ForLoopIterateBase.__init__(self, map_expr, iterator_identifier)
-
-
-class ExpressionStatement(Statement):
-	def __init__(self, expression):
-		self.expression = expression
-
-	def getExpression(self):
-		return self.expression
-
-	def isEmpty(self):
-		return False
-
-
-# block of raw code
-class RawCode(BlockEntry):
-	def __init__(self, text):
-		self.text = text
-
-	def getText(self):
-		return self.text
-
-	def isEmpty(self):
-		return (len(self.text.strip()) == 0)
-
-
-# log message to console
-class LogStatement(Statement):
-	def __init__(self, msg):
-		self.msg = msg
-
-	def getMessage(self):
-		return self.msg
-
-	def isEmpty(self):
-		return False
-
-
-class Expression(GenericConstruct):
-	__metaclass__ = abc.ABCMeta
-
-	@abc.abstractmethod
-	def isCompound(self):
-		pass
-
-class SimpleExpression(Expression):
-	def isCompound(self):
-		return False
-
-class CompoundExpression(Expression):
-	def isCompound(self):
-		return True
-
-class RuntimeModuleIdentifier(SimpleExpression):
-	pass
-
-# Not a real language construct, simply 'glues' expressions together.
-class Glue(SimpleExpression, AbstractList):
-	def __init__(self):
-		self.expression_list = []
-
-	def add(self, expr):
-		self.expression_list.append(MakeExpression(expr))
-
-	def getExpressionList(self):
-		return self.expression_list
-
-
-class ForLoopCurrentElement(SimpleExpression):
-	def __init__(self, collection_expr, iterator_identifier):
-		self.collection_expr = MakeExpression(collection_expr)
-		self.iterator_identifier = iterator_identifier
-
-	def getCollectionExpression(self):
-		return self.collection_expr
-
-	def getIteratorIdentifier(self):
-		return self.iterator_identifier
-
-
-class Literal(SimpleExpression):
-	def __init__(self, text):
-		self.text = text
-
-	def getText(self):
-		return self.text
-
-
-class String(Literal):
-	def __init__(self, text):
-		Literal.__init__(self, text)
-
-
-class Property(SimpleExpression):
-	def __init__(self, owner, prop):
-		self.owner = MakeExpression(owner)
-		self.prop = prop
-
-	def getOwnerExpression(self):
-		return self.owner
-
-	def getProperty(self):
-		return self.prop
-
-
-class MapIndexedExpression(SimpleExpression):
-	def __init__(self, map_expr, key_expr):
-		self.map_expr = MakeExpression(map_expr)
-		self.key_expr = MakeExpression(key_expr)
-
-	def getMapExpression(self):
-		return self.map_expr
-
-	def getKeyExpression(self):
-		return self.key_expr
-
-
-class ArrayIndexedExpression(SimpleExpression):
-	def __init__(self, array_expr, index_expr):
-		self.array_expr = MakeExpression(array_expr)
-		self.index_expr = MakeExpression(index_expr)
-
-	def getArrayExpression(self):
-		return self.array_expr
-
-	def getIndexExpression(self):
-		return self.index_expr
-
-
-class ActualParameters(GenericConstruct, AbstractList):
-	def __init__(self, parameter_list = None):
-		if parameter_list is None: parameter_list = []
-		self.parameter_list = MakeExpressionList(parameter_list)
-
-	def add(self, p):
-		self.parameter_list.append(MakeExpression(p))
-		pass
-
-	def getParameterList(self):
-		return self.parameter_list
-
-
-class FunctionCallBase(SimpleExpression):
-	def __init__(self, actual_parameters = None):
-		if actual_parameters is None: actual_parameters = ActualParameters()
-		self.actual_parameters = MakeActualParameters(actual_parameters)
-
-	def getActualParameters(self):
-		return self.actual_parameters
-	
-
-
-class FunctionCall(FunctionCallBase):
-	def __init__(self, function_expr, actual_parameters = None):
-		FunctionCallBase.__init__(self, actual_parameters)
-		self.function_expr = MakeExpression(function_expr)
-
-	def getFunctionExpression(self):
-		return self.function_expr
-
-
-class SuperClassCallBase(FunctionCallBase):
-	def __init__(self, super_class_identifier, actual_parameters = None):
-		FunctionCallBase.__init__(self, actual_parameters)
-		self.super_class_identifier = super_class_identifier
-
-	def getSuperClassIdentifier(self):
-		return self.super_class_identifier
-
-
-class SuperClassConstructorCall(SuperClassCallBase):
-	def __init__(self, super_class_identifier, actual_parameters = None):
-		SuperClassCallBase.__init__(self, super_class_identifier, actual_parameters)
-
-
-class SuperClassDestructorCall(SuperClassCallBase):
-	def __init__(self, super_class_identifier):
-		SuperClassCallBase.__init__(self, super_class_identifier)
-
-
-class SuperClassMethodCall(SuperClassCallBase):
-	def __init__(self, super_class_identifier, method_identifier, actual_parameters = None):
-		SuperClassCallBase.__init__(self, super_class_identifier, actual_parameters)
-		self.method_identifier = method_identifier
-
-	def getMethodIdentifier(self):
-		return self.method_identifier
-
-
-class NewExpression(FunctionCallBase):
-	def __init__(self, type_expr, actual_parameters = None):
-		FunctionCallBase.__init__(self, actual_parameters)
-		self.type_expr = MakeExpression(type_expr)
-
-	def getTypeExpression(self):
-		return self.type_expr
-
-
-class SelfExpression(SimpleExpression):
-	pass
-
-
-class SelfProperty(Property):
-	def __init__(self, prop):
-		Property.__init__(self, SelfExpression(), prop)
-
-
-class Operator(GenericConstruct):
-	pass
-
-
-class AndOperator(Operator):
-	pass
-
-class OrOperator(Operator):
-	pass
-
-class LessThanOperator(Operator):
-	pass
-
-class GreaterThanOperator(Operator):
-	pass
-
-class NotOperator(Operator):
-	pass
-
-class EqualsOperator(Operator):
-	pass
-
-class AssignmentOperator(Operator):
-	pass
-
-class ProductOperator(Operator):
-	pass
-
-
-class UnaryExpression(CompoundExpression):
-	def __init__(self, operator, expr):
-		self.operator = operator
-		self.expr = MakeExpression(expr)
-
-	def getExpression(self):
-		return self.expr
-
-	def getOperator(self):
-		return self.operator
-
-
-class BinaryExpression(CompoundExpression):
-	def __init__(self, lhs_expr, operator, rhs_expr):
-		self.lhs_expr = MakeExpression(lhs_expr)
-		self.operator = operator
-		self.rhs_expr = MakeExpression(rhs_expr)
-
-	def getLhsExpression(self):
-		return self.lhs_expr
-
-	def getRhsExpression(self):
-		return self.rhs_expr
-
-	def getOperator(self):
-		return self.operator
-
-
-class NotExpression(UnaryExpression):
-	def __init__(self, expr):
-		UnaryExpression.__init__(self, NotOperator(), expr)
-
-class AndExpression(BinaryExpression):
-	def __init__(self, lexpr = None, rexpr = None):
-		BinaryExpression.__init__(self, lexpr, AndOperator(), rexpr)
-
-class OrExpression(BinaryExpression):
-	def __init__(self, lexpr = None, rexpr = None):
-		BinaryExpression.__init__(self, lexpr, OrOperator(), rexpr)
-
-class LessThanExpression(BinaryExpression):
-	def __init__(self, lexpr = None, rexpr = None):
-		BinaryExpression.__init__(self, lexpr, LessThanOperator(), rexpr)
-
-class GreaterThanExpression(BinaryExpression):
-	def __init__(self, lexpr = None, rexpr = None):
-		BinaryExpression.__init__(self, lexpr, GreaterThanOperator(), rexpr)
-
-class EqualsExpression(BinaryExpression):