Explorar o código

Rewrote transformation file structure to contain a match and rewrite phase

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
14aded2864
Modificáronse 3 ficheiros con 23 adicións e 18 borrados
  1. BIN=BIN
      bootstrap/bootstrap.m.gz
  2. 16 15
      bootstrap/transform.alc
  3. 7 3
      integration/test_pn_interface.py

BIN=BIN
bootstrap/bootstrap.m.gz


+ 16 - 15
bootstrap/transform.alc

@@ -25,51 +25,37 @@ Element function make_matching_schedule(LHS_model : Element):
 		// workset is empty, but we still need to add to the list
 		// Therefore, we pick a random, unbound node, and add it to the workset
 		new_element = set_pop(all_elements)
-		log("Pick random: " + cast_v2s(new_element))
 		while (bool_or(set_in(schedule, new_element), is_edge(LHS_model["model"][new_element]))):
-			log("Picked stupid: " + cast_v2s(new_element))
 			// Element is not usable, so pick another one
 			new_element = set_pop(all_elements)
-		log("Picked: " + cast_v2s(new_element))
 		set_add(workset, new_element)
 
 		// Handle the workset
 		while (read_nr_out(workset) > 0):
 			// Still elements in the workset, so pop from these first
 			next = set_pop(workset)
-			log("Working on " + cast_v2s(next))
 
 			// Check if element might not be already used somewhere
-			log("Check if already in schedule")
 			if (bool_not(set_in(schedule, next))):
-				log("NO")
 				if (set_in(full_all_elements, next)):
 					list_append(schedule, next)
 
 					// If it is an edge, we should also add the target and source
-					log("Edge?")
 					if (is_edge(LHS_model["model"][next])):
-						log("YES")
 						// Add the target/source to the schedule
 						set_add(workset, reverseKeyLookup(LHS_model["model"], read_edge_src(LHS_model["model"][next])))
 						set_add(workset, reverseKeyLookup(LHS_model["model"], read_edge_dst(LHS_model["model"][next])))
 
 					// Also add all outgoing links
-					log("Recurse")
 					counter = read_nr_out(LHS_model["model"][next])
 					while (counter > 0):
-						log("Check")
 						counter = counter - 1
 						if (set_in_node(LHS_model["model"], read_out(LHS_model["model"][next], counter))):
-							log("ADD")
 							set_add(workset, reverseKeyLookup(LHS_model["model"], read_out(LHS_model["model"][next], counter)))
-					log("DONE")
-				else:
-					log("Not a Pre_Element and thus not matchable")
 
 	return schedule!
 
-Void function transform(host_model : Element, LHS_model : Element, RHS_model : Element):
+Element function match(host_model : Element, LHS_model : Element):
 	Element schedule
 
 	schedule = make_matching_schedule(LHS_model)
@@ -77,4 +63,19 @@ Void function transform(host_model : Element, LHS_model : Element, RHS_model : E
 	while (read_nr_out(schedule) > 0):
 		output(list_pop(schedule, 0))
 
+	Element mapping
+	mapping = create_node()
+
+	return mapping!
+
+Void function rewrite(host_model : Element, RHS_model : Element, mapping : Element):
+	output("TODO: rewrite!")
+
+	return!
+
+Void function transform(host_model : Element, LHS_model : Element, RHS_model : Element):
+	Element mapping
+	mapping = match(host_model, LHS_model)
+	rewrite(host_model, RHS_model, mapping)
+
 	return!

+ 7 - 3
integration/test_pn_interface.py

@@ -556,14 +556,18 @@ Element function constraint(model : Element, name : String):
                 "types",
                 "instantiate", "LHS", "lhs",
                 "instantiate", "Pre_Place", "p",
+                "instantiate", "Pre_Natural", "tokens",
+                "instantiate", "Pre_Place_tokens", "p_tokens", "p", "tokens",
                 "instantiate", "Pre_Transition", "t",
                 "instantiate", "Pre_P2T", "pt", "p", "t",
                 "instantiate", "LHS_contains", "", "lhs", "p",
                 "instantiate", "LHS_contains", "", "lhs", "t",
                 "instantiate", "LHS_contains", "", "lhs", "pt",
-                "attr_add", "p", "label", "old_p",
-                "attr_add", "t", "label", "old_t",
-                "attr_add", "pt", "label", "old_pt",
+                "attr_add", "tokens", "label", "0_tokens",
+                "attr_add", "p_tokens", "label", "1_p_tokens",
+                "attr_add", "p", "label", "2_p",
+                "attr_add", "t", "label", "3_t",
+                "attr_add", "pt", "label", "4_pt",
                 "verify", "exit",
              "transform", "pn", "pn_LHS", "pn_LHS",
                 ],