瀏覽代碼

Add warning to object_operations not to use dict_add_fast

Yentl Van Tendeloo 8 年之前
父節點
當前提交
359d00ca73
共有 1 個文件被更改,包括 4 次插入27 次删除
  1. 4 27
      bootstrap/object_operations.alc

+ 4 - 27
bootstrap/object_operations.alc

@@ -114,13 +114,14 @@ Element function getAttributeList(model : Element, element : String):
 
 	while (read_nr_out(types) > 0):
 		type = set_pop(types)
-		keys = dict_keys(model["metamodel"]["model"][type])
 
 		// Add our own attributes
-		while (0 < list_len(keys)):
+		keys = dict_keys(model["metamodel"]["model"][type])
+		while (read_nr_out(keys) > 0):
 			attr_name = set_pop(keys)
 			if (is_physical_string(attr_name)):
 				attr_type = reverseKeyLookup(model["metamodel"]["model"], model["metamodel"]["model"][type][attr_name])
+				// WARNING: do not change this to dict_add_fast, as this crashes random code...
 				dict_add(result, attr_name, attr_type)
 
 	return result!
@@ -137,35 +138,11 @@ Element function getInstantiatableAttributes(model : Element, element : String):
 	all_links = allOutgoingAssociationInstances(model, element, "Attribute")
 	while (read_nr_out(all_links) > 0):
 		link = set_pop(all_links)
+		// WARNING: do not change this to dict_add_fast, as this crashes random code...
 		dict_add(result, read_attribute(model, link, "name"), read_type(model, readAssociationDestination(model, link)))
 
 	return result!
 
-Element function getInstantiatableAttributes_old(model : Element, element : String):
-	Element result
-	result = create_node()
-
-	Element types
-	types = get_superclasses(model, element)
-
-	while (read_nr_out(types) > 0):
-		element = set_pop(types)
-
-		// Get all outgoing "dictionary" links
-		Element set_own
-		Element elem
-		elem = model["model"][element]
-		set_own = dict_keys(elem)
-
-		// Filter them
-		Element e
-		while (0 < read_nr_out(set_own)):
-			e = set_pop(set_own)
-			if (is_physical_string(e)):
-				dict_add(result, e, reverseKeyLookup(model["model"], elem[e]))
-
-	return result!
-
 String function reverseKeyLookup(dict : Element, element : Element):
 	Integer nr_in
 	Integer nr_out