浏览代码

Bugfix for problems with schedule generation

Yentl Van Tendeloo 8 年之前
父节点
当前提交
bf59decadf
共有 2 个文件被更改,包括 25 次插入23 次删除
  1. 二进制
      bootstrap/bootstrap.m.gz
  2. 25 23
      bootstrap/transform.alc

二进制
bootstrap/bootstrap.m.gz


+ 25 - 23
bootstrap/transform.alc

@@ -1,51 +1,53 @@
+include "primitives.alh"
+include "object_operations.alh"
+include "modelling.alh"
+
 Element function make_matching_schedule(LHS_model : Element):
 	Element schedule
 	Element workset
 	Element all_elements
 	Integer required_size
 	String new_element
-	Element tmp
+	Integer counter
+	String next
 
+	// Initialize
 	schedule = create_node()
 	workset = create_node()
-
 	all_elements = allInstances(LHS_model, "Pre_Element")
-	//TODO is this completely true?
-	// Calculate the size of the final match
 	required_size = read_nr_out(all_elements)
 
+	// Need to keep adding to the schedule
 	while (read_nr_out(schedule) < required_size):
-		// Need to keep adding to the schedule
 
 		// 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)
-		while (bool_or(set_in(schedule, new_element), (is_edge(LHS_model["model"][new_element]))):
+		while (bool_or(set_in(schedule, new_element), is_edge(LHS_model["model"][new_element]))):
+			// Element is not usable, so pick another one
 			new_element = set_pop(all_elements)
 		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)
 
+			// Check if element might not be already used somewhere
 			if (bool_not(set_in(schedule, next))):
 				list_append(schedule, next)
 
-				if (is_edge(next)):
+				// If it is an edge, we should also add the target and source
+				if (is_edge(LHS_model["model"][next])):
 					// Add the target/source to the schedule
-					if (bool_not(set_in(schedule, read_edge_src(next)))):
-						// Add source
-						set_add(workset, read_edge_src(next))
-					if (bool_not(set_in(schedule, read_edge_dst(next)))):
-						// Add destination
-						set_add(workset, read_edge_dst(next))
-
-				// Also add all outgoing and incoming elements
-				tmp = allOutgoingAssociations(next)
-				while (read_nr_out(tmp) > 0):
-					set_add(workset, set_pop(tmp))
-				tmp = allIncomingAssociations(next)
-				while (read_nr_out(tmp) > 0):
-					set_add(workset, set_pop(tmp))
-
-	return schedule
+					set_add(workset, read_edge_src(LHS_model["model"][next]))
+					set_add(workset, read_edge_dst(LHS_model["model"][next]))
+
+				// Also add all outgoing links
+				counter = read_nr_out(LHS_model["model"][next])
+				while (counter > 0):
+					counter = counter - 1
+					if (set_in_node(LHS_model["model"], read_out(LHS_model["model"][next], counter))):
+						set_add(workset, reverseKeyLookup(LHS_model["model"], read_out(LHS_model["model"][next], counter)))
+
+	return schedule!