瀏覽代碼

Shift new type mappings to the typing file

Yentl Van Tendeloo 8 年之前
父節點
當前提交
fd4d8cde8d
共有 4 個文件被更改,包括 9 次插入6 次删除
  1. 2 2
      bootstrap/core_algorithm.alc
  2. 1 1
      bootstrap/modelling.alc
  3. 5 2
      bootstrap/typing.alc
  4. 1 1
      interface/HUTN/includes/typing.alh

+ 2 - 2
bootstrap/core_algorithm.alc

@@ -111,10 +111,10 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 			dict_add(m, "type_mapping", import_node(read_attribute(core, set_pop(allAssociationDestinations(core, choice, "typing")), "location")))
 		else:
 			// Start from scratch
-			dict_add(m, "type_mapping", new_type_mapping())
+			new_type_mapping(m)
 	else:
 		// Start from scratch
-		dict_add(m, "type_mapping", new_type_mapping())
+		new_type_mapping(m)
 	
 	if (find_type_mapping(m)):
 		// TODO store the found type model somewhere

+ 1 - 1
bootstrap/modelling.alc

@@ -78,7 +78,7 @@ Void function retype_model(model : Element, metamodel : Element):
 	if (dict_in(model, "type_mapping")):
 		dict_delete(model, "type_mapping")
 
-	dict_add_fast(model, "type_mapping", new_type_mapping())
+	new_type_mapping(model)
 	dict_add_fast(model, "metamodel", metamodel)
 	return!
 

+ 5 - 2
bootstrap/typing.alc

@@ -33,8 +33,11 @@ Void function retype(model : Element, element : String, type : String):
 	dict_add_fast(model["type_mapping"], element, type)
 	return!
 
-Element function new_type_mapping():
-	return dict_create()!
+Void function new_type_mapping(model : Element):
+	if (dict_in(model, "type_mapping")):
+		dict_delete(model, "type_mapping")
+	dict_add_fast(model, "type_mapping", dict_create())
+	return !
 
 Void function remove_type(model : Element, name : String):
 	dict_delete(model["type_mapping"], name)

+ 1 - 1
interface/HUTN/includes/typing.alh

@@ -2,5 +2,5 @@ Element function get_type_mapping_as_dict(model : Element)
 Element function get_elements_typed_by(model : Element, type : String)
 String function read_type(model : Element, name : String)
 Void function retype(model : Element, element : String, type : String)
-Element function new_type_mapping()
+Void function new_type_mapping(model : Element)
 Void function remove_type(model : Element, name : String)