Sfoglia il codice sorgente

Less reverseKeyLookup in transform.alc

Yentl Van Tendeloo 8 anni fa
parent
commit
56cf8464c9
1 ha cambiato i file con 19 aggiunte e 6 eliminazioni
  1. 19 6
      bootstrap/transform.alc

+ 19 - 6
bootstrap/transform.alc

@@ -17,6 +17,9 @@ Element function make_matching_schedule(schedule_model : Element, LHS : String,
 	String next
 	Element tmp
 
+	Element reverse
+	reverse = make_reverse_dictionary(schedule_model["model"])
+
 	// Initialize
 	schedule = create_node()
 	workset = create_node()
@@ -52,22 +55,26 @@ Element function make_matching_schedule(schedule_model : Element, LHS : String,
 					// If it is an edge, we should also add the target and source
 					if (is_edge(schedule_model["model"][next])):
 						// Add the target/source to the schedule
-						set_add(workset, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][next])))
-						set_add(workset, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][next])))
+						//set_add(workset, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][next])))
+						//set_add(workset, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][next])))
+						set_add(workset, reverse[cast_id2s(read_edge_src(schedule_model["model"][next]))])
+						set_add(workset, reverse[cast_id2s(read_edge_dst(schedule_model["model"][next]))])
 
 					// Also add all outgoing links
 					counter = read_nr_out(schedule_model["model"][next])
 					while (counter > 0):
 						counter = counter - 1
 						if (set_in_node(schedule_model["model"], read_out(schedule_model["model"][next], counter))):
-							set_add(workset, reverseKeyLookup(schedule_model["model"], read_out(schedule_model["model"][next], counter)))
+							//set_add(workset, reverseKeyLookup(schedule_model["model"], read_out(schedule_model["model"][next], counter)))
+							set_add(workset, reverse[cast_id2s(read_out(schedule_model["model"][next], counter))])
 
 					// And incoming links
 					counter = read_nr_in(schedule_model["model"][next])
 					while (counter > 0):
 						counter = counter - 1
 						if (set_in_node(schedule_model["model"], read_in(schedule_model["model"][next], counter))):
-							set_add(workset, reverseKeyLookup(schedule_model["model"], read_in(schedule_model["model"][next], counter)))
+							//set_add(workset, reverseKeyLookup(schedule_model["model"], read_in(schedule_model["model"][next], counter)))
+							set_add(workset, reverse[cast_id2s(read_in(schedule_model["model"][next], counter))])
 
 	return schedule!
 
@@ -348,6 +355,9 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	Element action
 	Element original_RHS_labels
 
+	Element reverse
+	reverse = make_reverse_dictionary(schedule_model["model"])
+
 	LHS_labels = dict_keys(mapping)
 	RHS_labels = create_node()
 	RHS_map = create_node()
@@ -376,8 +386,11 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 		label = list_pop(labels_to_add, read_nr_out(labels_to_add) - 1)
 		if (is_edge(schedule_model["model"][RHS_map[label]])):
 			// Edge
-			src = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][RHS_map[label]])), "label")
-			dst = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][RHS_map[label]])), "label")
+			//src = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][RHS_map[label]])), "label")
+			//dst = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][RHS_map[label]])), "label")
+			src = read_attribute(schedule_model, reverse[cast_id2s(read_edge_src(schedule_model["model"][RHS_map[label]]))], "label")
+			dst = read_attribute(schedule_model, reverse[cast_id2s(read_edge_dst(schedule_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