Kaynağa Gözat

Fixed some more problems with MvC

Yentl Van Tendeloo 8 yıl önce
ebeveyn
işleme
b8e89654ee
3 değiştirilmiş dosya ile 33 ekleme ve 3 silme
  1. 15 0
      bootstrap/metamodels.alc
  2. 13 0
      bootstrap/modelling.alc
  3. 5 3
      core/core_algorithm.alc

+ 15 - 0
bootstrap/metamodels.alc

@@ -303,7 +303,22 @@ Element function create_metamodels():
 	return dict_read(dict_read(read_root(), "__hierarchy"), "models")!
 
 Void function add_AL_to_MM(model : Element):
+	instantiate_node(model, "AttributeValue", "PrimitiveType")
 	instantiate_node(model, "AttributeValue", "Action")
+	instantiate_node(model, "AttributeValue", "String")
+	instantiate_node(model, "AttributeValue", "Natural")
+
+	instantiate_link(model, "Inheritance", "", "Natural", "PrimitiveType")
+	instantiate_link(model, "Inheritance", "", "String", "PrimitiveType")
+	instantiate_link(model, "Inheritance", "", "Action", "PrimitiveType")
+	instantiate_link(model, "Inheritance", "", "Boolean", "PrimitiveType")
+
+	instantiate_attribute(model, "Natural", "constraint", constraint_natural)
+	instantiate_attribute(model, "String", "constraint", constraint_string)
+	instantiate_attribute(model, "Boolean", "constraint", constraint_boolean)
+
+	instantiate_node(model, "AttributeValue", "Boolean")
+
 	instantiate_link(model, "Inheritance", "", "Action", "PrimitiveType")
 	instantiate_node(model, "AttributeValue", "Statement")
 	instantiate_node(model, "AttributeValue", "Expression")

+ 13 - 0
bootstrap/modelling.alc

@@ -108,6 +108,9 @@ String function instantiate_node(model : Element, type_name : String, instance_n
 		log("    for " + instance_name)
 		return ""!
 
+	if (dict_in(model["model"], instance_name)):
+		return ""!
+
 	actual_name = model_add_node(model, instance_name)
 	retype(model, actual_name, type_name)
 
@@ -123,6 +126,9 @@ String function instantiate_value(model : Element, type_name : String, instance_
 		log("     for " + instance_name)
 		return ""!
 
+	if (dict_in(model["model"], instance_name)):
+		return ""!
+
 	actual_name = model_add_value(model, instance_name, value)
 	retype(model, actual_name, type_name)
 
@@ -207,6 +213,9 @@ Void function instantiate_attribute(model : Element, element : String, attribute
 	String attr_type
 	String attr_name
 
+	if (element_neq(read_attribute(model, element, attribute_name), read_root())):
+		unset_attribute(model, element, attribute_name)
+
 	attr_type = find_attribute_type(model, element, attribute_name)
 
 	if (attr_type == ""):
@@ -268,6 +277,9 @@ String function instantiate_link(model : Element, type : String, name : String,
 	// Create a typed link between two nodes
 	String actual_name
 
+	if (dict_in(model["model"], name)):
+		return ""!
+
 	if (type == ""):
 		// Have to find the type ourselves, as it isn't defined
 		Element out
@@ -557,6 +569,7 @@ Element function construct_model_raw(metamodel : Element):
 
 	while (True):
 		command = input()
+		log("EXEC " + command)
 		if (command == "add_node"):
 			input()
 			model_add_node(model, input())

+ 5 - 3
core/core_algorithm.alc

@@ -323,9 +323,6 @@ String function get_user_id(name : String):
 	Element users
 	String user
 
-	log("Searching user " + name)
-	log("In " + cast_e2s(core))
-	log("Has entries: " + set_to_string(dict_keys(core)))
 	users = allInstances(core, "User")
 
 	while (read_nr_out(users) > 0):
@@ -730,6 +727,7 @@ Void function user_function_skip_init(user_id : String):
 			String new_model_id
 
 			old_type_id = ""
+			log("Adding MT language")
 
 			// Read involved formalisms
 			all_formalisms = create_node()
@@ -764,7 +762,9 @@ Void function user_function_skip_init(user_id : String):
 					String tracability_link
 
 					// New location is available, so write
+					log("FUSE")
 					merged_formalism = model_fuse(set_copy(all_formalisms))
+					log("Fuse OK")
 					model_create(merged_formalism, "__merged_" + name, user_id, type_id, "Model")
 					merged_formalism_id = get_model_id("__merged_" + name)
 
@@ -775,7 +775,9 @@ Void function user_function_skip_init(user_id : String):
 						instantiate_attribute(core, tracability_link, "type", "merged")
 
 					// Merge complete, now RAMify!
+					log("RAM")
 					ramified_formalism = ramify(merged_formalism)
+					log("RAMed")
 					model_create(ramified_formalism, name, user_id, type_id, "Model")
 					ramified_formalism_id = get_model_id(name)