瀏覽代碼

More dict_add_fast operations

Yentl Van Tendeloo 8 年之前
父節點
當前提交
89b402da70
共有 2 個文件被更改,包括 28 次插入28 次删除
  1. 9 9
      bootstrap/model_management.alc
  2. 19 19
      bootstrap/modelling.alc

+ 9 - 9
bootstrap/model_management.alc

@@ -119,17 +119,17 @@ Element function model_retype_on_name(model : Element, new_MM : Element, operati
 			if (operation == "+"):
 				// Keep all, but augment typename
 				dict_delete(model["type_mapping"], key)
-				dict_add(model["type_mapping"], key, name + type)
+				dict_add_fast(model["type_mapping"], key, name + type)
 			elif (operation == "-"):
 				// Keep only if typename beginning matches and remove from typename
 				if (string_startswith(type, name)):
 					dict_delete(model["type_mapping"], key)
-					dict_add(model["type_mapping"], key, string_substr(type, length, string_len(type)))
+					dict_add_fast(model["type_mapping"], key, string_substr(type, length, string_len(type)))
 				else:
 					model_delete_element(model, key)
 
 	dict_delete(model, "metamodel")
-	dict_add(model, "metamodel", new_MM)
+	dict_add_fast(model, "metamodel", new_MM)
 
 	return model!
 
@@ -161,17 +161,17 @@ Void function model_join(dst_model : Element, src_model : Element, retyping_key
 
 			if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
 				// All present, so create the link between them
-				dict_add(mapping, name, instantiate_link(dst_model, retyping_key + type, "", mapping[src], mapping[dst]))
+				dict_add_fast(mapping, name, instantiate_link(dst_model, retyping_key + type, "", mapping[src], mapping[dst]))
 			else:
 				set_add(second_keys, name)
 
 		elif (has_value(src_model["model"][name])):
 			// Has a value, so copy that as well
-			dict_add(mapping, name, instantiate_value(dst_model, retyping_key + type, "", src_model["model"][name]))
+			dict_add_fast(mapping, name, instantiate_value(dst_model, retyping_key + type, "", src_model["model"][name]))
 
 		else:
 			// Is a node
-			dict_add(mapping, name, instantiate_node(dst_model, retyping_key + type, ""))
+			dict_add_fast(mapping, name, instantiate_node(dst_model, retyping_key + type, ""))
 
 		if (read_nr_out(keys) == 0):
 			keys = second_keys
@@ -216,7 +216,7 @@ Element function model_split(src_model : Element, target_metamodel : Element, re
 
 				if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
 					// All present, so create the link between them
-					dict_add(mapping, name, instantiate_link(dst_model, new_type, "", mapping[src], mapping[dst]))
+					dict_add_fast(mapping, name, instantiate_link(dst_model, new_type, "", mapping[src], mapping[dst]))
 				elif (bool_not(bool_or(set_in(keys, src), set_in(keys, dst)))):
 					// Source/target not in the queue, but we need it to split!
 					// This is an error as it indicates problems with links crossing different formalisms
@@ -234,11 +234,11 @@ Element function model_split(src_model : Element, target_metamodel : Element, re
 
 			elif (has_value(src_model["model"][name])):
 				// Has a value, so copy that as well
-				dict_add(mapping, name, instantiate_value(dst_model, new_type, "", src_model["model"][name]))
+				dict_add_fast(mapping, name, instantiate_value(dst_model, new_type, "", src_model["model"][name]))
 
 			else:
 				// Is a node
-				dict_add(mapping, name, instantiate_node(dst_model, new_type, ""))
+				dict_add_fast(mapping, name, instantiate_node(dst_model, new_type, ""))
 
 		if (read_nr_out(keys) == 0):
 			keys = second_keys

+ 19 - 19
bootstrap/modelling.alc

@@ -22,8 +22,8 @@ Element function instantiate_bottom():
 	new_model = create_node()
 
 	// Add an empty model and empty type mapping
-	dict_add(new_model, "model", create_node())
-	dict_add(new_model, "type_mapping", create_node())
+	dict_add_fast(new_model, "model", create_node())
+	dict_add_fast(new_model, "type_mapping", create_node())
 
 	// Return the created model
 	return new_model!
@@ -36,7 +36,7 @@ String function model_add_node(model : Element, name : String):
 
 	new_node = create_node()
 	actual_name = instantiated_name(new_node, name)
-	dict_add(model["model"], actual_name, new_node)
+	dict_add_fast(model["model"], actual_name, new_node)
 
 	return actual_name!
 
@@ -45,7 +45,7 @@ String function model_add_value(model : Element, name : String, value : Element)
 	String actual_name
 
 	actual_name = instantiated_name(value, name)
-	dict_add(model["model"], actual_name, value)
+	dict_add_fast(model["model"], actual_name, value)
 
 	return actual_name!
 
@@ -68,15 +68,15 @@ String function model_add_edge(model : Element, name : String, source : String,
 
 	new_edge = create_edge(model["model"][source], model["model"][destination])
 	actual_name = instantiated_name(new_edge, name)
-	dict_add(model["model"], actual_name, new_edge)
+	dict_add_fast(model["model"], actual_name, new_edge)
 
 	return actual_name!
 
 Void function retype_model(model : Element, metamodel : Element):
 	// Remove the type mapping and add a new one for the specified metamodel
 	dict_delete(model, "type_mapping")
-	dict_add(model, "type_mapping", create_node())
-	dict_add(model, "metamodel", metamodel)
+	dict_add_fast(model, "type_mapping", create_node())
+	dict_add_fast(model, "metamodel", metamodel)
 	return!
 
 Void function retype(model : Element, element : String, type : String):
@@ -86,7 +86,7 @@ Void function retype(model : Element, element : String, type : String):
 	if (dict_in(model["type_mapping"], element)):
 		dict_delete(model["type_mapping"], element)
 
-	dict_add(model["type_mapping"], element, type)
+	dict_add_fast(model["type_mapping"], element, type)
 
 	return!
 
@@ -442,23 +442,23 @@ Void function add_AL_links(model : Element, list : Element, element : Element, t
 	link_name = "__" + cast_id2s(link)
 
 	// The link
-	dict_add(model["model"], link_name, link)
-	dict_add(model["type_mapping"], link_name, (type + "_") + linkname)
+	dict_add_fast(model["model"], link_name, link)
+	dict_add_fast(model["type_mapping"], link_name, (type + "_") + linkname)
 
 	// The name link
 	link = read_out(link, 0)
 	link_name = "__" + cast_id2s(link)
 
-	dict_add(model["model"], link_name, link)
-	dict_add(model["type_mapping"], link_name, "dict_link_name")
+	dict_add_fast(model["model"], link_name, link)
+	dict_add_fast(model["type_mapping"], link_name, "dict_link_name")
 	
 	// The name node
 	link = read_edge_dst(link)
 	link_name = "__" + cast_id2s(link)
 
 	if (bool_not(set_in_node(model["model"], link))):
-		dict_add(model["model"], link_name, link)
-		dict_add(model["type_mapping"], link_name, "StringAttr")
+		dict_add_fast(model["model"], link_name, link)
+		dict_add_fast(model["type_mapping"], link_name, "StringAttr")
 
 	// Now add the destination to the worker list
 	set_add(list, create_tuple(element[linkname], expected_type))
@@ -494,8 +494,8 @@ String function add_AL(model : Element, element : Element):
 
 			// Add the node itself
 			elem_name = "__" + cast_id2s(elem)
-			dict_add(model["model"], elem_name, elem)
-			dict_add(model["type_mapping"], elem_name, type)
+			dict_add_fast(model["model"], elem_name, elem)
+			dict_add_fast(model["type_mapping"], elem_name, type)
 
 			// Now add its edges
 			if (type == "if"):
@@ -559,7 +559,7 @@ Void function construct_model():
 		if (command == "instantiate_bottom"):
 			Element m
 			m = instantiate_bottom()
-			dict_add(global_models, input(), m)
+			dict_add_fast(global_models, input(), m)
 		elif (command == "add_node"):
 			model_add_node(global_models[input()], input())
 		elif (command == "add_value"):
@@ -575,7 +575,7 @@ Void function construct_model():
 		elif (command == "instantiate_model"):
 			Element m
 			m = instantiate_model(global_models[input()])
-			dict_add(global_models, input(), m)
+			dict_add_fast(global_models, input(), m)
 		elif (command == "instantiate_node"):
 			instantiate_node(global_models[input()], input(), input())
 		elif (command == "instantiate_attribute"):
@@ -603,7 +603,7 @@ Void function construct_model():
 			if (element_eq(m, read_root())):
 				log("Error: import not found for " + command)
 			else:
-				dict_add(global_models, input(), m)
+				dict_add_fast(global_models, input(), m)
 		elif (command == "add_code_model"):
 			add_code_model(global_models[input()], input(), construct_function())
 		else: