Procházet zdrojové kódy

Shift all operations on "type_mapping" to typing.alc

Yentl Van Tendeloo před 8 roky
rodič
revize
5d7b1bc80e

+ 4 - 4
bootstrap/core_algorithm.alc

@@ -108,7 +108,7 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 	if (element_neq(choice, read_root())):
 		if (set_len(allAssociationDestinations(core, choice, "typing")) == 1):
 			// Add the preferred original type mapping
-			dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
+			set_type_mapping(m, import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
 		else:
 			// Start from scratch
 			new_type_mapping(m)
@@ -377,8 +377,8 @@ String function export_typing(model : Element, name : String, user_id : String):
 
 	// Create type mapping model
 	String location
-	location = "type mappings/" + cast_id2s(model["type_mapping"])
-	export_node(location, model["type_mapping"])
+	location = "type mappings/" + cast_id2s(get_type_mapping(model))
+	export_node(location, get_type_mapping(model))
 
 	String instance_of
 	name = store_entry(result, name, get_user_id("admin"))
@@ -627,7 +627,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 			Element new_tracability_model
 			new_tracability_model = result["__tracability"]
 			dict_overwrite(tracability_model, "model", new_tracability_model["model"])
-			dict_overwrite(tracability_model, "type_mapping", new_tracability_model["type_mapping"])
+			set_type_mapping(tracability_model, get_type_mapping(new_tracability_model))
 			dict_overwrite(tracability_model, "metamodel", new_tracability_model["metamodel"])
 			dict_delete(result, "__tracability")
 

+ 2 - 1
bootstrap/mini_modify.alc

@@ -6,6 +6,7 @@ include "conformance_scd.alh"
 include "io.alh"
 include "metamodels.alh"
 include "modelling.alh"
+include "typing.alh"
 
 Boolean verbose = True
 
@@ -88,7 +89,7 @@ String function cmd_upload(write : Boolean, model : Element):
 		output("Waiting for model constructors...")
 		new_model = construct_model_raw(model["metamodel"])
 		dict_overwrite(model, "model", new_model["model"])
-		dict_overwrite(model, "type_mapping", new_model["type_mapping"])
+		set_type_mapping(model, get_type_mapping(new_model))
 		return "Success"!
 	else:
 		return "Permission denied to write"!

+ 7 - 0
bootstrap/typing.alc

@@ -42,3 +42,10 @@ Void function new_type_mapping(model : Element):
 Void function remove_type(model : Element, name : String):
 	dict_delete(model["type_mapping"], name)
 	return !
+
+Void function set_type_mapping(model : Element, type_mapping : Element):
+	dict_overwrite(model, "type_mapping", type_mapping)
+	return!
+
+Element function get_type_mapping(model : Element):
+	return model["type_mapping"]!

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

@@ -3,3 +3,5 @@ String function read_type(model : Element, name : String)
 Void function retype(model : Element, element : String, type : String)
 Void function new_type_mapping(model : Element)
 Void function remove_type(model : Element, name : String)
+Void function set_type_mapping(model : Element, type_mapping : Element)
+Element function get_type_mapping(model : Element)