Explorar o código

Merge remote-tracking branch 'yentl/master' into jit

jonathanvdc %!s(int64=8) %!d(string=hai) anos
pai
achega
4ebe7a4849

BIN=BIN
bootstrap/bootstrap.m.gz


+ 15 - 8
bootstrap/conformance_scd.alc

@@ -214,7 +214,7 @@ String function conformance_scd(model : Element):
 				String result
 				Element func
 
-				func = get_func_AL_model(constraint_function)
+				func = get_func_AL_model(import_node(constraint_function))
 				result = func(model, model_name)
 
 				if (result != "OK"):
@@ -263,13 +263,20 @@ String function conformance_scd(model : Element):
 			if (result != "OK"):
 				return ((("Complex attribute doesn't match for: " + complex_instance) + "\n Message: ") + result)!
 
-	// Structure seems fine, now do static semantics
-	if (dict_in(metamodel, "constraints")):
-		Element constraint_function
-		constraint_function = metamodel["constraints"]
-		return constraint_function(model)!
-	else:
-		return "OK"!
+	// Structure seems fine, now do global constraints
+	Element global_constraints
+	String constraint
+	Element func
+
+	global_constraints = allInstances(model, "GlobalConstraints")
+	while (read_nr_out(global_constraints) > 0):
+		constraint = set_pop(global_constraints)
+		func = get_func_AL_model(import_node(read_attribute(model, constraint, "global_constraint")))
+		result = func(model)
+		if (result != "OK"):
+			return result!
+
+	return "OK"!
 
 String function check_location_conformance(instance_location : String, type_location : String):
 	// Check whether the instance is typed by the type

+ 3 - 1
bootstrap/metamodels.alc

@@ -17,7 +17,6 @@ String function constraint_Natural(model : Element, name : String):
 
 Element function constraint_String(model : Element, name : String):
 	Element self
-	log("Invoked!")
 	self = model["model"][name]
 	if (is_physical_string(self)):
 		return "OK"!
@@ -137,6 +136,9 @@ Element function initialize_SCD(location : String):
 	instantiate_attribute_code(scd, "Location", "constraint", constraint_Location)
 	instantiate_attribute_code(scd, "ActionLanguage", "constraint", constraint_ActionLanguage)
 
+	instantiate_node(scd, "Class", "GlobalConstraint")
+	model_define_attribute(scd, "GlobalConstraint", "global_constraint", False, "ActionLanguage")
+
 	return scd!
 
 Element function initialize_PN(location_SCD : String, location_PN : String):

+ 0 - 3
bootstrap/model_management.alc

@@ -56,9 +56,6 @@ Element function model_copy(src_model : Element):
 	String type
 
 	dst_model = instantiate_model(src_model["metamodel"])
-	dict_add(dst_model, "model", create_node())
-	dict_add(dst_model, "type_mapping", create_node())
-
 	queue = set_to_list(dict_keys(src_model["model"]))
 
 	while (read_nr_out(queue) > 0):

+ 2 - 9
bootstrap/modelling.alc

@@ -372,7 +372,7 @@ Element function read_attribute(model : Element, element : String, attribute : S
 			i = i + 1
 
 	else:
-		log("Element does not exist!")
+		log("Element does not exist: " + element)
 
 	// Not found: either element doesn't exist, or we couldn't find it
 	return read_root()!
@@ -629,14 +629,10 @@ Element function construct_model_raw(metamodel : Element):
 		else:
 			log("Modelling error: did not understand command " + command)
 
-Element function get_func_AL_model(model_location : String):
+Element function get_func_AL_model(al_model : Element):
 	Element result
-	Element al_model
 	Element initial_function
 
-	// Fetch the model to execute
-	al_model = import_node(model_location)
-
 	// Find the initial function
 	initial_function = allInstances(al_model, "Initial")
 
@@ -648,8 +644,5 @@ Element function get_func_AL_model(model_location : String):
 		return create_node()!
 	else:
 		initial_function = al_model["model"][set_pop(allAssociationDestinations(al_model, set_pop(initial_function), "initial_funcdef"))]
-		log("Found initial_function: " + cast_e2s(initial_function))
-		log("Keys: " + set_to_string(dict_keys(initial_function)))
-		log("Resolved " + model_location)
 
 	return initial_function!

+ 13 - 9
bootstrap/object_operations.alc

@@ -11,17 +11,21 @@ Element function allInstances(model : Element, type_name : String):
 	Element keys
 
 	keys = dict_keys(model["model"])
-	type = model["metamodel"]["model"][type_name]
-	result = create_node()
+	if (dict_in(model["metamodel"]["model"], type_name)):
+		type = model["metamodel"]["model"][type_name]
+		result = create_node()
 
-	// TODO more efficient to work backwards: find all instances of an element through the type mapping directly
-	//      must then take into account all inheritance links ourselves...
-	while (0 < list_len(keys)):
-		key = set_pop(keys)
-		if (is_nominal_instance(model, key, type_name)):
-			set_add(result, key)
+		// TODO more efficient to work backwards: find all instances of an element through the type mapping directly
+		//      must then take into account all inheritance links ourselves...
+		while (0 < list_len(keys)):
+			key = set_pop(keys)
+			if (is_nominal_instance(model, key, type_name)):
+				set_add(result, key)
 
-	return result!
+		return result!
+	else:
+		log("No such type in the metamodel!")
+		return create_node()!
 
 Element function selectPossibleIncoming(model : Element, target : String, limit_set : Element):
 	// Find all possible incoming link types for the target model

+ 7 - 7
bootstrap/transform.alc

@@ -4,6 +4,7 @@ include "modelling.alh"
 include "random.alh"
 include "conformance_scd.alh"
 include "model_management.alh"
+include "library.alh"
 
 Element function make_matching_schedule(schedule_model : Element, LHS : String, ignore : Element):
 	Element schedule
@@ -120,7 +121,6 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 			options = allInstances(host_model, original_typename)
 		elif (read_nr_out(options) > 1):
 			// Multiple "only" options, which will not work out: no options!
-			log("    multi!")
 			return create_node()!
 
 	// Filter options further
@@ -146,7 +146,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 				Element func
 
 				constraint_function = read_attribute(schedule_model, current_element, "constraint")
-				func = get_func_AL_model(constraint_function)
+				func = get_func_AL_model(import_node(constraint_function))
 				result = func(host_model, option)
 
 				if (result):
@@ -178,7 +178,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 			value = read_attribute(schedule_model, current_element, attribute)
 			// Attribute might be undefined, so skip if it is
 			if (element_neq(value, read_root())):
-				func = get_func_AL_model(value)
+				func = get_func_AL_model(import_node(value))
 				result = func(read_attribute(host_model, option, string_substr(attribute, string_len("constraint_"), string_len(attribute) + 1)))
 			else:
 				result = True
@@ -276,7 +276,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	if (element_neq(constraint, read_root())):
 		while (read_nr_out(mappings) > 0):
 			map = set_pop(mappings)
-			func = get_func_AL_model(constraint)
+			func = get_func_AL_model(import_node(constraint))
 			result = func(host_model, map)
 
 			if (result):
@@ -373,7 +373,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 
 			value = read_attribute(schedule_model, RHS_map[label], attribute)
 			if (element_neq(value, read_root())):
-				func = get_func_AL_model(value)
+				func = get_func_AL_model(import_node(value))
 				result = func(host_model, new_mapping[label], mapping)
 
 				if (has_value(result)):
@@ -387,7 +387,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 		action = read_attribute(schedule_model, RHS_map[label], "action")
 		if (element_neq(action, read_root())):
 			Element func
-			func = get_func_AL_model(action)
+			func = get_func_AL_model(import_node(action))
 			func(host_model, new_mapping[label], mapping)
 
 	while (read_nr_out(labels_to_remove) > 0):
@@ -400,7 +400,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	action = read_attribute(schedule_model, RHS, "action")
 	if (element_neq(action, read_root())):
 		Element func
-		func = get_func_AL_model(action)
+		func = get_func_AL_model(import_node(action))
 		func(host_model, new_mapping)
 
 	return!

+ 145 - 4
core/core_algorithm.alc

@@ -21,16 +21,21 @@ Void function main():
 	String core_model
 	String core_formalism_model
 	String scd_model
+	Element al_model
 	String admin_group
 	String admin_user
 	String nobody_group
 	String instance_of
 	String core_formalism
 	Element scd
+	Element al
 
 	String scd_location
+	String al_location
 	scd_location = "models/SimpleClassDiagrams"
 	scd = import_node(scd_location)
+	al_location = "models/ActionLanguage"
+	al = import_node(al_location)
 
 	// Create the Model itself and make public
 	core_formalism = import_node(core_location)
@@ -94,6 +99,18 @@ Void function main():
 	instantiate_link(core, "group", "", scd_model, admin_group)
 	instantiate_link(core, "owner", "", scd_model, admin_user)
 
+	// Add the Action Language formalism
+	al_model = instantiate_node(core, "Model", "")
+	instantiate_attribute(core, al_model, "name", "ActionLanguage")
+	instantiate_attribute(core, al_model, "location", al_location + "/model")
+	instantiate_attribute(core, al_model, "permissions", "221")
+	instance_of = instantiate_link(core, "instanceOf", "", al_model, scd_model)
+	instantiate_attribute(core, instance_of, "type_mapping", al["type_mapping"])
+
+	// Make necessary links for the formalism to the owners
+	instantiate_link(core, "group", "", al_model, admin_group)
+	instantiate_link(core, "owner", "", al_model, admin_user)
+
 	// Add the core formalism already
 	core_formalism_model = instantiate_node(core, "Model", "")
 	instantiate_attribute(core, core_formalism_model, "name", "CoreFormalism")
@@ -146,6 +163,7 @@ Element function get_full_model(model_id : String):
 	Element m
 	Element all_links
 	String choice
+	log("Getting full model!")
 
 	choice = get_instanceOf_link(model_id)
 
@@ -159,6 +177,7 @@ Element function get_full_model(model_id : String):
 	else:
 		dict_add(m, "metamodel", get_full_model(readAssociationDestination(core, choice)))
 
+	log("Finished!")
 	return m!
 
 Integer function get_relation_to_model(user_id : String, model_id : String):
@@ -349,7 +368,7 @@ Void function model_create(model : Element, name : String, user_id : String, typ
 	String model_id
 	String instance_of
 
-	location = "/models/" + cast_id2s(model)
+	location = "models/" + cast_id2s(model)
 	export_node(location, model["model"])
 
 	// Manage meta-info
@@ -368,7 +387,7 @@ Void function model_overwrite(model : Element, model_id : String):
 	String location
 	String instanceOf_link
 
-	location = "/models/" + cast_id2s(model)
+	location = "models/" + cast_id2s(model)
 	export_node(location, model["model"])
 
 	// Change location in meta-data
@@ -567,7 +586,6 @@ Void function user_function_skip_init(user_id : String):
 
 							schedule_model = get_full_model(transformation_id)
 
-							// Need to fall back to the default approach, which is way slower
 							// 1) Create empty instance of merged metamodel
 
 							ramified_metamodel_id = set_pop(followAssociation(core, transformation_id, "instanceOf"))
@@ -619,7 +637,54 @@ Void function user_function_skip_init(user_id : String):
 							else:
 								output("Could not resolve intermediate merged metamodel")
 						elif (exact_type == "ActionLanguage"):
-							output("Not Implemented yet!")
+							Element dictionary
+							Element new_inputs
+							Element input_keys
+							Element output_keys
+							Element result
+							String key
+							Element func
+
+							log("Action Language execution starts!")
+							log("Getting full model for transformation")
+							log("Got model: " + cast_e2s(read_attribute(core, transformation_id, "location")))
+
+							// 1) Group source models in dictionary
+							//  --> This is just the "inputs" variable, but resolve all references
+							log("Create inputs")
+							new_inputs = create_node()
+							input_keys = dict_keys(inputs)
+							while (read_nr_out(input_keys) > 0):
+								key = set_pop(input_keys)
+								log("Resolving " + cast_e2s(key))
+								log("  --> " + cast_e2s(inputs[key]))
+								log("  ID " + cast_e2s(get_model_id(inputs[key])))
+								log("  full m " + cast_e2s(get_full_model(get_model_id(inputs[key]))))
+								dict_add(new_inputs, key, get_full_model(get_model_id(inputs[key])))
+							inputs = new_inputs
+
+							// 2) Execute action language model
+							func = get_func_AL_model(get_full_model(transformation_id))
+							log("Ready to execute: " + cast_e2s(func))
+							result = func(inputs)
+							log("Result: " + cast_e2s(result))
+
+							// 3) Split output dictionary back to seperate models
+							output_keys = dict_keys(outputs)
+							while (read_nr_out(output_keys) > 0):
+								key = set_pop(output_keys)
+								log("Splitting " + key)
+
+								// Check if the destination model already exists
+								if (get_model_id(outputs[key]) == ""):
+									// New model
+									model_create(result[key], outputs[key], user_id, get_model_id(key), "Model")
+								else:
+									// Model exists, so we overwrite
+									model_overwrite(result[key], get_model_id(outputs[key]))
+
+							log("Finished")
+
 						else:
 							output("Did not know how to interpret model of type " + exact_type)
 					else:
@@ -828,6 +893,82 @@ Void function user_function_skip_init(user_id : String):
 			else:
 				output("No such model")
 
+		elif (cmd == "transformation_add_AL"):
+			// Add an action language transformation model
+			output("Which metamodels do you want to use as source for the action code (empty string to finish)?")
+			String model_id
+			Element models
+			Element source
+			Element target
+			String name
+
+			name = input()
+			source = create_node()
+			target = create_node()
+
+			while (name != ""):
+				model_id = get_model_id(name)
+				if (model_id != ""):
+					if (bool_not(set_in(source, model_id))):
+						set_add(source, model_id)
+						output("Model added as source")
+					else:
+						output("Model already selected as source")
+				else:
+					output("No such model; try again")
+				
+				name = input()
+
+			output("Which metamodels do you want to use as target for the action code (empty string to finish)?")
+			name = input()
+			while (name != ""):
+				model_id = get_model_id(name)
+				if (model_id != ""):
+					if (bool_not(set_in(target, model_id))):
+						set_add(target, model_id)
+						output("Model added as target")
+					else:
+						output("Model already selected as target")
+				else:
+					output("No such model; try again")
+				
+				name = input()
+
+			output("Name of Action Language model?")
+			name = input()
+
+			log("Add AL is fine!")
+			if (get_model_id(name) == ""):
+				// Finished with all information, now create the model itself!
+				output("Waiting for model constructors...")
+				log("AL model: " + cast_e2s(get_model_id("ActionLanguage")))
+				log("Location: " + cast_e2s(read_attribute(core, get_model_id("ActionLanguage"), "location")))
+				log("Imported: " + cast_e2s(import_node(read_attribute(core, get_model_id("ActionLanguage"), "location"))))
+				add_code_model(get_full_model(get_model_id("ActionLanguage")), "AL/" + name, construct_function())
+				log("Exported to " + cast_e2s(import_node("AL/" + name)))
+				model_create(import_node("AL/" + name), name, user_id, get_model_id("ActionLanguage"), "ActionLanguage")
+				model_id = get_model_id(name)
+
+				// Extend metadata with info on source and target
+				String link
+				String dst
+
+				log("Adding inputs")
+				while (read_nr_out(source) > 0):
+					dst = set_pop(source)
+					log(" for " + dst)
+					link = instantiate_link(core, "transformInput", "", model_id, dst)
+					instantiate_attribute(core, link, "name", read_attribute(core, dst, "name"))
+
+				log("Adding outputs")
+				while (read_nr_out(target) > 0):
+					dst = set_pop(target)
+					log(" for " + dst)
+					link = instantiate_link(core, "transformOutput", "", model_id, dst)
+					instantiate_attribute(core, link, "name", read_attribute(core, dst, "name"))
+			else:
+				output("Model already exists")
+
 		elif (cmd == "transformation_add_MT"):
 			// Add a model transformation model
 			// Just a usual model instantiation, but need to add the source and target links based on user info

+ 27 - 20
hybrid_server/classes/mvkcontroller.xml

@@ -219,23 +219,22 @@
                 </state>
             </state>
 
-            <state id="execution">
+            <state id="execution" initial="execution">
                 <state id="execution">
                     <onentry>
                         <script>
+                            self.outputs = []
                             self.timeout = False
-                            self.destination = None
                             if self.tasks:
                                 task = self.tasks.pop()
                                 if not task in self.debugged_tasks or self.debug_info[task]['state'] == 'running':
                                     # Check if there are values to input
-                                    if self.input_queue[task]:
+                                    while self.input_queue[task]:
                                         source, args = self.input_queue[task].pop(0)
                                         for args_entry in args:
                                             self.execute_modelverse(task, "set_input", [args_entry])
 
-                                        self.destination = source
-                                        self.value = "OK"
+                                        self.outputs.append((source, "OK"))
                                         self.all_failed = False
 
                                     nr_of_steps = 1 if task in self.debugged_tasks else 100
@@ -250,15 +249,14 @@
                                         # Could at least execute one instruction, so mark it as "not failed"
                                         self.all_failed = False
 
-                                    # Check that we don't have anything to output yet, otherwise we wait
-                                    if self.destination is None:
-                                        # Perform output if there is anything
-                                        if self.output_queue[task]:
-                                            self.execute_modelverse(task, "get_output", [])
-                                            if self.mvk.success:
-                                                self.destination = self.output_queue[task].pop(0)
-                                                self.value = self.mvk.returnvalue
-                                                self.all_failed = False
+                                    # Perform output if there is anything
+                                    while self.output_queue[task]:
+                                        self.execute_modelverse(task, "get_output", [])
+                                        if self.mvk.success:
+                                            self.outputs.append((self.output_queue[task].pop(0), self.mvk.returnvalue))
+                                            self.all_failed = False
+                                        else:
+                                            break
 
                             else:
                                 if self.count >= 2000:
@@ -282,15 +280,24 @@
                         </script>
                     </onentry>
 
-                    <transition cond="self.destination is not None" after="self.sccd_yield()" target=".">
-                        <raise event="HTTP_input" scope="narrow" target="'to_mvi/%s' % self.destination">
-                            <parameter expr="json.dumps(self.value)"/>
+                    <transition cond="self.outputs" after="self.sccd_yield()" target="../process_data"/>
+
+                    <transition cond="self.timeout and not self.outputs" after="self.sccd_yield() + 0.10" target="."/>
+
+                    <transition cond="not self.timeout and not self.outputs" after="self.sccd_yield()" target="."/>
+                </state>
+
+                <state id="process_data">
+                    <transition cond="self.outputs" target=".">
+                        <script>
+                            destination, value = self.outputs.pop()
+                        </script>
+                        <raise event="HTTP_input" scope="narrow" target="'to_mvi/%s' % destination">
+                            <parameter expr="json.dumps(value)"/>
                         </raise>
                     </transition>
 
-                    <transition cond="self.timeout and self.destination is None" after="self.sccd_yield() + 0.10" target="."/>
-
-                    <transition cond="not self.timeout and self.destination is None" after="self.sccd_yield()" target="."/>
+                    <transition cond="not self.outputs" target="../execution"/>
                 </state>
             </state>
 

+ 88 - 0
integration/code/pn_simulate.alc

@@ -0,0 +1,88 @@
+include "primitives.alh"
+include "modelling.alh"
+include "random.alh"
+include "model_management.alh"
+include "object_operations.alh"
+include "modelling.alh"
+
+Element function simulate(inputs : Element):
+	log("Start PN step!")
+	Element outputs
+	outputs = create_node()
+
+	log("Inputs: " + dict_to_string(inputs))
+	log("PN input: " + cast_e2s(inputs["PetriNets_Runtime"]))
+	log("Outgoing: " + set_to_string(dict_keys(inputs["PetriNets_Runtime"])))
+
+	// Copy over the model to the output dictionary
+	dict_add(outputs, "PetriNets_Runtime", model_copy(inputs["PetriNets_Runtime"]))
+
+	log("Copy OK!")
+
+	// Do a single simulation step
+	Element model
+	model = outputs["PetriNets_Runtime"]
+
+	// Find enabled transitions
+	Element all_transitions
+	Element enabled_transitions
+	String under_study
+	Boolean enabled
+	Element in_arcs
+	String arc_under_study
+
+	all_transitions = allInstances(model, "Transition")
+	enabled_transitions = create_node()
+
+	while (0 < read_nr_out(all_transitions)):
+		under_study = set_pop(all_transitions)
+		enabled = True
+
+		// Find all incoming transitions
+		in_arcs = allIncomingAssociationInstances(model, under_study, "P2T")
+
+		while (0 < read_nr_out(in_arcs)):
+			arc_under_study = set_pop(in_arcs)
+
+			Integer present_tokens
+			Integer required_tokens
+			required_tokens = read_attribute(model, arc_under_study, "weight")
+			log("Weight: " + cast_i2s(required_tokens))
+			present_tokens = read_attribute(model, reverseKeyLookup(model["model"], read_edge_src(model["model"][arc_under_study])), "tokens")
+			log("Tokens: " + cast_i2s(present_tokens))
+			if (present_tokens < required_tokens):
+				// Less tokens than required, so disable the transition completely
+				enabled = False
+
+		if (enabled):
+			set_add(enabled_transitions, under_study)
+
+	// Pick random enabled transition
+	String transition
+
+	transition = random_choice(enabled_transitions)
+
+	// Consume tokens
+	Element workset
+	String working_arc
+	String working_place
+	Integer new_value
+
+	workset = allIncomingAssociationInstances(model, transition, "P2T")
+	while (0 < read_nr_out(workset)):
+		working_arc = set_pop(workset)
+		working_place = reverseKeyLookup(model["model"], read_edge_src(model["model"][working_arc]))
+		new_value = integer_subtraction(read_attribute(model, working_place, "tokens"), read_attribute(model, working_arc, "weight"))
+		instantiate_attribute(model, working_place, "tokens", new_value)
+
+	// Add tokens
+	workset = allOutgoingAssociationInstances(model, transition, "T2P")
+	while (0 < read_nr_out(workset)):
+		working_arc = set_pop(workset)
+		working_place = reverseKeyLookup(model["model"], read_edge_dst(model["model"][working_arc]))
+		new_value = integer_addition(read_attribute(model, working_place, "tokens"), read_attribute(model, working_arc, "weight"))
+		instantiate_attribute(model, working_place, "tokens", new_value)
+
+	// Finish up
+	log("Finished PN Step!")
+	return outputs!

+ 2 - 10
integration/test_binary2decimal.py

@@ -2,16 +2,8 @@ import unittest
 
 from utils import run_file
 
-
 class TestBinary2Decimal(unittest.TestCase):
-    def test_po_binary2decimal(self):
-        self.binary2decimal("PO")
-
-    def test_co_binary2decimal(self):
-        self.binary2decimal("CO")
-
-    def binary2decimal(self, mode):
+    def test_binary2decimal(self):
         self.assertTrue(run_file(["binary_to_decimal.alc", "primitives.alc"],
             ["1", "10", "11", "100", "001", "1100111101"],
-            [1, 2, 3, 4, 1, 829],
-            mode))
+            [1, 2, 3, 4, 1, 829]))

+ 2 - 10
integration/test_factorial.py

@@ -2,16 +2,8 @@ import unittest
 
 from utils import run_file
 
-
 class TestFactorial(unittest.TestCase):
-    def test_po_factorial(self):
-        self.factorial("PO")
-
-    def test_co_factorial(self):
-        self.factorial("CO")
-
-    def factorial(self, mode):
+    def test_factorial(self):
         self.assertTrue(run_file(["factorial.alc", "primitives.alc"],
             [1, 2, 3, 4, 20],
-            [1, 2, 6, 24, 2432902008176640000],
-            mode))
+            [1, 2, 6, 24, 2432902008176640000]))

+ 2 - 9
integration/test_fibonacci.py

@@ -4,14 +4,7 @@ from utils import run_file
 
 
 class TestFibonacci(unittest.TestCase):
-    def test_po_fibonacci(self):
-        self.fibonacci("PO")
-
-    def test_co_fibonacci(self):
-        self.fibonacci("CO")
-
-    def fibonacci(self, mode):
+    def test_fibonacci(self):
         self.assertTrue(run_file(["fibonacci.alc", "primitives.alc"],
             [1, 2, 3, 4],
-            [1, 1, 2, 3],
-            mode))
+            [1, 1, 2, 3]))

+ 2 - 10
integration/test_fibonacci_smart.py

@@ -2,16 +2,8 @@ import unittest
 
 from utils import run_file
 
-
 class TestFibonacciSmart(unittest.TestCase):
-    def test_po_fibonacci_smart(self):
-        self.fibonacci_smart("PO")
-
-    def test_co_fibonacci_smart(self):
-        self.fibonacci_smart("CO")
-
-    def fibonacci_smart(self, mode):
+    def test_fibonacci_smart(self):
         self.assertTrue(run_file(["fibonacci_smart.alc", "primitives.alc"],
             [1, 2, 3, 4, 5, 6, 7, 8],
-            [1, 1, 2, 3, 5, 8, 13, 21],
-            mode))
+            [1, 1, 2, 3, 5, 8, 13, 21]))

+ 4 - 18
integration/test_if_elif.py

@@ -4,26 +4,12 @@ from utils import run_file
 
 
 class TestIfElif(unittest.TestCase):
-    def test_po_if_elif_else(self):
-        self.if_elif_else("PO")
-
-    def test_co_if_elif_else(self):
-        self.if_elif_else("CO")
-
-    def if_elif_else(self, mode):
+    def test_if_elif_else(self):
         self.assertTrue(run_file(["if_elif_else.alc", "primitives.alc"],
             [-1, 10, 11, 0, 1, 0, -100],
-            [-1, 1, 1, 0, 1, 0, -1],
-            mode))
-
-    def test_po_if_elif(self):
-        self.if_elif("PO")
-
-    def test_co_if_elif(self):
-        self.if_elif("CO")
+            [-1, 1, 1, 0, 1, 0, -1]))
 
-    def if_elif(self, mode):
+    def test_if_elif(self):
         self.assertTrue(run_file(["if_elif.alc", "primitives.alc"],
                                  [-1, 10, 11, 0, 1, 0, -100],
-                                 [-1, 1, 1, 0, 1, 0, -1],
-                                 mode))
+                                 [-1, 1, 1, 0, 1, 0, -1]))

+ 2 - 9
integration/test_leap_year.py

@@ -4,14 +4,7 @@ from utils import run_file
 
 
 class TestLeapYear(unittest.TestCase):
-    def test_po_leap_year(self):
-        self.leap_year("PO")
-
-    def test_co_leap_year(self):
-        self.leap_year("CO")
-
-    def leap_year(self, mode):
+    def test_leap_year(self):
         self.assertTrue(run_file(["leap_year.alc", "primitives.alc"],
             [2016, 2015, 2014, 2013, 2012, 2001, 2000, 1999],
-            [True, False, False, False, True, False, False, False],
-            mode))
+            [True, False, False, False, True, False, False, False]))

+ 2 - 9
integration/test_main.py

@@ -4,14 +4,7 @@ from utils import run_file
 
 
 class TestMain(unittest.TestCase):
-    def test_po_main(self):
-        self.main("PO")
-
-    def test_co_main(self):
-        self.main("CO")
-
-    def main(self, mode):
+    def test_main(self):
         self.assertTrue(run_file(["main.alc", "primitives.alc"],
             [],
-            ["Hello, world!", "Hello, world!", "Hello, world!"],
-            mode))
+            ["Hello, world!", "Hello, world!", "Hello, world!"]))

+ 344 - 69
integration/test_mvc.py

@@ -20,13 +20,7 @@ all_files = [   "core/mini_modify.alc",
             ]
 
 class TestModelverseCore(unittest.TestCase):
-    def test_po_list(self):
-        self.list("PO")
-
-    def test_co_list(self):
-        self.list("CO")
-
-    def list(self, mode):
+    def test_list(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_list",
@@ -40,14 +34,11 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  SimpleClassDiagrams : SimpleClassDiagrams",
                      "  CoreFormalism : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  core : CoreFormalism"]),
-            ],
-            mode))
+            ]))
 
-    def test_po_list_full(self):
-        self.list_full("PO")
-
-    def list_full(self, mode):
+    def test_list_full(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_list_full",
@@ -61,14 +52,11 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
-            ],
-            mode))
+            ]))
 
-    def test_po_model_add_empty(self):
-        self.model_add_empty("PO")
-
-    def model_add_empty(self, mode):
+    def test_model_add_empty(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -93,20 +81,18 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  SimpleClassDiagrams : SimpleClassDiagrams",
                      "  CoreFormalism : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  Empty : SimpleClassDiagrams",
                      "  core : CoreFormalism"]),
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
-            ],
-            mode))
-
-    def test_po_model_empty_modify(self):
-        self.model_empty_modify("PO")
+            ]))
 
-    def model_empty_modify(self, mode):
+    def test_model_empty_modify(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -139,11 +125,13 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  SimpleClassDiagrams : SimpleClassDiagrams",
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  Empty : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  core : CoreFormalism"]),
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
                 "Which model do you want to modify?",
@@ -157,16 +145,13 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
-            ],
-            mode))
-
-    def test_po_model_overwrite(self):
-        self.model_overwrite("PO")
+            ]))
 
-    def model_overwrite(self, mode):
+    def test_model_overwrite(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -214,6 +199,7 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
                 "Which model do you want to modify?",
@@ -227,6 +213,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
@@ -236,6 +223,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   Empty : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
@@ -248,13 +236,9 @@ class TestModelverseCore(unittest.TestCase):
                      "  C : Class"]),
                 "Please give your command.",
                 "Ready for command...",
-            ],
-            mode))
-
-    def test_po_transform_add_MT_language(self):
-        self.transform_add_MT_language("PO")
+            ]))
 
-    def transform_add_MT_language(self, mode):
+    def test_transform_add_MT_language(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -284,6 +268,7 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
                 "Formalisms to include (terminate with empty string)?",
@@ -294,15 +279,12 @@ class TestModelverseCore(unittest.TestCase):
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
-            ],
-            mode))
+            ]))
 
-    def test_po_transform_add_MT_instance(self):
-        self.transform_add_MT_instance("PO")
-
-    def transform_add_MT_instance(self, mode):
+    def test_transform_add_MT_instance(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -341,6 +323,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
@@ -349,6 +332,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
@@ -370,6 +354,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets_Print : PetriNets_RAM",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
@@ -379,13 +364,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                     ]),
                 "Ready for command...",
-            ],
-            mode))
+            ]))
 
-    def test_po_transform_add_MT_pn_print_upload(self):
-        self.transform_add_MT_pn_print_upload("PO")
-
-    def transform_add_MT_pn_print_upload(self, mode):
+    def test_transform_add_MT_pn_print_upload(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -422,6 +403,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
                 "Ready for command...",
@@ -431,6 +413,7 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root admin   core : CoreFormalism"]),
@@ -449,13 +432,9 @@ class TestModelverseCore(unittest.TestCase):
                 set(["  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                     ]),
                 "Ready for command...",
-            ],
-            mode))
-
-    def test_po_transform_add_MT_pn_print_exec(self):
-        self.transform_add_MT_pn_print_exec("PO")
+            ]))
 
-    def transform_add_MT_pn_print_exec(self, mode):
+    def test_transform_add_MT_pn_print_exec(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -506,6 +485,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody   my_pn : PetriNets",
                      "  200  root admin   core : CoreFormalism"]),
@@ -514,6 +494,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Name of the RAMified transformation metamodel?",
                 "Ready for command...",
                 set(["  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  221  root admin   ActionLanguage : SimpleClassDiagrams",
                      "  221  root admin   CoreFormalism : SimpleClassDiagrams",
                      "  200  root nobody   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
@@ -543,13 +524,9 @@ class TestModelverseCore(unittest.TestCase):
                     ]),
                 "Transformation executed with result: True",
                 "Ready for command...",
-            ],
-            mode))
-
-    def test_po_transform_add_MT_pn_simulate(self):
-        self.transform_add_MT_pn_simulate("PO")
+            ]))
 
-    def transform_add_MT_pn_simulate(self, mode):
+    def test_transform_add_MT_pn_simulate(self):
         self.assertTrue(run_file(all_files,
             [ "root", "root", "root", 
                 "model_add",
@@ -680,6 +657,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # model_list
                 set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  PetriNets : SimpleClassDiagrams",
                      "  my_pn : PetriNets",
@@ -692,6 +670,7 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 # model_list
                 set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  PetriNets_Runtime : SimpleClassDiagrams",
                      "  PetriNets : SimpleClassDiagrams",
@@ -805,6 +784,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  PetriNets_RAM : SimpleClassDiagrams",
                      "  my_pn : PetriNets",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  core : CoreFormalism"]),
                 "Ready for command...",
                 # transformation_list
@@ -849,14 +829,10 @@ class TestModelverseCore(unittest.TestCase):
                     ]),
                 "Transformation executed with result: True",
                 "Ready for command...",
-            ],
-            mode))
+            ]))
 
     @slow
-    def test_po_transform_add_MT_pn_simulate_larger(self):
-        self.transform_add_MT_pn_simulate_larger("PO")
-
-    def transform_add_MT_pn_simulate_larger(self, mode):
+    def test_transform_add_MT_pn_simulate_larger(self):
         def step_and_print():
             return [ \
                 # transformation_execute (pn_step)
@@ -1015,6 +991,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  PetriNets : SimpleClassDiagrams",
                      "  my_pn : PetriNets",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  PetriNets_Runtime : SimpleClassDiagrams",
                      "  core : CoreFormalism"]),
                 "Ready for command...",
@@ -1027,6 +1004,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  PetriNets_Runtime : SimpleClassDiagrams",
                      "  PetriNets : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  PetriNets_RAM : SimpleClassDiagrams",
                      "  my_pn : PetriNets",
@@ -1130,6 +1108,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  CoreFormalism : SimpleClassDiagrams",
                      "  PetriNets_Runtime : SimpleClassDiagrams",
                      "  PetriNets : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
                      "  pn_print : PetriNets_RAM",
                      "  pn_design_to_runtime : PetriNets_RAM",
                      "  pn_runtime_to_design : PetriNets_RAM",
@@ -1162,5 +1141,301 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
                 ] + \
                     step_and_print() * 10 +
-                [],
-            mode))
+                []))
+
+    def test_transform_add_AL_pn_simulate(self):
+        self.assertTrue(run_file(all_files,
+            [ "root", "root", "root", 
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PetriNets",
+                    ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PetriNets_Runtime",
+                    ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
+                "model_add",
+                    "PetriNets",
+                    "my_pn",
+                    ] + get_model_constructor(open("integration/code/pn_design_model.mvc", "r").read()) + [
+                "model_list",
+                "transformation_add_MT_language",
+                    "PetriNets_Runtime",
+                    "PetriNets",
+                    "",
+                    "PetriNets_RAM",
+                "model_list",
+                "model_modify",
+                    "__merged_PetriNets_RAM",
+                        "instantiate",
+                            "Association",
+                            "D2R_PlaceLink",
+                            "PetriNets/Place",
+                            "PetriNets_Runtime/Place",
+                        "instantiate",
+                            "Association",
+                            "D2R_TransitionLink",
+                            "PetriNets/Transition",
+                            "PetriNets_Runtime/Transition",
+                        "instantiate",
+                            "Association",
+                            "R2D_PlaceLink",
+                            "PetriNets_Runtime/Place",
+                            "PetriNets/Place",
+                        "instantiate",
+                            "Association",
+                            "R2D_TransitionLink",
+                            "PetriNets_Runtime/Transition",
+                            "PetriNets/Transition",
+                        "exit",
+                "transformation_RAMify",
+                    "__merged_PetriNets_RAM",
+                    "PetriNets_RAM",
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets",
+                    "",
+                    "PetriNets_Runtime",
+                    "",
+                    "pn_design_to_runtime",
+                    ] + get_model_constructor(open("integration/code/pn_design_to_runtime.mvc", "r").read()) + [
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets_Runtime",
+                    "",
+                    "PetriNets",
+                    "",
+                    "pn_runtime_to_design",
+                    ] + get_model_constructor(open("integration/code/pn_runtime_to_design.mvc", "r").read()) + [
+                "transformation_add_AL",
+                    "PetriNets_Runtime",
+                    "",
+                    "PetriNets_Runtime",
+                    "",
+                    "pn_step",
+                    ] + get_constructor(open("integration/code/pn_simulate.alc", "r").read()) + [
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets",
+                    "",
+                    "",
+                    "pn_print",
+                    ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
+                "model_list",
+                "transformation_list",
+                "transformation_execute",
+                "pn_print",
+                "my_pn",
+                "transformation_execute",
+                "pn_design_to_runtime",
+                "my_pn",
+                "my_pn_runtime",
+                "transformation_execute",
+                "pn_step",
+                "my_pn_runtime",
+                "my_pn_runtime",
+                "transformation_execute",
+                "pn_runtime_to_design",
+                "my_pn_runtime",
+                "my_pn",
+                "transformation_execute",
+                "pn_print",
+                "my_pn",
+            ],
+            [   # bootup phase
+                "Desired username for admin user?",
+                "Desired password for admin user?",
+                "Please repeat the password",
+                "Passwords match!",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # transformation_add_MT_language
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  ActionLanguage : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  __merged_PetriNets_RAM : SimpleClassDiagrams",
+                     "  PetriNets_RAM : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # model_modify
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                # instantiate 1
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 2
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 3
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 4
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                "Ready for command...",
+                # transformation_RAMify
+                "Which metamodel do you want to RAMify?",
+                "Where do you want to store the RAMified metamodel?",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_AL
+                "Which metamodels do you want to use as source for the action code (empty string to finish)?",
+                "Model added as source",
+                "Which metamodels do you want to use as target for the action code (empty string to finish)?",
+                "Model added as target",
+                "Name of Action Language model?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  pn_print : PetriNets_RAM",
+                     "  pn_design_to_runtime : PetriNets_RAM",
+                     "  pn_runtime_to_design : PetriNets_RAM",
+                     "  pn_step : ActionLanguage",
+                     "  __merged_PetriNets_RAM : SimpleClassDiagrams",
+                     "  PetriNets_RAM : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  ActionLanguage : SimpleClassDiagrams",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # transformation_list
+                set(["[ModelTransformation] pn_print : PetriNets_RAM",
+                     "[ModelTransformation] pn_design_to_runtime : PetriNets_RAM",
+                     "[ModelTransformation] pn_runtime_to_design : PetriNets_RAM",
+                     "[ActionLanguage] pn_step : ActionLanguage"]),
+                "Ready for command...",
+                # transformation_execute (pn_print)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                set(['"p1" --> 1',
+                     '"p2" --> 2',
+                     '"p3" --> 3',
+                    ]),
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_design_to_runtime)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                "Which model to create for target element PetriNets_Runtime",
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_step)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets_Runtime",
+                "Which model to create for target element PetriNets_Runtime",
+                "Ready for command...",
+                # transformation_execute (pn_runtime_to_design)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets_Runtime",
+                "Which model to create for target element PetriNets",
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_print)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                set(['"p1" --> 0',
+                     '"p2" --> 1',
+                     '"p3" --> 5',
+                    ]),
+                "Transformation executed with result: True",
+                "Ready for command...",
+            ]))

+ 2 - 8
integration/test_power.py

@@ -4,13 +4,7 @@ from utils import run_file
 
 
 class TestPower(unittest.TestCase):
-    def test_po_power(self):
-        self.power("PO")
-
-    def test_cs_power(self):
-        self.power("CO")
-
-    def power(self, mode):
+    def test_power(self):
         self.assertTrue(run_file(["power.alc", "primitives.alc"],
             [1, 0, 2, 1, 5, 0, 2, 2, 3, 2, 10, 2, 10, 10],
-            [1, 2, 1, 4, 9, 100, 10000000000], mode))
+            [1, 2, 1, 4, 9, 100, 10000000000]))

+ 2 - 9
integration/test_remainder.py

@@ -2,15 +2,8 @@ import unittest
 
 from utils import run_file
 
-
 class TestRemainder(unittest.TestCase):
-    def test_po_remainder(self):
-        self.remainder("PO")
-
-    def test_cs_remainder(self):
-        self.remainder("CO")
-
-    def remainder(self, mode):
+    def test_remainder(self):
         self.assertTrue(run_file(["remainder.alc", "primitives.alc"],
             [1, 2, 20, 2, 99, 100, 17, 3],
-            [1, 0, 99, 2], mode))
+            [1, 0, 99, 2]))

+ 2 - 10
integration/test_revert.py

@@ -2,16 +2,8 @@ import unittest
 
 from utils import run_file
 
-
 class TestRevert(unittest.TestCase):
-    def test_po_revert(self):
-        self.revert("PO")
-
-    def test_cs_revert(self):
-        self.revert("CO")
-
-    def revert(self, mode):
+    def test_revert(self):
         self.assertTrue(run_file(["revert.alc", "primitives.alc"],
             ["abc", "defghi", "This is a very simple test case!", "abccba"],
-            ["cba", "ihgfed", "!esac tset elpmis yrev a si sihT", "abccba"],
-            mode))
+            ["cba", "ihgfed", "!esac tset elpmis yrev a si sihT", "abccba"]))

+ 6 - 7
integration/utils.py

@@ -97,7 +97,7 @@ def compile_file(address, mod_filename, filename, mode, proc):
         except UnboundLocalError:
             pass
 
-def run_file(files, parameters, expected, mode, wait=False):
+def run_file(files, parameters, expected, wait=False):
     # Resolve file
     import os.path
 
@@ -131,7 +131,7 @@ def run_file(files, parameters, expected, mode, wait=False):
                 model_mode = "MO"
                 mod_files.remove(mod_filename)
             else:
-                model_mode = mode
+                model_mode = "PO"
             if parallel_push:
                 import threading
                 threads.append(threading.Thread(target=compile_file, args=[address, mod_filename, mod_filename, model_mode, proc]))
@@ -143,11 +143,10 @@ def run_file(files, parameters, expected, mode, wait=False):
             for t in threads:
                 t.join()
 
-        if mode[-1] == "O":
-            # Fire up the linker
-            val = execute("link_and_load", [address, taskname] + mod_files, wait=True)
-            if val != 0:
-                raise Exception("Linking error")
+        # Fire up the linker
+        val = execute("link_and_load", [address, taskname] + mod_files, wait=True)
+        if val != 0:
+            raise Exception("Linking error")
 
         # Send the request ...
         flush_data(address, parameters)

+ 2 - 1
interface/HUTN/includes/modelling.alh

@@ -21,4 +21,5 @@ Element function read_attribute(model : Element, elem : String, name : String)
 Void function model_delete_element(model : Element, name : String)
 String function model_define_attribute(model : Element, elem : String, name : String, optional : Boolean, type : String)
 Element function construct_model_raw(metamodel : Element)
-Element function get_func_AL_model(model_location : String)
+Element function get_func_AL_model(model : Element)
+Void function add_code_model(model : Element, export_name : String, code : Element)