Browse Source

Moved reverseKeyLookup to semi_primitives, as it deals with internal representations

Yentl Van Tendeloo 8 years ago
parent
commit
7b25242546

+ 0 - 38
bootstrap/object_operations.alc

@@ -145,44 +145,6 @@ Element function getInstantiatableAttributes(model : Element, element : String):
 
 	return result!
 
-String function reverseKeyLookup(dict : Element, element : Element):
-	// TODO don't know if this AL will actually work...
-	Integer nr_in
-	Integer nr_out
-	Integer counter
-	Element link
-
-	nr_in = read_nr_in(element)
-	counter = 0
-	while (counter < nr_in):
-		if (element_eq(read_edge_src(read_in(element, counter)), dict)):
-			// Got a match
-			return (read_edge_dst(read_out(read_in(element, counter), 0)))!
-
-		counter = counter + 1
-	
-	return string_join(string_join("(unknown: ", cast_e2s(element)), " )")!
-
-Element function reverseKeyLookupMulti(dict : Element, element : Element):
-	// TODO don't know if this AL will actually work...
-	Integer nr_in
-	Integer nr_out
-	Integer counter
-	Element link
-	Element result
-
-	result = set_create()
-	nr_in = read_nr_in(element)
-	counter = 0
-	while (counter < nr_in):
-		if (element_eq(read_edge_src(read_in(element, counter)), dict)):
-			// Got a match
-			set_add(result, read_edge_dst(read_out(read_in(element, counter), 0)))
-
-		counter = counter + 1
-	
-	return result!
-
 String function print_dict(dict : Element):
 	Element keys
 	Element key

+ 38 - 0
bootstrap/semi_primitives.alc

@@ -354,3 +354,41 @@ Boolean function set_in(a: Element, b: Element):
 
 Element function set_in_node(a: Element, b: Element):
 	return dict_in_node(a, b)!
+
+String function reverseKeyLookup(dict : Element, element : Element):
+	// TODO don't know if this AL will actually work...
+	Integer nr_in
+	Integer nr_out
+	Integer counter
+	Element link
+
+	nr_in = read_nr_in(element)
+	counter = 0
+	while (counter < nr_in):
+		if (element_eq(read_edge_src(read_in(element, counter)), dict)):
+			// Got a match
+			return (read_edge_dst(read_out(read_in(element, counter), 0)))!
+
+		counter = counter + 1
+	
+	return string_join(string_join("(unknown: ", cast_e2s(element)), " )")!
+
+Element function reverseKeyLookupMulti(dict : Element, element : Element):
+	// TODO don't know if this AL will actually work...
+	Integer nr_in
+	Integer nr_out
+	Integer counter
+	Element link
+	Element result
+
+	result = set_create()
+	nr_in = read_nr_in(element)
+	counter = 0
+	while (counter < nr_in):
+		if (element_eq(read_edge_src(read_in(element, counter)), dict)):
+			// Got a match
+			set_add(result, read_edge_dst(read_out(read_in(element, counter), 0)))
+
+		counter = counter + 1
+	
+	return result!

+ 0 - 2
interface/HUTN/includes/object_operations.alh

@@ -5,8 +5,6 @@ Element function allOutgoingAssociationInstances(model: Element, source_name : S
 Element function allIncomingAssociationInstances(model: Element, target_name : String, assoc_name: String)
 Element function getAttributeList(model: Element, element: String)
 Element function getInstantiatableAttributes(model: Element, element: String)
-String function reverseKeyLookup(a: Element, b: Element)
-Element function reverseKeyLookupMulti(a: Element, b: Element)
 String function print_dict(dict : Element)
 String function readAssociationSource(model : Element, name : String)
 String function readAssociationDestination(model : Element, name : String)

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

@@ -116,3 +116,5 @@ Element function make_reverse_dictionary(dict : Element)
 Element function set_create()
 Element function list_create()
 Element function dict_create()
+String function reverseKeyLookup(a: Element, b: Element)
+Element function reverseKeyLookupMulti(a: Element, b: Element)