Explorar o código

Fixed bug with model_split: entry listed multiple times in model

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
c30fa9ed74
Modificáronse 4 ficheiros con 19 adicións e 3 borrados
  1. 12 0
      bootstrap/model_management.alc
  2. 6 1
      bootstrap/modelling.alc
  3. 0 1
      core/core_algorithm.alc
  4. 1 1
      core/mini_modify.alc

+ 12 - 0
bootstrap/model_management.alc

@@ -198,7 +198,19 @@ Element function model_split(src_model : Element, target_metamodel : Element, re
 				if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
 					// All present, so create the link between them
 					dict_add(mapping, name, instantiate_link(dst_model, new_type, "", mapping[src], mapping[dst]))
+				elif (bool_not(bool_or(set_in(queue, src), set_in(queue, dst)))):
+					// Source/target not in the queue, but we need it to split!
+					// This is an error as it indicates problems with links crossing different formalisms
+					log("ERROR: source/target of link to be included is not included!")
+					log("Source: " + src)
+					log("  type: " + read_type(src_model, src))
+					log("Destination: " + dst)
+					log("  type: " + read_type(src_model, dst))
+					log("For link: " + name)
+					log("  type: " + type)
+					return create_node()!
 				else:
+					// Still source or destination in the queue, so we wait for that
 					list_append(queue, name)
 
 			elif (has_value(src_model["model"][name])):

+ 6 - 1
bootstrap/modelling.alc

@@ -131,6 +131,7 @@ String function instantiate_value(model : Element, type_name : String, instance_
 String function find_attribute_type(model : Element, elem : String, name : String):
 	String mm_elem
 	String direct_type
+	String result
 
 	direct_type = read_type(model, elem)
 
@@ -143,7 +144,8 @@ String function find_attribute_type(model : Element, elem : String, name : Strin
 		// Couldn't find element, so is not allowed!
 		return ""!
 	else:
-		return reverseKeyLookup(model["metamodel"]["model"], dict_read_edge(model["metamodel"]["model"][mm_elem], name))!
+		result = reverseKeyLookup(model["metamodel"]["model"], dict_read_edge(model["metamodel"]["model"][mm_elem], name))
+		return result!
 
 Element function get_superclasses(model : Element, name : String):
 	Element result
@@ -211,6 +213,9 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 		log("Could not find attribute " + cast_v2s(attribute_name))
 		log("For element " + element)
 		return!
+
+	if (has_value(value)):
+		value = create_value(value)
 		
 	attr_name = model_add_value(model, (element + ".") + attribute_name, value)
 	retype(model, attr_name, reverseKeyLookup(model["metamodel"]["model"], read_edge_dst(model["metamodel"]["model"][attr_type])))

+ 0 - 1
core/core_algorithm.alc

@@ -687,7 +687,6 @@ Void function user_function_skip_init(user_id : String):
 			models = allInstances(core, "Model")
 			while (read_nr_out(models) > 0):
 				m = set_pop(models)
-				log("Read attribute name of " + cast_e2s(m))
 				output(string_join((string_join("  ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(followAssociation(core, m, "instanceOf")), "name")))
 
 		elif (cmd == "model_list_full"):

+ 1 - 1
core/mini_modify.alc

@@ -77,7 +77,7 @@ Element function modify(model : Element, write : Boolean):
 							instantiate_node(model, mm_type_name, element_name)
 							output("Instantiation successful!")
 				else:
-					log("Culd not find element in " + set_to_string(dict_keys(model["metamodel"]["model"])))
+					log("Could not find element in " + set_to_string(dict_keys(model["metamodel"]["model"])))
 					output("Unknown type specified; aborting")
 			else:
 				output("Permission denied")