Quellcode durchsuchen

Updated all*AssociationInstances to use strings as well

Yentl Van Tendeloo vor 9 Jahren
Ursprung
Commit
7566327d68

+ 3 - 1
bootstrap/conformance_scd.alc

@@ -85,7 +85,7 @@ String function conformance_scd(model : Element):
 	Element dst_metamodel
 	Element element
 	Element check_list
-	Element check_type
+	String check_type
 	Element cardinalities
 	Element scd
 
@@ -171,6 +171,8 @@ String function conformance_scd(model : Element):
 					// Cardinalities defined for this association, so check them
 					lower_val = cardinalities[check_type]["tlc"]
 					upper_val = cardinalities[check_type]["tuc"]
+					log("Read instances for " + cast_e2s(model_name))
+					log("  of " + cast_e2s(check_type))
 					instances = list_len(allOutgoingAssociationInstances(model, model_name, check_type))
 					log("Instances: " + cast_i2s(instances))
 					if (dict_in(cardinalities[check_type], "tlc")):

+ 3 - 4
bootstrap/modelling.alc

@@ -90,7 +90,7 @@ String function instantiate_node(model : Element, type_name : String, instance_n
 
 	return actual_name
 
-Element function find_attribute_type(model : Element, elem : String, name : String):
+String function find_attribute_type(model : Element, elem : String, name : String):
 	Element mm_elem
 	Element direct_type
 
@@ -193,7 +193,7 @@ Element function read_attribute(model : Element, element : String, attribute : S
 
 	while (list_len(attr_links) > 0):
 		attr_link = set_pop(attr_links)
-		return read_edge_dst(attr_link)
+		return read_edge_dst(model["model"][attr_link])
 
 	return read_root()
 
@@ -208,13 +208,12 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
 
 	while (list_len(attr_links) > 0):
 		attr_link = set_pop(attr_links)
-		model_delete_element(model, getName(model, attr_link))
+		model_delete_element(model, attr_link)
 
 	return
 
 Void function construct_model():
 	String command
-	log("Enter modelling constructs!")
 	while (True):
 		command = input()
 

+ 27 - 32
bootstrap/object_operations.alc

@@ -70,45 +70,40 @@ Element function allOutgoingAssociationInstances(model : Element, source_name :
 	// Read out all outgoing edges of the model and select those that are typed by the specified association
 	// TODO for some reason this crashes if allInstances is used!
 
-	Element assoc
-	Element source
-	source = model["model"][source_name]
-	assoc = model["metamodel"]["model"][assoc_name]
-
-	Integer length
-	length = read_nr_out(source)
-
-	Integer counter
-	counter = 0
-
+	Integer nr_out
+	Integer i
+	Element out
+	String out_name
 	Element result
-	result = create_node()
 
-	Element edge
-	while (counter < length):
-		edge = read_out(source, counter)
-		if (element_eq(dict_read_node(model["type_mapping"], edge), assoc)):
-			set_add(result, edge)
-		counter = counter + 1
+	result = create_node()
+	nr_out = read_nr_out(model["model"][source_name])
+	i = 0
+	while (i < nr_out):
+		out = read_out(model["model"][source_name], i)
+		out_name = reverseKeyLookup(model["model"], out)
+		if (is_nominal_instance(model, out, model["metamodel"]["model"][assoc_name])):
+			set_add(result, out_name)
+		i = i + 1
 	return result
 
-Element function allIncomingAssociationInstances(model : Element, target_name : Element, assoc_name : Element):
+Element function allIncomingAssociationInstances(model : Element, target_name : String, assoc_name : String):
 	// Read out all outgoing edges of the model and select those that are typed by the specified association
-	Element assoc
-	Element target 
-	target = model["model"][target_name]
-	assoc = model["metamodel"]["model"][assoc_name]
-
+	Integer nr_in
+	Integer i
+	Element in
+	String in_name
 	Element result
+
 	result = create_node()
-	Element allinsts
-	allinsts = allInstances(model, assoc)
-
-	Element understudy
-	while (0 < read_nr_out(allinsts)):
-		understudy = set_pop(allinsts)
-		if (element_eq(read_edge_dst(understudy), target)):
-			set_add(result, understudy)
+	nr_in = read_nr_in(model["model"][target_name])
+	i = 0
+	while (i < nr_in):
+		in = read_out(model["model"][target_name], i)
+		in_name = reverseKeyLookup(model["model"], in)
+		if (is_nominal_instance(model, in, model["metamodel"]["model"][assoc_name])):
+			set_add(result, in_name)
+		i = i + 1
 	return result
 
 Element function readElementByName(model : Element, name : String):

+ 1 - 1
interface/HUTN/includes/object_operations.alh

@@ -1,5 +1,5 @@
 Element function allInstances(a: Element, b: Element)
-Element function allOutgoingAssociationInstances(a: Element, b: Element, c: Element)
+Element function allOutgoingAssociationInstances(model: Element, source_name : String, assoc_name: String)
 Element function allIncomingAssociationInstances(a: Element, b: Element, c: Element)
 Element function readElementByName(a: Element, b: String)
 Element function getAttributeList(a: Element, b: Element)