Browse Source

RAMification works with toolbar in GUI: assign a name to elements

Yentl Van Tendeloo 7 years ago
parent
commit
1b8062ec08
1 changed files with 22 additions and 4 deletions
  1. 22 4
      bootstrap/ramify.alc

+ 22 - 4
bootstrap/ramify.alc

@@ -49,10 +49,12 @@ Element function ramify(model : Element):
 	//  Class LHS : LHS_Root {}
 	instantiate_node(new_model, "Class", "LHS")
 	instantiate_link(new_model, "Inheritance", "", "LHS", "LHS_Root")
+	instantiate_attribute(new_model, "LHS", "name", "LHS")
 
 	//  Class NAC : LHS_Root {}
 	instantiate_node(new_model, "Class", "NAC")
 	instantiate_link(new_model, "Inheritance", "", "NAC", "LHS_Root")
+	instantiate_attribute(new_model, "NAC", "name", "NAC")
 
 	//	Class PreElement {
 	//		label : String
@@ -73,6 +75,7 @@ Element function ramify(model : Element):
 	instantiate_node(new_model, "Class", "RHS")
 	instantiate_attribute(new_model, "RHS", "lower_cardinality", 1)
 	instantiate_attribute(new_model, "RHS", "upper_cardinality", 1)
+	instantiate_attribute(new_model, "RHS", "name", "RHS")
 	model_define_attribute(new_model, "RHS", "action", True, "ActionLanguage")
 
 	//	Class PostElement {
@@ -111,6 +114,7 @@ Element function ramify(model : Element):
 	set_add(copied_attributes, "upper_cardinality")
 	set_add(copied_attributes, "source_upper_cardinality")
 	set_add(copied_attributes, "target_upper_cardinality")
+	set_add(copied_attributes, "name")
 
 	while (list_len(keys) > 0):
 		key = list_pop(keys, 0)
@@ -130,8 +134,12 @@ Element function ramify(model : Element):
 				attr_name = set_pop(local_copied_attributes)
 				if (element_neq(read_attribute(model, key, attr_name), read_root())):
 					// Attribute was defined, so reassign in both LHS and RHS
-					instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
-					instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
+					if (attr_name == "name"):
+						instantiate_attribute(new_model, "Pre_" + key, attr_name, string_join("Pre_", read_attribute(model, key, attr_name)))
+						instantiate_attribute(new_model, "Post_" + key, attr_name, string_join("Post_", read_attribute(model, key, attr_name)))
+					else:
+						instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
+						instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
 
 		elif (type_name == "AttributeLink"):
 			// Got an attribute, so find out the source and name
@@ -173,8 +181,12 @@ Element function ramify(model : Element):
 				attr_name = set_pop(local_copied_attributes)
 				if (element_neq(read_attribute(model, key, attr_name), read_root())):
 					// Attribute was defined, so reassign in both LHS and RHS
-					instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
-					instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
+					if (attr_name == "name"):
+						instantiate_attribute(new_model, "Pre_" + key, attr_name, string_join("Pre_", read_attribute(model, key, attr_name)))
+						instantiate_attribute(new_model, "Post_" + key, attr_name, string_join("Post_", read_attribute(model, key, attr_name)))
+					else:
+						instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
+						instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
 
 		elif (type_name == "Inheritance"):
 			old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
@@ -196,10 +208,12 @@ Element function ramify(model : Element):
 	//	Class Success : Entry {}
 	instantiate_node(new_model, "Class", "Success")
 	instantiate_link(new_model, "Inheritance", "", "Success", "Entry")
+	instantiate_attribute(new_model, "Success", "name", "Success")
 
 	//	Class Failure : Entry {}
 	instantiate_node(new_model, "Class", "Failure")
 	instantiate_link(new_model, "Inheritance", "", "Failure", "Entry")
+	instantiate_attribute(new_model, "Failure", "name", "Failure")
 
 	//  Class Rule : Entry {}
 	instantiate_node(new_model, "Class", "Rule")
@@ -251,20 +265,24 @@ Element function ramify(model : Element):
 	// 	Class Query : LHSRule {}
 	instantiate_node(new_model, "Class", "Query")
 	instantiate_link(new_model, "Inheritance", "", "Query", "LHSRule")
+	instantiate_attribute(new_model, "Query", "name", "Query")
 
 	//	Class Atomic : LHSRule, RHSRule {}
 	instantiate_node(new_model, "Class", "Atomic")
 	instantiate_link(new_model, "Inheritance", "", "Atomic", "LHSRule")
 	instantiate_link(new_model, "Inheritance", "", "Atomic", "RHSRule")
+	instantiate_attribute(new_model, "Atomic", "name", "Atomic")
 
 	// 	Class ForAll : LHSRule, RHSRule {}
 	instantiate_node(new_model, "Class", "ForAll")
 	instantiate_link(new_model, "Inheritance", "", "ForAll", "LHSRule")
 	instantiate_link(new_model, "Inheritance", "", "ForAll", "RHSRule")
+	instantiate_attribute(new_model, "ForAll", "name", "ForAll")
 
 	//	Class Composite : Rule {}
 	instantiate_node(new_model, "Class", "Composite")
 	instantiate_link(new_model, "Inheritance", "", "Composite", "Rule")
+	instantiate_attribute(new_model, "Composite", "name", "Composite")
 
 	//	Association Initial(Composite, Entry){
 	//		target_lower_cardinality = 1