Browse Source

Preliminary implementation of model_copy

Yentl Van Tendeloo 8 years ago
parent
commit
b4dea75716

BIN
bootstrap/bootstrap.m.gz


+ 25 - 0
bootstrap/modelling.alc

@@ -562,6 +562,7 @@ Element function model_copy(src_model : Element):
 	Element dst_model
 	Element queue
 	Element name
+	String type
 
 	dst_model = instantiate_model(src_model["metamodel"])
 	dict_add(dst_model, "inheritance", src_model["inheritance"])
@@ -575,7 +576,31 @@ Element function model_copy(src_model : Element):
 
 		if (is_edge(src_model["model"][name])):
 			// Is an edge, so potentially queue it
+			String src
+			String dst
+
+			src = reverseKeyLookup(src_model["model"], read_edge_src(src_model["model"][name]))
+			dst = reverseKeyLookup(src_model["model"], read_edge_dst(src_model["model"][name]))
+			type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
+
+			if (bool_and(dict_in(dst_model["model"], src), dict_in(dst_model["model"], dst))):
+				// All present, so create the link between them
+				instantiate_link(dst_model, type, name, src, dst)
+			else:
+				list_append(queue, name)
+
 		elif (has_value(src_model["model"][name])):
 			// Has a value, so copy that as well
+			type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
+			instantiate_value(dst_model, type, name, src_model["model"][name])
+
 		else:
 			// Is a node
+			type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
+			instantiate_node(dst_model, type, name)
+
+	return dst_model!
+
+Element function model_retype_on_name(model : Element, new_MM : Element, operation : String, name : String):
+	// TODO
+	return model!

+ 1 - 0
bootstrap/ramify.alc

@@ -28,6 +28,7 @@ Element function create_outplace_transformation_language(source : Element, targe
 	dict_add(ramified, "inplace", False)
 	dict_add(ramified, "source", source)
 	dict_add(ramified, "target", target)
+	dict_add(ramified, "fused", fused)
 
 	return ramified!
 

+ 1 - 1
bootstrap/transform.alc

@@ -285,7 +285,7 @@ Element function transform(host_model : Element, schedule_model : Element):
 		// 		2) the host_model conforms to the fused language
 
 		// 1) Merge the languages
-		merged = model_fuse(schedule_model["metamodel"]["source"], schedule_model["metamodel"]["target"])
+		merged = schedule_model["metamodel"]["fused"]
 
 		// 2a) Copy host_model, as we will change its typing information and content out-place
 		host_model = model_copy(host_model)

+ 2 - 0
interface/HUTN/includes/modelling.alh

@@ -23,3 +23,5 @@ Void function model_delete_element(model : Element, name : String)
 Void function add_constraint(model : Element, name : String, constraint : Action)
 String function model_define_attribute(model : Element, elem : String, name : String, type : String)
 Element function model_fuse(models : Element)
+Element function model_copy(model : Element)
+Element function model_retype_on_name(model : Element, new_MM : Element, operation : String, name : String)