Bladeren bron

Add two library functions and add constraints on all sides of the Tile

Yentl Van Tendeloo 9 jaren geleden
bovenliggende
commit
8ab906c727

+ 2 - 2
bootstrap/compilation_manager.alc

@@ -49,13 +49,13 @@ Element function compilation_manager():
 		dict_add(node, "symbols", symbols)
 		while (input()):
 			dict_add(symbols, input(), input())
+	elif (operation == "remove_obj"):
+		dict_delete(root, input())
 	elif (operation == "read_symbols"):
 		output(read_symbols(root, input()))
 	elif (operation == "read_initializers"):
 		node = root[input()]["initializers"]
 		output(node)
-	elif (operation == "remove_obj"):
-		dict_delete(root, input())
 	elif (operation == "is_defined"):
 		object_name = input()
 		if (dict_in(root, object_name)):

+ 6 - 0
bootstrap/object_operations.alc

@@ -163,3 +163,9 @@ String function print_dict(dict : Element):
 		result = result + cast_v2s(dict[key])
 		result = result + "\n"
 	return result
+
+String function readAssociationSource(model : Element, name : String):
+	return reverseKeyLookup(model["model"], read_edge_src(model["model"][name]))
+
+String function readAssociationDestination(model : Element, name : String):
+	return reverseKeyLookup(model["model"], read_edge_dst(model["model"][name]))

+ 40 - 5
integration/test_pn_interface.py

@@ -420,16 +420,51 @@ Element function constraint(model : Element, name : String):
 \tassociations = allOutgoingAssociationInstances(model, name, "tile_left")
 \twhile (0 < list_len(associations)):
 \t\tassociation = set_pop(associations)
-\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(model["model"][association]))
+\t\tdestination = readAssociationDestination(model, association)
 \t\tback_associations = allOutgoingAssociationInstances(model, destination, "tile_right")
 \t\tif (list_len(back_associations) < 1):
-\t\t\treturn "Left link does not have a right link back at "
+\t\t\treturn "Left link does not have a right link back"
 \t\telse:
 \t\t\tassociation = set_pop(back_associations)
-\t\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(model["model"][association]))
+\t\t\tdestination = readAssociationDestination(model, association)
 \t\t\tif (destination != name):
-\t\t\t\treturn "Left link does not have a right link back to the same node at "
-\tlog("All OK for " + name)
+\t\t\t\treturn "Right link does not have a left link back to the same tile"
+\tassociations = allOutgoingAssociationInstances(model, name, "tile_right")
+\twhile (0 < list_len(associations)):
+\t\tassociation = set_pop(associations)
+\t\tdestination = readAssociationDestination(model, association)
+\t\tback_associations = allOutgoingAssociationInstances(model, destination, "tile_left")
+\t\tif (list_len(back_associations) < 1):
+\t\t\treturn "Right link does not have a left link back"
+\t\telse:
+\t\t\tassociation = set_pop(back_associations)
+\t\t\tdestination = readAssociationDestination(model, association)
+\t\t\tif (destination != name):
+\t\t\t\treturn "Right link does not have a left link back to the same tile"
+\tassociations = allOutgoingAssociationInstances(model, name, "tile_top")
+\twhile (0 < list_len(associations)):
+\t\tassociation = set_pop(associations)
+\t\tdestination = readAssociationDestination(model, association)
+\t\tback_associations = allOutgoingAssociationInstances(model, destination, "tile_bottom")
+\t\tif (list_len(back_associations) < 1):
+\t\t\treturn "Top link does not have a bottom link back"
+\t\telse:
+\t\t\tassociation = set_pop(back_associations)
+\t\t\tdestination = readAssociationDestination(model, association)
+\t\t\tif (destination != name):
+\t\t\t\treturn "Top link does not have a bottom link back to the same tile"
+\tassociations = allOutgoingAssociationInstances(model, name, "tile_bottom")
+\twhile (0 < list_len(associations)):
+\t\tassociation = set_pop(associations)
+\t\tdestination = readAssociationDestination(model, association)
+\t\tback_associations = allOutgoingAssociationInstances(model, destination, "tile_top")
+\t\tif (list_len(back_associations) < 1):
+\t\t\treturn "Bottom link does not have a top link back"
+\t\telse:
+\t\t\tassociation = set_pop(back_associations)
+\t\t\tdestination = readAssociationDestination(model, association)
+\t\t\tif (destination != name):
+\t\t\t\treturn "Bottom link does not have a top link back to the same tile"
 \treturn "OK"
             """
 

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

@@ -7,3 +7,5 @@ Element function getAttributeList(model: Element, element: String)
 Element function getInstantiatableAttributes(model: Element, element: String)
 String function reverseKeyLookup(a: Element, b: Element)
 String function print_dict(dict : Element)
+String function readAssociationSource(model : Element, name : String)
+String function readAssociationDestination(model : Element, name : String)