Browse Source

Clean up files

Yentl Van Tendeloo 9 years ago
parent
commit
e41cc0270d
1 changed files with 114 additions and 114 deletions
  1. 114 114
      bootstrap/object_operations.alc

+ 114 - 114
bootstrap/object_operations.alc

@@ -2,28 +2,28 @@ include "primitives.alh"
 include "conformance_scd.alh"
 include "constructors.alh"
 
-Element function allInstances(model_ai : Element, type_ai : Element):
-	Element type_mapping_ai
-	Element result_ai
+Element function allInstances(model : Element, type : Element):
+	Element type_mapping
+	Element result
 
-	type_mapping_ai = dict_read(model_ai, "type_mapping")
-	result_ai = create_node()
+	type_mapping = dict_read(model, "type_mapping")
+	result = create_node()
 
-	Integer counter_ai
-	counter_ai = 0
+	Integer counter
+	counter = 0
 
-	Integer length_ai
-	length_ai = read_nr_out(type_mapping_ai)
+	Integer length
+	length = read_nr_out(type_mapping)
 
-	Element edge_ai
-	while (counter_ai < length_ai):
-		edge_ai = read_out(type_mapping_ai, counter_ai)
-		if (element_eq(read_edge_dst(edge_ai), type_ai)):
+	Element edge
+	while (counter < length):
+		edge = read_out(type_mapping, counter)
+		if (element_eq(read_edge_dst(edge), type)):
 			// Found an element of the specified type
-			set_add(result_ai, read_edge_dst(read_out(edge_ai, 0)))
-		counter_ai = counter_ai + 1
+			set_add(result, read_edge_dst(read_out(edge, 0)))
+		counter = counter + 1
 	
-	return result_ai
+	return result
 
 Element function allOutgoingAssociationInstances(model_aoai : Element, source_aoai : Element, assoc_aoai : Element):
 	// Read out all outgoing edges of the model and select those that are typed by the specified association
@@ -45,128 +45,128 @@ Element function allOutgoingAssociationInstances(model_aoai : Element, source_ao
 		counter_aoai = counter_aoai + 1
 	return result_aoai
 
-Element function allIncomingAssociationInstances(model_aiai : Element, source_aiai : Element, assoc_aiai : Element):
+Element function allIncomingAssociationInstances(model : Element, source : Element, assoc : Element):
 	// Read out all outgoing edges of the model and select those that are typed by the specified association
-	Element result_aiai
-	result_aiai = create_node()
-	Element allinsts_aiai
-	allinsts_aiai = allInstances(model_aiai, assoc_aiai)
-
-	Element understudy_aiai
-	while (0 < read_nr_out(allinsts_aiai)):
-		understudy_aiai = set_pop(allinsts_aiai)
-		if (element_eq(read_edge_dst(understudy_aiai), source_aiai)):
-			set_add(result_aiai, understudy_aiai)
-	return result_aiai
-
-Element function readElementByName(model_rebn : Element, name_rebn : String):
-	return dict_read(dict_read(model_rebn, "model"), name_rebn)
-
-Element function findAttribute(source_fa : Element, attr_name_fa : Element, types_fa : Element, inheritance_link_fa : Element):
-	if (dict_in(source_fa, attr_name_fa)):
-		return dict_read_edge(source_fa, attr_name_fa)
+	Element result
+	result = create_node()
+	Element allinsts
+	allinsts = allInstances(model, assoc)
+
+	Element understudy
+	while (0 < read_nr_out(allinsts)):
+		understudy = set_pop(allinsts)
+		if (element_eq(read_edge_dst(understudy), source)):
+			set_add(result, understudy)
+	return result
+
+Element function readElementByName(model : Element, name : String):
+	return dict_read(dict_read(model, "model"), name)
+
+Element function findAttribute(source : Element, attr_name : Element, types : Element, inheritance_link : Element):
+	if (dict_in(source, attr_name)):
+		return dict_read_edge(source, attr_name)
 	else:
-		Integer counter_fa
-		Integer i_fa
-		Element edge_fa
-		counter_fa = read_nr_out(source_fa)
-		i_fa = 0
-		while (i_fa < counter_fa):
-			edge_fa = read_out(source_fa, i_fa)
-			if (element_eq(dict_read_node(types_fa, edge_fa), inheritance_link_fa)):
-				return find_attribute(read_edge_dst(edge_fa), attr_name_fa, types_fa, inheritance_link_fa)
-			i_fa = i_fa + 1
+		Integer counter
+		Integer i
+		Element edge
+		counter = read_nr_out(source)
+		i = 0
+		while (i < counter):
+			edge = read_out(source, i)
+			if (element_eq(dict_read_node(types, edge), inheritance_link)):
+				return find_attribute(read_edge_dst(edge), attr_name, types, inheritance_link)
+			i = i + 1
 		// No return at the moment, as this crashes the MvK
 		log("ERROR: could not find attribute")
 
-Element function readAttribute(model_ra : Element, source_ra : Element, attr_name_ra : String):
+Element function readAttribute(model : Element, source : Element, attr_name : String):
 	// Read out the edge we are talking about
-	Element edge_ra
-	edge_ra = findAttribute(dict_read_node(dict_read(model_ra, "type_mapping"), source_ra), attr_name_ra, dict_read(model_ra, "type_mapping"), dict_read(model_ra, "inheritance"))
+	Element edge
+	edge = findAttribute(dict_read_node(dict_read(model, "type_mapping"), source), attr_name, dict_read(model, "type_mapping"), dict_read(model, "inheritance"))
 
-	return read_edge_dst(set_pop(allOutgoingAssociationInstances(model_ra, source_ra, edge_ra)))
+	return read_edge_dst(set_pop(allOutgoingAssociationInstances(model, source, edge)))
 
-Element function setAttribute(model_sa : Element, source_sa : Element, attr_name_sa : String, value_sa : Element):
+Element function setAttribute(model : Element, source : Element, attr_name : String, value : Element):
 	// Read out which edge we are talking about
-	Element edge_sa
-	edge_sa = deleteAttribute(model_sa, source_sa, attr_name_sa)
+	Element edge
+	edge = deleteAttribute(model, source, attr_name)
 
 	// Now make the element
-	Element created_edge_sa
-	created_edge_sa = create_edge(source_sa, value_sa)
-	dict_add(dict_read(model_sa, "type_mapping"), created_edge_sa, edge_sa)
-	dict_add(dict_read(model_sa, "type_mapping"), value_sa, read_edge_dst(edge_sa))
-	add_to_model(model_sa, "", value_sa)
-	add_to_model(model_sa, "", created_edge_sa)
+	Element created_edge
+	created_edge = create_edge(source, value)
+	dict_add(dict_read(model, "type_mapping"), created_edge, edge)
+	dict_add(dict_read(model, "type_mapping"), value, read_edge_dst(edge))
+	add_to_model(model, "", value)
+	add_to_model(model, "", created_edge)
 
 	return True
 
-Element function deleteAttribute(model_da : Element, source_da : Element, attr_name_da : Element):
-	Element edge_da
-	edge_da = findAttribute(dict_read_node(dict_read(model_da, "type_mapping"), source_da), attr_name_da, dict_read(model_da, "type_mapping"), dict_read(model_da, "inheritance"))
+Element function deleteAttribute(model : Element, source : Element, attr_name : Element):
+	Element edge
+	edge = findAttribute(dict_read_node(dict_read(model, "type_mapping"), source), attr_name, dict_read(model, "type_mapping"), dict_read(model, "inheritance"))
 
-	Element found_elements_da
-	found_elements_da = allOutgoingAssociationInstances(model_da, source_da, edge_da)
+	Element found_elements
+	found_elements = allOutgoingAssociationInstances(model, source, edge)
 
-	Element rm_element_da
-	if (list_len(found_elements_da) > 0):
-		rm_element_da = read_edge_dst(set_pop(found_elements_da))
-		dict_delete(dict_read(model_da, "type_mapping"), rm_element_da)
-		delete_element(rm_element_da)
+	Element rm_element
+	if (list_len(found_elements) > 0):
+		rm_element = read_edge_dst(set_pop(found_elements))
+		dict_delete(dict_read(model, "type_mapping"), rm_element)
+		delete_element(rm_element)
 
-	return edge_da
+	return edge
 
-Element function getAttributeList(model_gali : Element, mm_gali : Element):
-	Element result_gali
-	result_gali = create_node()
+Element function getAttributeList(model : Element, mm : Element):
+	Element result
+	result = create_node()
 	// Get all outgoing "dictionary" links
-	Element set_gali_own
-	set_gali_own = dict_keys(mm_gali)
+	Element set_own
+	set_own = dict_keys(mm)
 
 	// Filter them
-	Element e_gali
-	while (0 < read_nr_out(set_gali_own)):
-		e_gali = set_pop(set_gali_own)
-		if (typeof(e_gali) == String):
-			if (typeof(dict_read(mm_gali, e_gali)) == Type):
+	Element e
+	while (0 < read_nr_out(set_own)):
+		e = set_pop(set_own)
+		if (typeof(e) == String):
+			if (typeof(dict_read(mm, e)) == Type):
 				// This is a primitive type, so add to the list
-				dict_add(result_gali, e_gali, dict_read(mm_gali, e_gali))
+				dict_add(result, e, dict_read(mm, e))
 
 	// And go up to the possible supertypes
-	Element found_elements_gali
-	found_elements_gali = allOutgoingAssociationInstances(model_gali, mm_gali, dict_read(model_gali, "inheritance"))
-	Element dict_gali_super
-	Integer i_gali
-	Integer max_gali
-	Element set_gali_super
-	Element found_key_gali
-	while (0 < read_nr_out(found_elements_gali)):
+	Element found_elements
+	found_elements = allOutgoingAssociationInstances(model, mm, dict_read(model, "inheritance"))
+	Element dict_super
+	Integer i
+	Integer max
+	Element set_super
+	Element found_key
+	while (0 < read_nr_out(found_elements)):
 		// Now find the destination of these associations, which are the superclasses of this model
-		dict_gali_super = getAttributeList(model_gali, read_edge_dst(set_pop(found_elements_gali)))
-		set_gali_super = dict_keys(dict_gali_super)
+		dict_super = getAttributeList(model, read_edge_dst(set_pop(found_elements)))
+		set_super = dict_keys(dict_super)
 		// Merge the two
-		while (0 < read_nr_out(set_gali_super)):
-			found_key_gali = set_pop(set_gali_super)
-			dict_add(result_gali, found_key_gali, dict_read(dict_gali_super, found_key_gali))
+		while (0 < read_nr_out(set_super)):
+			found_key = set_pop(set_super)
+			dict_add(result, found_key, dict_read(dict_super, found_key))
 
-	return result_gali
+	return result
 
-Element function getInstantiatableAttributes(model_gili : Element, element_gili : Element):
-	Element result_gili
-	result_gili = create_node()
+Element function getInstantiatableAttributes(model : Element, element : Element):
+	Element result
+	result = create_node()
 	// Get all outgoing "dictionary" links
-	Element set_gili_own
-	set_gili_own = dict_keys(element_gili)
+	Element set_own
+	set_own = dict_keys(element)
 
 	// Filter them
-	Element e_gili
-	while (0 < read_nr_out(set_gili_own)):
-		e_gili = set_pop(set_gili_own)
-		if (bool_and(typeof(e_gili) == String, typeof(dict_read(element_gili, e_gili)) == Type)):
+	Element e
+	while (0 < read_nr_out(set_own)):
+		e = set_pop(set_own)
+		if (bool_and(typeof(e) == String, typeof(dict_read(element, e)) == Type)):
 			// This is a primitive type, so add to the list
-			dict_add(result_gili, e_gili, dict_read(element_gili, e_gili))
+			dict_add(result, e, dict_read(element, e))
 
-	return result_gili
+	return result
 
 String function getName(m : Element, e : Element):
 	Element element_keys
@@ -182,14 +182,14 @@ String function getName(m : Element, e : Element):
 
 	return string_join(string_join("(unknown: ", cast_e2s(e)), " )")
 
-String function reverseNameLookup(s_rnl : Element, e_rnl : Element):
-	Element element_keys_rnl
-	element_keys_rnl = dict_keys(s_rnl)
+String function reverseNameLookup(s : Element, e : Element):
+	Element element_keys
+	element_keys = dict_keys(s)
 
-	while (0 < read_nr_out(element_keys_rnl)):
-		Element key_rnl
-		key_rnl = set_pop(element_keys_rnl)
-		if (element_eq(dict_read_node(s_rnl, key_rnl), e_rnl)):
-			return key_rnl
+	while (0 < read_nr_out(element_keys)):
+		Element key
+		key = set_pop(element_keys)
+		if (element_eq(dict_read_node(s, key), e)):
+			return key
 
-	return string_join(string_join("(unknown: ", cast_e2s(e_rnl)), " )")
+	return string_join(string_join("(unknown: ", cast_e2s(e)), " )")