Przeglądaj źródła

Updated generate_bottom_type_mapping function

Yentl Van Tendeloo 8 lat temu
rodzic
commit
338de6eadf
1 zmienionych plików z 18 dodań i 29 usunięć
  1. 18 29
      bootstrap/conformance_scd.alc

+ 18 - 29
bootstrap/conformance_scd.alc

@@ -316,37 +316,26 @@ Element function set_model_constraints(model : Element, func : Element):
 	dict_add_fast(model, "constraints", func)
 	return model!
 
-Element function generate_bottom_type_mapping(model : Element):
-	Element mm
-	mm = model["metamodel"]["model"]
-	dict_delete(model, "type_mapping")
-	Element tm
-	tm = create_node()
-	dict_add_fast(model, "type_mapping", tm)
-	
-	// Iterate over every element
-	Element elem_keys
-	String elem
+String function model_info(model : Element, name : String):
+	return name!
 
-	elem_keys = dict_keys(model["model"])
-	while (read_nr_out(elem_keys) > 0):
-		elem = set_pop(elem_keys)
+Element function generate_bottom_type_mapping(model_dict : Element):
+	// The model is only a dictionary of elements, being the usual model["model"] value.
+	// This function returns the type mapping dictionary
+	// There are only two concepts that we can link to: "Node" and "Edge".
 
-		if (is_edge(model["model"][elem])):
-			dict_add_fast(tm, elem, "Edge")
-		else:
-			dict_add_fast(tm, elem, "Node")
+	// Iterate over each element in the model
+	Element result
+	Element elements
+	String element
 
-	return model!
+	elements = dict_keys(model_dict)
+	result = create_node()
 
-String function model_info(model : Element, name : String):
-	return name!
-	// For more detailed information
-	String result
-	result = ""
-	result = (result + "\nModel name: ") + name
-	result = (result + "\nType: ") + cast_v2s(model["type_mapping"][name])
-	result = (result + "\nValue: ") + cast_v2s(model["model"][name])
-	result = (result + "\nSource: ") + cast_v2s(reverseKeyLookup(model["model"], read_edge_src(model["model"][name])))
-	result = (result + "\nDestination: ") + cast_v2s(reverseKeyLookup(model["model"], read_edge_dst(model["model"][name])))
+	while (set_len(elements) > 0):
+		element = set_pop(elements)
+		if (is_edge(model_dict[element])):
+			dict_add_fast(result, element, "Edge")
+		else:
+			dict_add_fast(result, element, "Node")
 	return result!