Browse Source

Creation of simple schedule seems to work mostly

Yentl Van Tendeloo 8 years ago
parent
commit
62c84dbc67

BIN
bootstrap/bootstrap.m.gz


+ 0 - 15
bootstrap/conformance_scd.alc

@@ -4,21 +4,6 @@ include "object_operations.alh"
 include "constructors.alh"
 include "modelling.alh"
 
-Element function set_copy(a : Element):
-	Element b
-	Integer i
-	Integer count
-
-	b = create_node()
-	i = 0
-	count = read_nr_out(a)
-
-	while (i < count):
-		set_add(b, read_edge_dst(read_out(a, i)))
-		i = i + 1
-
-	return b!
-
 Boolean function is_direct_instance(model : Element, instance : String, type : String):
 	// Just check whether or not the type mapping specifies the type as the type of the instance
 	return element_eq(dict_read_node(model["type_mapping"], model["model"][instance]), model["metamodel"]["model"][type])!

+ 15 - 0
bootstrap/primitives.alc

@@ -179,3 +179,18 @@ Element function list_pop(lst : Element, index : Integer):
 	v = list_read(lst, index)
 	list_delete(lst, index)
 	return v!
+
+Element function set_copy(a : Element):
+	Element b
+	Integer i
+	Integer count
+
+	b = create_node()
+	i = 0
+	count = read_nr_out(a)
+
+	while (i < count):
+		set_add(b, read_edge_dst(read_out(a, i)))
+		i = i + 1
+
+	return b!

+ 23 - 18
bootstrap/transform.alc

@@ -6,6 +6,7 @@ Element function make_matching_schedule(LHS_model : Element):
 	Element schedule
 	Element workset
 	Element all_elements
+	Element full_all_elements
 	Integer required_size
 	String new_element
 	Integer counter
@@ -15,6 +16,7 @@ Element function make_matching_schedule(LHS_model : Element):
 	schedule = create_node()
 	workset = create_node()
 	all_elements = allInstances(LHS_model, "Pre_Element")
+	full_all_elements = set_copy(all_elements)
 	required_size = read_nr_out(all_elements)
 
 	// Need to keep adding to the schedule
@@ -41,26 +43,29 @@ Element function make_matching_schedule(LHS_model : Element):
 			log("Check if already in schedule")
 			if (bool_not(set_in(schedule, next))):
 				log("NO")
-				list_append(schedule, next)
+				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])))
+					// 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")
+					// 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!
 

+ 1 - 0
interface/HUTN/includes/primitives.alh

@@ -96,3 +96,4 @@ Element function exec(a : Element)
 Element function resolve(var_name : String)
 Boolean function has_input()
 Element function list_pop(lst : Element, index : Integer)
+Element function set_copy(set : Element)