Переглянути джерело

Slightly more efficient library operations

Yentl Van Tendeloo 9 роки тому
батько
коміт
e31818d6fc
2 змінених файлів з 13 додано та 10 видалено
  1. 1 2
      bootstrap/conformance_scd.alc
  2. 12 8
      bootstrap/object_operations.alc

+ 1 - 2
bootstrap/conformance_scd.alc

@@ -31,8 +31,7 @@ Boolean function is_nominal_subtype(metamodel : Element, subclass : Element, sup
 
 	while (0 < list_len(superclasses)):
 		new_superclass = set_pop(superclasses)
-		result = is_nominal_subtype(metamodel, new_superclass, superclass)
-		if (result):
+		if (is_nominal_subtype(metamodel, new_superclass, superclass)):
 			return True
 	
 	return False

+ 12 - 8
bootstrap/object_operations.alc

@@ -26,18 +26,20 @@ Element function selectPossibleIncoming(model : Element, target : String, limit_
 	// Should also include those specified on the superclass(es)
 
 	String type
-	Element metamodel
+	Element metamodel_dict
 	Element elem
 	Element result
+	Element target_element
 
 	result = create_node()
-	metamodel = model["metamodel"]
+	metamodel_dict = model["metamodel"]["model"]
+	target_element = model["model"][target]
 
 	while (0 < list_len(limit_set)):
 		type = set_pop(limit_set)
-		elem = metamodel["model"][type]
+		elem = metamodel_dict[type]
 		if (is_edge(elem)):
-			if (is_nominal_instance(model, model["model"][target], read_edge_dst(elem))):
+			if (is_nominal_instance(model, target_element, read_edge_dst(elem))):
 				set_add(result, type)
 	
 	return result
@@ -46,18 +48,20 @@ Element function selectPossibleOutgoing(model : Element, source : String, limit_
 	// Find all possible outgoing link types for the source model
 	// Should also include those specified on the superclass(es)
 	String type
-	Element metamodel
+	Element metamodel_dict
 	Element elem
 	Element result
+	Element source_element
 
 	result = create_node()
-	metamodel = model["metamodel"]
+	metamodel_dict = model["metamodel"]["model"]
+	source_element = model["model"][source]
 	
 	while (0 < list_len(limit_set)):
 		type = set_pop(limit_set)
-		elem = metamodel["model"][type]
+		elem = metamodel_dict[type]
 		if (is_edge(elem)):
-			if (is_nominal_instance(model, model["model"][source], read_edge_src(elem))):
+			if (is_nominal_instance(model, source_element, read_edge_src(elem))):
 				set_add(result, type)
 	
 	return result