Parcourir la source

Fixed model transformations

Yentl Van Tendeloo il y a 8 ans
Parent
commit
566436600d
3 fichiers modifiés avec 6 ajouts et 12 suppressions
  1. BIN
      bootstrap/bootstrap.m.gz
  2. 0 9
      bootstrap/transform.alc
  3. 6 3
      integration/test_pn_interface.py

BIN
bootstrap/bootstrap.m.gz


+ 0 - 9
bootstrap/transform.alc

@@ -111,12 +111,9 @@ Element function get_possible_bindings(host_model : Element, LHS_model : Element
 			else:
 				// Check local constraints and add only if positive
 				Element constraint_function
-				log("Finding constraint")
 				constraint_function = read_attribute(LHS_model, current_element, "constraint")
 				Boolean result
-				log("Executing constraint")
 				result = constraint_function(host_model, option)
-				log("Executed constraint")
 				if (result):
 					set_add(filtered_options, option)
 
@@ -255,13 +252,10 @@ Void function rewrite(host_model : Element, RHS_model : Element, mapping : Eleme
 			dict_add(new_mapping, label, new_name)
 
 	while (read_nr_out(original_RHS_labels) > 0):
-		log("Checking whether actions must be executed!")
 		label = set_pop(original_RHS_labels)
-		log("Checking for actions!")
 		action = read_attribute(RHS_model, RHS_map[label], "action")
 		if (element_neq(action, read_root())):
 			action(host_model, new_mapping[label], mapping)
-		log("DONE")
 
 	while (read_nr_out(labels_to_remove) > 0):
 		// Remove the elements linked to these labels
@@ -275,7 +269,6 @@ Void function rewrite(host_model : Element, RHS_model : Element, mapping : Eleme
 	RHS = set_pop(RHS)
 	action = read_attribute(RHS_model, RHS, "action")
 	if (element_neq(action, read_root())):
-		log("Executing global action")
 		action(host_model, new_mapping)
 
 	return!
@@ -286,13 +279,11 @@ Void function transform(host_model : Element, LHS_model : Element, RHS_model : E
 
 	// Get all possible mappings
 	mappings = match(host_model, LHS_model)
-	log("Found total mappings: " + cast_v2s(read_nr_out(mappings)))
 
 	// Select one such mapping and rewrite it
 	if (read_nr_out(mappings) > 0):
 		// Mapping found, so can rewrite it
 		mapping = set_pop(mappings)
-		log("Found example mapping " + dict_to_string(mapping))
 		rewrite(host_model, RHS_model, mapping)
 	else:
 		output("No mapping found!")

+ 6 - 3
integration/test_pn_interface.py

@@ -641,8 +641,8 @@ Boolean function constraint(host_model : Element, name : String):
 include "primitives.alh"
 include "modelling.alh"
 Void function action(host_model : Element, name : String, mapping : Element):
-\tunset_attribute(host_model, name, "tokens")
-\tinstantiate_attribute(host_model, name, "tokens", 5)
+\tlog("Assigning " + cast_v2s(read_attribute(host_model, mapping["0_p"], "tokens")))
+\tinstantiate_attribute(host_model, name, "tokens", read_attribute(host_model, mapping["0_p"], "tokens"))
 \treturn!
             """
 
@@ -679,12 +679,15 @@ Void function action(host_model : Element, name : String, mapping : Element):
              "new", "PetriNets_POST", "pn_RHS",
                 "instantiate", "RHS", "rhs",
                 "instantiate", "Post_Place", "p",
+                "instantiate", "Post_Place", "p2",
                 "instantiate", "Post_Transition", "t",
                 "instantiate", "RHS_contains", "", "rhs", "p",
+                "instantiate", "RHS_contains", "", "rhs", "p2",
                 "instantiate", "RHS_contains", "", "rhs", "t",
                 "attr_add", "p", "label", "0_p",
                 "attr_add", "t", "label", "1_t",
-                "attr_add_code", "p", "action",
+                "attr_add", "p2", "label", "3_p",
+                "attr_add_code", "p2", "action",
             ] + constructor_action + [
                 "exit",
              "transform", "pn", "pn_LHS", "pn_RHS",