Explorar o código

Fixed several problems with exogenous transformations

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
8d2c932758
Modificáronse 4 ficheiros con 37 adicións e 35 borrados
  1. BIN=BIN
      bootstrap/bootstrap.m.gz
  2. BIN=BIN
      bootstrap/minimal.m.gz
  3. 19 12
      bootstrap/model_management.alc
  4. 18 23
      integration/test_pn_interface.py

BIN=BIN
bootstrap/bootstrap.m.gz


BIN=BIN
bootstrap/minimal.m.gz


+ 19 - 12
bootstrap/model_management.alc

@@ -20,6 +20,7 @@ Element function model_fuse(name1 : String, model1 : Element, name2 : String, mo
 	// Read out some data first
 	selected_MM = model1["metamodel"]
 	new_model = instantiate_model(selected_MM)
+	dict_add(new_model, "inheritance", model1["inheritance"])
 
 	// Create a list to nicely iterate over it
 	models = create_node()
@@ -114,18 +115,24 @@ Element function model_retype_on_name(model : Element, new_MM : Element, operati
 
 	while (read_nr_out(keys) > 0):
 		key = set_pop(keys)
-		type = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][key]))
-
-		if (operation == "+"):
-			// Keep all, but augment typename
-			dict_delete_node(model["type_mapping"], model["model"][key])
-			dict_add(model["type_mapping"], model["model"][key], model["metamodel"]["model"][name + type])
-		elif (operation == "-"):
-			// Keep only if typename beginning matches and remove from typename
-			if (string_startswith(type, name)):
+		if (dict_in(model["model"], key)):
+			// Check if the element is still there, as a delete of a node might remove all attached links automatically
+			type = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], model["model"][key]))
+
+			if (operation == "+"):
+				// Keep all, but augment typename
 				dict_delete_node(model["type_mapping"], model["model"][key])
-				dict_add(model["type_mapping"], model["model"][key], model["metamodel"]["model"][string_substr(type, length, string_len(type))])
-			else:
-				model_delete_element(model, key)
+				dict_add(model["type_mapping"], model["model"][key], new_MM["model"][name + type])
+			elif (operation == "-"):
+				// Keep only if typename beginning matches and remove from typename
+				if (string_startswith(type, name)):
+					dict_delete_node(model["type_mapping"], model["model"][key])
+					dict_add(model["type_mapping"], model["model"][key], new_MM["model"][string_substr(type, length, string_len(type))])
+				else:
+					model_delete_element(model, key)
+
+	dict_delete(model, "metamodel")
+	dict_add(model, "metamodel", new_MM)
+	log("Elements in model: " + set_to_string(dict_keys(model["model"])))
 
 	return model!

+ 18 - 23
integration/test_pn_interface.py

@@ -1269,28 +1269,28 @@ Void function action(host_model : Element, name : String, mapping : Element):
                             }
                         }
                         RHS {
-                            Post_SOURCE_Place cp2t_p{
+                            Post_SOURCE_Place rhs_cp2t_p{
                                 label = "0"
                             }
-                            Post_SOURCE_Transition cp2t_t{
+                            Post_SOURCE_Transition rhs_cp2t_t{
                                 label = "1"
                             }
-                            Post_SOURCE_P2T cp2t_p2t (cp2t_p, cp2t_t){
+                            Post_SOURCE_P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
                                 label = "2"
                             }
-                            Post_TARGET_Place cp2t_p2 {
+                            Post_TARGET_Place rhs_cp2t_p2 {
                                 label = "3"
                             }
-                            Post_TARGET_Transition cp2t_t2 {
+                            Post_TARGET_Transition rhs_cp2t_t2 {
                                 label = "4"
                             }
-                            Post_PlaceLink (cp2t_p, cp2t_p2){
+                            Post_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
                                 label = "5"
                             }
-                            Post_TransitionLink (cp2t_t, cp2t_t2){
+                            Post_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
                                 label = "6"
                             }
-                            Post_TARGET_P2T cp2t_p2t2(cp2t_p2, cp2t_t2) {
+                            Post_TARGET_P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
                                 label = "7"
                                 action = $
                                     include "primitives.alh"
@@ -1310,7 +1310,7 @@ Void function action(host_model : Element, name : String, mapping : Element):
                             Pre_SOURCE_Transition ct2p_t{
                                 label = "1"
                             }
-                            Pre_SOURCE_T2P (ct2p_p, ct2p_t){
+                            Pre_SOURCE_T2P (ct2p_t, ct2p_p){
                                 label = "2"
                             }
                             Pre_TARGET_Place ct2p_p2{
@@ -1327,28 +1327,28 @@ Void function action(host_model : Element, name : String, mapping : Element):
                             }
                         }
                         RHS {
-                            Post_SOURCE_Place ct2p_p{
+                            Post_SOURCE_Place rhs_ct2p_p{
                                 label = "0"
                             }
-                            Post_SOURCE_Transition ct2p_t{
+                            Post_SOURCE_Transition rhs_ct2p_t{
                                 label = "1"
                             }
-                            Post_SOURCE_T2P (ct2p_p, ct2p_t){
+                            Post_SOURCE_T2P (rhs_ct2p_t, rhs_ct2p_p){
                                 label = "2"
                             }
-                            Post_TARGET_Place ct2p_p2 {
+                            Post_TARGET_Place rhs_ct2p_p2 {
                                 label = "3"
                             }
-                            Post_TARGET_Transition ct2p_t2 {
+                            Post_TARGET_Transition rhs_ct2p_t2 {
                                 label = "4"
                             }
-                            Post_PlaceLink (ct2p_p, ct2p_p2){
+                            Post_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
                                 label = "5"
                             }
-                            Post_TransitionLink (ct2p_t, ct2p_t2){
+                            Post_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
                                 label = "6"
                             }
-                            Post_TARGET_T2P (ct2p_p2, ct2p_t2) {
+                            Post_TARGET_T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
                                 label = "7"
                                 action = $
                                     include "primitives.alh"
@@ -1387,14 +1387,9 @@ Void function action(host_model : Element, name : String, mapping : Element):
                 "ramify", "PetriNets_SCHEDULE", "PetriNets_Design_to_Runtime",
                 ] + get_model_constructor(schedule_model) + [
                 "transform", "pn", "pn_annotate",
-                "split", "pn", "PetriNets_Runtime", "TARGET/",
+                "split", "pn", "PetriNets_Runtime", "TARGET_",
                 "load", "pn",
-                    "list",
                     "verify",
-                    "read", "t1",
-                    "read", "p1",
-                    "read", "p2",
-                    "read", "p3",
                     "exit",
             ],
           None, "PO"))