Browse Source

Merge both typings together (partially)

Yentl Van Tendeloo 8 years ago
parent
commit
b98946af6c
1 changed files with 14 additions and 9 deletions
  1. 14 9
      bootstrap/typing.alc

+ 14 - 9
bootstrap/typing.alc

@@ -2,16 +2,20 @@ include "primitives.alh"
 include "utils.alh"
 
 Element function get_type_mapping_as_dict(model : Element):
+	//NEW_get_type_mapping_as_dict(model)
 	return OLD_get_type_mapping_as_dict(model)!
 
 String function read_type(model : Element, name : String):
+	NEW_read_type(model, name)
 	return OLD_read_type(model, name)!
 
 Void function retype(model : Element, element : String, type : String):
+	//NEW_retype(model, element, type)
 	OLD_retype(model, element, type)
 	return!
 
 Void function new_type_mapping(model : Element):
+	NEW_new_type_mapping(model)
 	OLD_new_type_mapping(model)
 	return!
 
@@ -76,7 +80,7 @@ String function NEW_read_type(model : Element, name : String):
 
 Void function NEW_retype(model : Element, element : String, type : String):
 	// Remove previous type
-	remove_type(model, element)
+	NEW_remove_type(model, element)
 
 	// Add element of the model
 	dict_add_fast(model["type_mapping"], cast_id2s(model["model"][element]), model["model"][element])
@@ -112,17 +116,17 @@ Void function NEW_remove_type(model : Element, name : String):
 	return !
 
 Element function OLD_get_type_mapping_as_dict(model : Element):
-	return model["type_mapping"]!
+	return model["type_mapping"][""]!
 
 Element function OLD_get_elements_typed_by(model : Element, type : String):
-	return reverseKeyLookupMulti(model["type_mapping"], type)!
+	return reverseKeyLookupMulti(model["type_mapping"][""], type)!
 
 String function OLD_read_type(model : Element, name : String):
 	String result
 	Element tm
 	if (dict_in(model["model"], name)):
-		if (dict_in(model["type_mapping"], name)):
-			result = model["type_mapping"][name]
+		if (dict_in(model["type_mapping"][""], name)):
+			result = model["type_mapping"][""][name]
 			if (dict_in(model["metamodel"]["model"], result)):
 				return result!
 			else:
@@ -135,17 +139,18 @@ String function OLD_read_type(model : Element, name : String):
 Void function OLD_retype(model : Element, element : String, type : String):
 	// Retype a model, deleting any previous type the element had
 	// The type string is evaluated in the metamodel previously specified
-	if (dict_in(model["type_mapping"], element)):
-		dict_delete(model["type_mapping"], element)
-	dict_add_fast(model["type_mapping"], element, type)
+	if (dict_in(model["type_mapping"][""], element)):
+		dict_delete(model["type_mapping"][""], element)
+	dict_add_fast(model["type_mapping"][""], element, type)
 	return!
 
 Void function OLD_new_type_mapping(model : Element):
 	if (dict_in(model, "type_mapping")):
 		dict_delete(model, "type_mapping")
 	dict_add_fast(model, "type_mapping", dict_create())
+	dict_add_fast(model["type_mapping"], "", dict_create())
 	return !
 
 Void function OLD_remove_type(model : Element, name : String):
-	dict_delete(model["type_mapping"], name)
+	dict_delete(model["type_mapping"][""], name)
 	return !