浏览代码

First enactment starts working

Yentl Van Tendeloo 8 年之前
父节点
当前提交
1431c3825a
共有 2 个文件被更改,包括 21 次插入10 次删除
  1. 20 9
      core/core_algorithm.alc
  2. 1 1
      integration/test_mvc.py

+ 20 - 9
core/core_algorithm.alc

@@ -480,35 +480,37 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 	String exact_type
 	Element trace_links
 
+	inputs = create_node()
+	outputs = create_node()
+
 	// TODO use the prefix for data locations (in model write/read in MvC)
 
 	log("Enacting action " + cast_v2s(read_attribute(pm, element, "name")))
 	// Read out the referenced element from the MvC
-	transformation_id = read_attribute(pm, element, "name")
+	transformation_id = get_model_id(read_attribute(pm, element, "name"))
 
 	// Find all inputs and their types (i.e., key)
 	lst = allAssociationOrigins(pm, element, "Consumes")
 	while (read_nr_out(lst) > 0):
 		elem = set_pop(lst)
-		elem = prefix + elem
 		log("Origin: " + elem)
 		// As there are no inheritance relations between full models, we can just read out the typename
-		type_name = read_attribute(core, elem, "type")
-		dict_add(inputs, type_name, read_attribute(core, elem, "name"))
+		type_name = read_attribute(pm, elem, "type")
+		dict_add(inputs, type_name, string_join(prefix, read_attribute(pm, elem, "name")))
 
 	// Find all outputs and their types (i.e., key)
 	log("Read all producers of " + element)
 	lst = allAssociationDestinations(pm, element, "Produces")
 	while (read_nr_out(lst) > 0):
 		elem = set_pop(lst)
-		elem = prefix + elem
 		log("Destination: " + elem)
 		// As there are no inheritance relations between full models, we can just read out the typename
-		type_name = read_attribute(core, elem, "type")
+		type_name = read_attribute(pm, elem, "type")
 		log("Type name: " + type_name)
-		dict_add(outputs, type_name, read_attribute(core, elem, "name"))
+		dict_add(outputs, type_name, string_join(prefix, read_attribute(pm, elem, "name")))
 
 	exact_type = read_type(core, transformation_id)
+	log("Exact type: " + exact_type)
 	if (exact_type == "ModelTransformation"):
 		// Model transformation is always in-place and uses only a single metamodel
 		// Therefore, we must:
@@ -533,14 +535,20 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		// 1) Create empty instance of merged metamodel
 
 		ramified_metamodel_id = set_pop(followAssociation(core, transformation_id, "instanceOf"))
+		log("Got ramified: " + ramified_metamodel_id)
 		trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
+		log("Trace links resolved")
 		merged_metamodel_id = ""
 		while (read_nr_out(trace_links) > 0):
 			trace_link_id = set_pop(trace_links)
 			if (value_eq(read_attribute(core, trace_link_id, "type"), "RAMified")):
 				merged_metamodel_id = readAssociationDestination(core, trace_link_id)
+				log("Got merged metamodel: " + merged_metamodel_id)
+
 		if (merged_metamodel_id != ""):
+			log("Ready for instantiate")
 			merged_model = instantiate_model(get_full_model(merged_metamodel_id))
+			log("Instantiated model")
 
 			// 2) Merge source models
 
@@ -549,7 +557,9 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			Element input_keys
 			Element output_keys
 
+			log("Fetching input keys")
 			input_keys = dict_keys(inputs)
+			log("Input keys: " + set_to_string(input_keys))
 			while (read_nr_out(input_keys) > 0):
 				key = set_pop(input_keys)
 				model_join(merged_model, get_full_model(get_model_id(inputs[key])), key + "/")
@@ -558,7 +568,6 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 
 			log("EXECUTE TRANSFORMATION " + cast_e2s(read_attribute(core, transformation_id, "name")))
 			result = transform(merged_model, schedule_model)
-			output("Transformation executed with result: " + cast_v2s(result))
 
 			// 4) Split in different files depending on type
 
@@ -579,7 +588,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 					// Model exists, so we overwrite
 					model_overwrite(split_off_model, get_model_id(outputs[key]))
 		else:
-			output("Could not resolve intermediate merged metamodel")
+			log("Intermediate not found")
 
 	elif (exact_type == "ActionLanguage"):
 		Element dictionary
@@ -688,6 +697,8 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		else:
 			output("Could not find merged metamodel")
 	else:
+		log("Type name: " + exact_type)
+		log("From " + transformation_id)
 		output("Did not know how to interpret model of type " + exact_type)
 
 	return result!

+ 1 - 1
integration/test_mvc.py

@@ -1934,7 +1934,7 @@ class TestModelverseCore(unittest.TestCase):
                 "model_list",
                 "process_execute",
                 "pn_reachability",
-                "my_"
+                "my_",
                 "model_list",
             ],
             [   # bootup phase