Browse Source

Working actions in RHS for transformations

Yentl Van Tendeloo 8 years ago
parent
commit
506bbb9897
3 changed files with 5 additions and 16 deletions
  1. BIN
      bootstrap/bootstrap.m.gz
  2. 2 15
      bootstrap/transform.alc
  3. 3 1
      integration/test_pn_interface.py

BIN
bootstrap/bootstrap.m.gz


+ 2 - 15
bootstrap/transform.alc

@@ -184,7 +184,6 @@ Void function rewrite(host_model : Element, RHS_model : Element, mapping : Eleme
 	while (read_nr_out(RHS_elements) > 0):
 		tmp = set_pop(RHS_elements)
 		label = read_attribute(RHS_model, tmp, "label")
-		log("Read label of " + cast_v2s(tmp))
 		set_add(RHS_labels, label)
 		dict_add(RHS_map, label, tmp)
 
@@ -203,39 +202,28 @@ Void function rewrite(host_model : Element, RHS_model : Element, mapping : Eleme
 		label = set_pop(labels_to_remove)
 		model_delete_element(host_model, mapping[label])
 		dict_delete(new_mapping, label)
-		log("Removed " + cast_v2s(label))
 
 	while (read_nr_out(labels_to_add) > 0):
 		// Add the elements linked to these labels
 		label = list_pop(labels_to_add, 0)
-		log("Add element linked to label " + label)
-		log("Label: " + cast_v2s(label))
-		log("Element with label: " + cast_v2s(RHS_map[label]))
-		log("Element: " + cast_e2s(RHS_model["model"][RHS_map[label]]))
-		log("Value: " + cast_v2s(read_attribute(RHS_model, RHS_map[label], "label")))
 		if (element_neq(read_attribute(RHS_model, RHS_map[label], "value"), read_root())):
 			// There is an action associated with this node
-			log("Fetching action")
 			value_function = read_attribute(RHS_model, RHS_map[label], "value")
-			log("Executing action!")
-			log("Got function: " + cast_e2s(value_function))
 			value = value_function(host_model, RHS_model)
-			log("Got value to assign: " + cast_v2s(value))
 
 			typename = reverseKeyLookup(RHS_model["metamodel"]["model"], dict_read_node(RHS_model["type_mapping"], RHS_model["model"][RHS_map[label]]))
 			original_typename = string_substr(typename, 5, string_len(typename))
-			log("Instantiate type " + original_typename)
 			new_name = instantiate_value(host_model, original_typename, "", value)
 			dict_add(new_mapping, label, new_name)
 
-		elif (is_edge(RHS_model["model"][mapping[label]])):
+		elif (is_edge(RHS_model["model"][RHS_map[label]])):
 			// Edge
 			src = read_attribute(RHS_model, reverseKeyLookup(RHS_model["model"], read_edge_src(RHS_model["model"][RHS_map[label]])), "label")
 			dst = read_attribute(RHS_model, reverseKeyLookup(RHS_model["model"], read_edge_dst(RHS_model["model"][RHS_map[label]])), "label")
 			// First check whether both source and destination are already created
 			if (bool_and(dict_in(new_mapping, src), dict_in(new_mapping, dst))):
 				// Both are present, so we can make the link
-				typename = reverseKeyLookup(RHS_model["metamodel"]["model"], dict_read_node(RHS_model["type_mapping"], RHS_model["model"][mapping[label]]))
+				typename = reverseKeyLookup(RHS_model["metamodel"]["model"], dict_read_node(RHS_model["type_mapping"], RHS_model["model"][RHS_map[label]]))
 				original_typename = string_substr(typename, 5, string_len(typename))
 				new_name = instantiate_link(host_model, original_typename, "", new_mapping[src], new_mapping[dst])
 				dict_add(new_mapping, label, new_name)
@@ -247,7 +235,6 @@ Void function rewrite(host_model : Element, RHS_model : Element, mapping : Eleme
 			// Create the node and add it
 			typename = reverseKeyLookup(RHS_model["metamodel"]["model"], dict_read_node(RHS_model["type_mapping"], RHS_model["model"][RHS_map[label]]))
 			original_typename = string_substr(typename, 5, string_len(typename))
-			log("Instantiate type " + original_typename)
 			new_name = instantiate_node(host_model, original_typename, "")
 			dict_add(new_mapping, label, new_name)
 

+ 3 - 1
integration/test_pn_interface.py

@@ -554,7 +554,7 @@ Integer function value(host_model : Element, RHS_model : Element):
                 "instantiate", "Transition", "t1",
                 "instantiate", "P2T", "p2t", "p1", "t1",
                 "instantiate", "P2T", "p2t2", "p2", "t1",
-                "attr_add", "p1", "tokens", 5,
+                "attr_add", "p1", "tokens", 1,
                 "attr_add", "p2", "tokens", 2,
                 "attr_add", "p2t", "weight", 1,
                 "attr_add", "p2t2", "weight", 2,
@@ -599,6 +599,8 @@ Integer function value(host_model : Element, RHS_model : Element):
              "load", "pn",
                 "list",
                 "verify",
+                "read",
+                "p1",
                 "exit",
                 ],
             None, "PO"))