Pārlūkot izejas kodu

Rename most read_nr_out to the more specific version: set_len, list_len, or dict_len

Yentl Van Tendeloo 8 gadi atpakaļ
vecāks
revīzija
faac1abb01

+ 4 - 4
bootstrap/conformance_scd.alc

@@ -245,7 +245,7 @@ String function conformance_scd(model : Element):
 	mm_model = metamodel["model"]
 
 	metamodel_keys = dict_keys(mm_model)
-	while (read_nr_out(metamodel_keys) > 0):
+	while (set_len(metamodel_keys) > 0):
 		metamodel_element = set_pop(metamodel_keys)
 
 		// Lower multiplicities
@@ -269,11 +269,11 @@ String function conformance_scd(model : Element):
 	String complex_type
 	String result
 	all_complex_types = allInstances(model["metamodel"]["metamodel"], "ComplexAttribute")
-	while (read_nr_out(all_complex_types) > 0):
+	while (set_len(all_complex_types) > 0):
 		complex_type = set_pop(all_complex_types)
 		complex_instances = allInstances(model, complex_type)
 
-		while (read_nr_out(complex_instances) > 0):
+		while (set_len(complex_instances) > 0):
 			complex_instance = set_pop(complex_instances)
 
 			complex_type = read_attribute(model["metamodel"], read_type(model, complex_instance), "type")
@@ -288,7 +288,7 @@ String function conformance_scd(model : Element):
 	Element func
 
 	global_constraints = allInstances(model, "GlobalConstraint")
-	while (read_nr_out(global_constraints) > 0):
+	while (set_len(global_constraints) > 0):
 		constraint = set_pop(global_constraints)
 		func = get_func_AL_model(import_node(read_attribute(model, constraint, "global_constraint")))
 		result = func(model)

+ 55 - 61
bootstrap/core_algorithm.alc

@@ -30,9 +30,9 @@ String function get_instanceOf_link(model_id : String, metamodel_id : String):
 
 	all_links = set_overlap(allOutgoingAssociationInstances(core, model_id, "instanceOf"), allIncomingAssociationInstances(core, metamodel_id, "instanceOf"))
 
-	if (read_nr_out(all_links) > 1):
+	if (set_len(all_links) > 1):
 		log("WARNING: multiple instanceOf relations were detected for this model; picking one at random!")
-	elif (read_nr_out(all_links) == 0):
+	elif (set_len(all_links) == 0):
 		log("ERROR: untyped model; crashing")
 		log("Instance model: " + cast_v2s(read_attribute(core, model_id, "name")))
 		log("Type model: " + cast_v2s(read_attribute(core, metamodel_id, "name")))
@@ -124,7 +124,7 @@ Boolean function allow_group_modify(user_id : String, group_id : String):
 		// Is admin, so always allow
 		return True!
 	else:
-		if (read_nr_out(set_overlap(allIncomingAssociationInstances(core, user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))) > 0):
+		if (set_len(set_overlap(allIncomingAssociationInstances(core, user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))) > 0):
 			// We are an owner
 			return True!
 		else:
@@ -187,7 +187,7 @@ String function get_model_id(name : String):
 	String model
 
 	models = allInstances(core, "Model")
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		model = set_pop(models)
 		if (value_eq(name, read_attribute(core, model, "name"))):
 			return model!
@@ -201,7 +201,7 @@ String function get_service_id(name : String):
 	services = allInstances(core, "Service")
 
 	log("Search " + name)
-	while (read_nr_out(services) > 0):
+	while (set_len(services) > 0):
 		service = set_pop(services)
 		log("Check " + cast_v2s(read_attribute(core, service, "name")))
 		if (value_eq(read_attribute(core, service, "name"), name)):
@@ -216,7 +216,7 @@ String function get_user_id(name : String):
 
 	users = allInstances(core, "User")
 
-	while (read_nr_out(users) > 0):
+	while (set_len(users) > 0):
 		user = set_pop(users)
 		if (value_eq(read_attribute(core, user, "name"), name)):
 			return user!
@@ -228,7 +228,7 @@ String function get_group_id(name : String):
 	String group
 
 	groups = allInstances(core, "Group")
-	while (read_nr_out(groups) > 0):
+	while (set_len(groups) > 0):
 		group = set_pop(groups)
 		if (value_eq(read_attribute(core, group, "name"), name)):
 			return group!
@@ -303,7 +303,7 @@ Boolean function pm_finished(worklist : Element, pm : String):
 	// If so, we can already finish, and therefore will stop immediately
 	finished = allInstances(pm, "Finish")
 	i = 0
-	cnt = read_nr_out(finished)
+	cnt = set_len(finished)
 
 	while (i < cnt):
 		// Check each finished element individually
@@ -347,13 +347,13 @@ Element function execute_operation(operation_id : String, input_models : Element
 	String edge
 	input_metamodels = dict_create()
 	iter = allOutgoingAssociationInstances(core, operation_id, "transformInput")
-	while (read_nr_out(iter) > 0):
+	while (set_len(iter) > 0):
 		edge = set_pop(iter)
 		dict_add(input_metamodels, read_attribute(core, edge, "name"), read_attribute(core, readAssociationDestination(core, edge), "name"))
 
 	output_metamodels = dict_create()
 	iter = allOutgoingAssociationInstances(core, operation_id, "transformOutput")
-	while (read_nr_out(iter) > 0):
+	while (set_len(iter) > 0):
 		edge = set_pop(iter)
 		dict_add(output_metamodels, read_attribute(core, edge, "name"), read_attribute(core, readAssociationDestination(core, edge), "name"))
 
@@ -362,7 +362,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 	exact_type = read_type(core, operation_id)
 	trace_links = allOutgoingAssociationInstances(core, operation_id, "tracability")
 	merged_metamodel_id = ""
-	while (read_nr_out(trace_links) > 0):
+	while (set_len(trace_links) > 0):
 		trace_link_id = set_pop(trace_links)
 		if (value_eq(read_attribute(core, trace_link_id, "type"), "operatesOn")):
 			merged_metamodel_id = readAssociationDestination(core, trace_link_id)
@@ -372,16 +372,16 @@ Element function execute_operation(operation_id : String, input_models : Element
 	if (merged_metamodel_id != ""):
 		model_tuples = set_create()
 		keys = dict_keys(input_models)
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			set_add(model_tuples, create_tuple(key, get_full_model(get_model_id(input_models[key]), get_model_id(input_metamodels[key]))))
 
 		merged_model = model_join(model_tuples, get_full_model(merged_metamodel_id, get_model_id("SimpleClassDiagrams")), tracability_model)
 	else:
-		if (bool_and(read_nr_out(input_models) == 1, read_nr_out(output_models) == 0)):
+		if (bool_and(dict_len(input_models) == 1, dict_len(output_models) == 0)):
 			// Just skip the merge...
-			merged_model = model_copy(get_full_model(get_model_id(set_read(input_models)), get_model_id(set_read(input_metamodels))))
-		elif (bool_and(read_nr_out(input_models) == 0, read_nr_out(output_models) == 0)):
+			merged_model = model_copy(get_full_model(get_model_id(input_models[set_pop(dict_keys(input_models))]), get_model_id(input_metamodels[set_pop(dict_keys(input_metamodels))])))
+		elif (bool_and(dict_len(input_models) == 0, dict_len(output_models) == 0)):
 			merged_model = read_root()
 		else:
 			log("Could not resolve intermediate merged metamodel")
@@ -393,7 +393,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 	if (exact_type == "ModelTransformation"):
 		trace_links = allOutgoingAssociationInstances(core, merged_metamodel_id, "tracability")
 		ramified_metamodel_id = ""
-		while (read_nr_out(trace_links) > 0):
+		while (set_len(trace_links) > 0):
 			trace_link_id = set_pop(trace_links)
 			if (value_eq(read_attribute(core, trace_link_id, "type"), "RAMified")):
 				ramified_metamodel_id = readAssociationDestination(core, trace_link_id)
@@ -422,18 +422,12 @@ Element function execute_operation(operation_id : String, input_models : Element
 	if (result):
 		model_tuples = set_create()
 		keys = dict_keys(output_models)
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			set_add(model_tuples, create_tuple(key, get_full_model(get_model_id(output_models[key]), get_model_id(output_metamodels[key]))))
 
 		result = model_split(merged_model, model_tuples, tracability)
 
-		//log("Output models:")
-		//keys = dict_keys(result)
-		//while (read_nr_out(keys) > 0):
-		//	key = set_pop(keys)
-		//	log((cast_v2s(key) + " --> ") + cast_v2s(read_nr_out(result[key]["model"])))
-
 		if (tracability):
 			Element new_tracability_model
 			new_tracability_model = result["__tracability"]
@@ -477,14 +471,14 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 
 	// Find all input model names
 	lst = allOutgoingAssociationInstances(pm, element, "Consumes")
-	while (read_nr_out(lst) > 0):
+	while (set_len(lst) > 0):
 		consume = set_pop(lst)
 		value = read_attribute(pm, readAssociationDestination(pm, consume), "name")
 		dict_add(inputs, read_attribute(pm, consume, "name"), prefix + value)
 
 	// Find all output model names and their metamodel
 	lst = allOutgoingAssociationInstances(pm, element, "Produces")
-	while (read_nr_out(lst) > 0):
+	while (set_len(lst) > 0):
 		produce = set_pop(lst)
 		elem = readAssociationDestination(pm, produce)
 		type_name = read_attribute(pm, elem, "type")
@@ -509,7 +503,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 		return False!
 	else:
 		keys = dict_keys(result)
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			if (get_model_id(output_map[key]) == ""):
 				// New model
@@ -533,7 +527,7 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 	// Initialize Join counters
 	counters = dict_create()
 	join_nodes = allInstances(pm, "Join")
-	while (read_nr_out(join_nodes) > 0):
+	while (set_len(join_nodes) > 0):
 		dict_add(counters, set_pop(join_nodes), 0)
 
 	// Create the worklist with the Start instance as first element
@@ -567,7 +561,7 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 			// Now check whether we have enough tokens to execute the Join itself
 			Integer required
 			Integer got
-			required = read_nr_out(allIncomingAssociationInstances(pm, element, "Next")) + read_nr_out(allIncomingAssociationInstances(pm, element, "Else"))
+			required = set_len(allIncomingAssociationInstances(pm, element, "Next")) + set_len(allIncomingAssociationInstances(pm, element, "Else"))
 			got = counters[element]
 			if (got == required):
 				// Reset counter to 0
@@ -600,7 +594,7 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 		Element all_next
 		all_next = allAssociationDestinations(pm, element, "Next")
 		String next
-		while (read_nr_out(all_next) > 0):
+		while (set_len(all_next) > 0):
 			next = set_pop(all_next)
 			set_add(worklist, create_tuple(next, result))
 
@@ -720,7 +714,7 @@ String function cmd_transformation_between(user_id : String, source_name : Strin
 
 			String r
 			r = "Success: "
-			while (read_nr_out(result) > 0):
+			while (set_len(result) > 0):
 				transformation = set_pop(result)
 				if (allow_read(user_id, transformation)):
 					r = r + string_join(read_attribute(core, transformation, "name"), "\n")
@@ -764,7 +758,7 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 					// Fetch the output types
 					output_map = dict_create()
 					out_links = allOutgoingAssociationInstances(core, mapper_ID, "transformOutput")
-					while(read_nr_out(out_links) > 0):
+					while(set_len(out_links) > 0):
 						link = set_pop(out_links)
 						dict_add(output_map, read_attribute(core, link, "name"), read_attribute(core, readAssociationDestination(core, link), "name"))
 
@@ -832,7 +826,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 				inputs = dict_create()
 
 				sources = allOutgoingAssociationInstances(core, transformation_id, "transformInput")
-				while (read_nr_out(sources) > 0):
+				while (set_len(sources) > 0):
 					source = set_pop(sources)
 					assoc_name = read_attribute(core, source, "name")
 					if (dict_in(source_models, assoc_name)):
@@ -860,7 +854,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 				targets = allOutgoingAssociationInstances(core, transformation_id, "transformOutput")
 				outputs = dict_create()
 				output_map = dict_create()
-				while (read_nr_out(targets) > 0):
+				while (set_len(targets) > 0):
 					target = set_pop(targets)
 					assoc_name = read_attribute(core, target, "name")
 					if (dict_in(target_models, assoc_name)):
@@ -896,7 +890,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 					return "Failure"!
 				else:
 					keys = dict_keys(result)
-					while (read_nr_out(keys) > 0):
+					while (set_len(keys) > 0):
 						key = set_pop(keys)
 						
 						if (get_model_id(outputs[key]) == ""):
@@ -1014,7 +1008,7 @@ String function cmd_model_list():
 
 	result = "Success: "
 	models = allInstances(core, "Model")
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		m = set_pop(models)
 		result = (result + string_join((string_join("  ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name"))) + "\n"
 	return result!
@@ -1032,7 +1026,7 @@ String function cmd_model_list_full():
 
 	result = "Success: "
 	models = allInstances(core, "Model")
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		m = set_pop(models)
 		permissions = read_attribute(core, m, "permissions")
 		owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
@@ -1071,7 +1065,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 	formalism_map = set_create()
 
 	keys = dict_keys(source_models)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		name = source_models[key]
 		model_id = get_model_id(name)
@@ -1090,7 +1084,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			return "Model not found: " + name!
 
 	keys = dict_keys(target_models)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		name = target_models[key]
 		model_id = get_model_id(name)
@@ -1111,7 +1105,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 	if (get_model_id(operation_name) == ""):
 		// Write out a merged metamodel containing all these models: this is the MM for the manual operation
 		// New location is available, so write
-		if (bool_not(bool_and(read_nr_out(source_models) == 0, read_nr_out(target_models) == 0))):
+		if (bool_not(bool_and(dict_len(source_models) == 0, dict_len(target_models) == 0))):
 			merged_formalism = model_fuse(set_copy(formalism_map))
 			modify(merged_formalism, True)
 
@@ -1127,12 +1121,12 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			model_create(import_node("AL/" + operation_name), operation_name, user_id, get_model_id("ActionLanguage"), "ActionLanguage")
 			model_id = get_model_id(operation_name)
 
-		if (bool_not(bool_and(read_nr_out(source_models) == 0, read_nr_out(target_models) == 0))):
+		if (bool_not(bool_and(dict_len(source_models) == 0, dict_len(target_models) == 0))):
 			model_create(merged_formalism, "__merged_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
 			merged_formalism_id = get_model_id("__merged_" + operation_name)
 
 			// Add tracability links at this level
-			while (read_nr_out(all_formalisms) > 0):
+			while (set_len(all_formalisms) > 0):
 				source_formalism_id = set_pop(all_formalisms)
 				tracability_link = instantiate_link(core, "tracability", "", merged_formalism_id, source_formalism_id)
 				instantiate_attribute(core, tracability_link, "type", "merged")
@@ -1145,13 +1139,13 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			String dst
 
 			keys = dict_keys(source)
-			while (read_nr_out(keys) > 0):
+			while (set_len(keys) > 0):
 				key = set_pop(keys)
 				link = instantiate_link(core, "transformInput", "", model_id, source[key])
 				instantiate_attribute(core, link, "name", key)
 
 			keys = dict_keys(target)
-			while (read_nr_out(keys) > 0):
+			while (set_len(keys) > 0):
 				key = set_pop(keys)
 				link = instantiate_link(core, "transformOutput", "", model_id, target[key])
 				instantiate_attribute(core, link, "name", key)
@@ -1190,14 +1184,14 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 	to_ramify = set_create()
 
 	keys = dict_keys(source_models)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		name = source_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
 			if (allow_read(user_id, name)):
 				// Check whether or not it is SimpleClassDiagrams
-				if (read_nr_out(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
+				if (set_len(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
 					if (bool_not(dict_in(source, key))):
 						dict_add(source, key, model_id)
 						set_add(to_ramify, create_tuple(key, get_full_model(model_id, get_model_id("SimpleClassDiagrams"))))
@@ -1211,13 +1205,13 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 			return "Model not found: " + name!
 
 	keys = dict_keys(target_models)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		name = target_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
 			if (allow_read(user_id, name)):
-				if (read_nr_out(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
+				if (set_len(get_instanceOf_links(model_id, get_model_id("SimpleClassDiagrams"))) > 0):
 					if (bool_not(dict_in(target, key))):
 						if (dict_in(source, key)):
 							if (value_eq(model_id, source[key])):
@@ -1271,14 +1265,14 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		String dst
 
 		keys = dict_keys(source)
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			dst = source[key]
 			link = instantiate_link(core, "transformInput", "", model_id, dst)
 			instantiate_attribute(core, link, "name", key)
 
 		keys = dict_keys(target)
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			dst = target[key]
 			link = instantiate_link(core, "transformOutput", "", model_id, dst)
@@ -1297,7 +1291,7 @@ String function cmd_transformation_list():
 
 	result = "Success: "
 	models = allInstances(core, "Transformation")
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		m = set_pop(models)
 		result = result + ((string_join(("[" + read_type(core, m)) + "]", string_join((string_join(" ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")))) + "\n")
 
@@ -1316,7 +1310,7 @@ String function cmd_transformation_list_full():
 
 	result = ""
 	models = allInstances(core, "Transformation")
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		m = set_pop(models)
 		permissions = read_attribute(core, m, "permissions")
 		owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
@@ -1438,12 +1432,12 @@ String function cmd_group_owner_add(user_id : String, group_name : String, other
 				Element overlap
 
 				overlap = set_overlap(allIncomingAssociationInstances(core, other_user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))
-				if (read_nr_out(overlap) == 0):
+				if (set_len(overlap) == 0):
 					instantiate_link(core, "owner", "", group_id, other_user_id)
 
 					overlap = set_overlap(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
 
-					if (read_nr_out(overlap) == 0):
+					if (set_len(overlap) == 0):
 						instantiate_link(core, "belongsTo", "", other_user_id, group_id)
 
 					return "Success"!
@@ -1469,9 +1463,9 @@ String function cmd_group_owner_delete(user_id : String, group_name : String, ot
 				Element overlap
 
 				overlap = set_overlap(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
-				if (read_nr_out(overlap) > 0):
+				if (set_len(overlap) > 0):
 					overlap = set_overlap(allIncomingAssociationInstances(core, other_user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))
-					if (read_nr_out(overlap) > 0):
+					if (set_len(overlap) > 0):
 						model_delete_element(core, set_pop(overlap))
 						return "Success"!
 					else:
@@ -1498,7 +1492,7 @@ String function cmd_group_join(user_id : String, group_name : String, other_user
 				Element overlap
 				overlap = set_overlap(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
 
-				if (read_nr_out(overlap) == 0):
+				if (set_len(overlap) == 0):
 					instantiate_link(core, "belongsTo", "", other_user_id, group_id)
 					return "Success"!
 				else:
@@ -1523,12 +1517,12 @@ String function cmd_group_kick(user_id : String, group_name : String, other_user
 				Element overlap
 				overlap = set_overlap(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
 
-				if (read_nr_out(overlap) > 0):
+				if (set_len(overlap) > 0):
 					model_delete_element(core, set_pop(overlap))
 
 					// Check if user was an owner as well
 					overlap = set_overlap(allIncomingAssociationInstances(core, other_user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))
-					if (read_nr_out(overlap) > 0):
+					if (set_len(overlap) > 0):
 						model_delete_element(core, set_pop(overlap))
 
 					return "Success"!
@@ -1550,7 +1544,7 @@ String function cmd_group_list(user_id : String):
 	
 	result = ""
 	groups = allAssociationDestinations(core, user_id, "belongsTo")
-	while (read_nr_out(groups) > 0):
+	while (set_len(groups) > 0):
 		group_id = set_pop(groups)
 		if (set_in(allOutgoingAssociationInstances(core, group_id, "owner"), user_id)):
 			admin = " A "
@@ -1637,12 +1631,12 @@ String function cmd_transformation_signature(user_id : String, transformation_na
 
 				result = "Success: "
 				inputs = allOutgoingAssociationInstances(core, model_id, "transformInput")
-				while (read_nr_out(inputs) > 0):
+				while (set_len(inputs) > 0):
 					elem = set_pop(inputs)
 					result = string_join(string_join(string_join(string_join("I ", read_attribute(core, elem, "name")), " "), read_attribute(core, readAssociationDestination(core, elem), "name")), "\n")
 
 				outputs = allOutgoingAssociationInstances(core, model_id, "transformOutput")
-				while (read_nr_out(outputs) > 0):
+				while (set_len(outputs) > 0):
 					elem = set_pop(outputs)
 					result = string_join(string_join(string_join(string_join("O ", read_attribute(core, elem, "name")), " "), read_attribute(core, readAssociationDestination(core, elem), "name")), "\n")
 

+ 11 - 11
bootstrap/mini_modify.alc

@@ -21,7 +21,7 @@ String function pretty_print(model : Element):
 	result = ""
 	keys_m = dict_keys(model["model"])
 
-	while (read_nr_out(keys_m) > 0):
+	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
 		type = read_type(model["metamodel"], read_type(model, v_m))
 
@@ -35,7 +35,7 @@ String function pretty_print(model : Element):
 			// Defines attributes
 			attr_list = getInstantiatableAttributes(model, v_m)
 			attr_keys = dict_keys(attr_list)
-			while (0 < read_nr_out(attr_keys)):
+			while (set_len(attr_keys) > 0):
 				attr_key = set_pop(attr_keys)
 				result = result + (((("      " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
 				result = result + "\n"
@@ -43,7 +43,7 @@ String function pretty_print(model : Element):
 			// Has attributes
 			attr_list = getAttributeList(model, v_m)
 			attr_keys = dict_keys(attr_list)
-			while (0 < read_nr_out(attr_keys)):
+			while (set_len(attr_keys) > 0):
 				attr_key = set_pop(attr_keys)
 				if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
 					result = result + (((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
@@ -193,7 +193,7 @@ String function cmd_list(model : Element):
 
 	result = "Success: "
 	keys_m = dict_keys(model["model"])
-	while (read_nr_out(keys_m) > 0):
+	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
 		// Filter out anonymous objects
 		if (bool_not(string_startswith(v_m, "__"))):
@@ -210,7 +210,7 @@ String function cmd_list_full(model : Element):
 
 	result = "Success: "
 	keys_m = dict_keys(model["model"])
-	while (read_nr_out(keys_m) > 0):
+	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
 		// Filter out anonymous objects
 		typename = read_type(model, v_m)
@@ -225,7 +225,7 @@ String function cmd_read_outgoing(model : Element, element_name : String, type :
 	if (dict_in(model["model"], element_name)):
 		result = "Success: "
 		elems = allOutgoingAssociationInstances(model, element_name, type)
-		while (read_nr_out(elems) > 0):
+		while (set_len(elems) > 0):
 			result = string_join(result, set_pop(elems)) + "\n"
 		return result!
 	else:
@@ -238,7 +238,7 @@ String function cmd_read_incoming(model : Element, element_name : String, type :
 	if (dict_in(model["model"], element_name)):
 		result = "Success: "
 		elems = allIncomingAssociationInstances(model, element_name, type)
-		while (read_nr_out(elems) > 0):
+		while (set_len(elems) > 0):
 			result = string_join(result, set_pop(elems)) + "\n"
 		return result!
 	else:
@@ -252,7 +252,7 @@ String function cmd_connections_between(model : Element, source_name : String, t
 		if (dict_in(model["model"], target_name)):
 			result = "Success: "
 			options = allowedAssociationsBetween(model, source_name, target_name)
-			while (read_nr_out(options) > 0):
+			while (set_len(options) > 0):
 				result = string_join(result, set_pop(options)) + "\n"
 		else:
 			return ("Element not found: " + target_name)!
@@ -277,13 +277,13 @@ String function cmd_read(model : Element, element_name : String):
 		result = result + "Defines attributes:\n"
 		attr_list = getInstantiatableAttributes(model, element_name)
 		attr_keys = dict_keys(attr_list)
-		while (0 < read_nr_out(attr_keys)):
+		while (0 < set_len(attr_keys)):
 			attr_key = set_pop(attr_keys)
 			result = ((((result + "  ") + attr_key) + " : ") + cast_v2s(attr_list[attr_key])) + "\n"
 		result = result + "Attributes:\n"
 		attr_list = getAttributeList(model, element_name)
 		attr_keys = dict_keys(attr_list)
-		while (0 < read_nr_out(attr_keys)):
+		while (0 < set_len(attr_keys)):
 			attr_key = set_pop(attr_keys)
 			result = ((((((result + "  ") + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, element_name, attr_key))) + "\n"
 		return result!
@@ -297,7 +297,7 @@ String function cmd_types(model : Element):
 
 	keys_t = dict_keys(model["metamodel"]["model"])
 	result = "Success: "
-	while (read_nr_out(keys_t) > 0):
+	while (set_len(keys_t) > 0):
 		v_t = set_pop(keys_t)
 		if (bool_not(string_startswith(v_t, "__"))):
 			result = (result + string_join(("  " + v_t) + " : ", read_type(model["metamodel"], v_t))) + "\n"

+ 18 - 19
bootstrap/model_management.alc

@@ -19,16 +19,15 @@ Element function model_fuse(models : Element):
 	Element reverse
 
 	// Read out some data first
-	if (read_nr_out(models) == 0):
+	if (set_len(models) == 0):
 		log("Cannot fuse empty set of models!")
 		return read_root()!
 
-	tagged_model = set_pop(models)
-	set_add(models, tagged_model)
+	tagged_model = set_read(models)
 	new_model = instantiate_model(tagged_model[1]["metamodel"])
 
 	// Do the iteration
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		tagged_model = set_pop(models)
 		model_name = string_join(list_read(tagged_model, 0), "/")
 		model = list_read(tagged_model, 1)
@@ -39,7 +38,7 @@ Element function model_fuse(models : Element):
 		keys = dict_keys(model["model"])
 		second_keys = set_create()
 
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			type = read_type(model, key)
 
@@ -57,7 +56,7 @@ Element function model_fuse(models : Element):
 			else:
 				instantiate_node(new_model, type, model_name + key)
 
-			if (read_nr_out(keys) == 0):
+			if (set_len(keys) == 0):
 				keys = second_keys
 				second_keys = set_create()
 
@@ -77,7 +76,7 @@ Element function model_copy(src_model : Element):
 	keys = dict_keys(src_model["model"])
 	second_keys = set_create()
 
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		name = set_pop(keys)
 
 		if (is_edge(src_model["model"][name])):
@@ -106,7 +105,7 @@ Element function model_copy(src_model : Element):
 			type = read_type(src_model, name)
 			instantiate_node(dst_model, type, name)
 
-		if (read_nr_out(keys) == 0):
+		if (set_len(keys) == 0):
 			keys = second_keys
 			second_keys = set_create()
 
@@ -121,7 +120,7 @@ Element function model_retype_on_name(model : Element, new_MM : Element, operati
 	keys = dict_keys(model["model"])
 	length = string_len(name)
 
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		if (dict_in(model["model"], key)):
 			// Check if the element is still there, as a delete of a node might remove all attached links automatically
@@ -162,7 +161,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 	elem_map = dict_create()
 
 	// Do the iteration
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		tagged_model = set_pop(models)
 		retyping_key = string_join(list_read(tagged_model, 0), "/")
 		model = list_read(tagged_model, 1)
@@ -171,7 +170,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 		keys = dict_keys(model["model"])
 		second_keys = set_create()
 
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			// Copy the new element
 			key = set_pop(keys)
 			type = read_type(model, key)
@@ -195,7 +194,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 				// Add the new name to a map which registers the mapping to the new name
 				dict_add_fast(elem_map, cast_id2s(model["model"][key]), new_name)
 
-			if (read_nr_out(keys) == 0):
+			if (set_len(keys) == 0):
 				keys = second_keys
 				second_keys = set_create()
 
@@ -210,7 +209,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 
 		tracability_links = allInstances(tracability_model, "TracabilityLink")
 
-		while (read_nr_out(tracability_links) > 0):
+		while (set_len(tracability_links) > 0):
 			tracability_link = set_pop(tracability_links)
 
 			// Get necessary information from the tracability link
@@ -229,7 +228,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
 	return new_model!
 	
 Element function model_split(merged_model : Element, models : Element, tracability : Boolean):
-	if (read_nr_out(models) == 0):
+	if (set_len(models) == 0):
 		// No results needed, so stop immediately unless tracability is True
 		if (bool_not(tracability)):
 			return dict_create()!
@@ -263,14 +262,14 @@ Element function model_split(merged_model : Element, models : Element, tracabili
 	mapping = dict_create()
 	second_keys = set_create()
 
-	while (read_nr_out(models) > 0):
+	while (set_len(models) > 0):
 		model_tuple = set_pop(models)
 		retyping_key = model_tuple[0]
 		metamodel = model_tuple[1]
 		dict_add_fast(result, retyping_key, instantiate_model(metamodel))
 
 	keys = dict_keys(merged_model["model"])
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		elem = merged_model["model"][key]
 		type = read_type(merged_model, key)
@@ -309,7 +308,7 @@ Element function model_split(merged_model : Element, models : Element, tracabili
 						set_add(second_keys, key)
 		else:
 			retyping_key = splitted[0]
-			if (read_nr_out(string_split(key, "/")) > 1):
+			if (list_len(string_split(key, "/")) > 1):
 				new_name = list_read(string_split(key, "/"), 1)
 			else:
 				new_name = key
@@ -342,13 +341,13 @@ Element function model_split(merged_model : Element, models : Element, tracabili
 					// Is a node
 					dict_add_fast(mapping, key, instantiate_node(result[retyping_key], original_type, new_name))
 
-		if (read_nr_out(keys) == 0):
+		if (set_len(keys) == 0):
 			keys = second_keys
 			second_keys = set_create()
 
 	// Finally, we also add tracability information as a separate model
 	if (tracability):
 		dict_add_fast(result, "__tracability", tracability_model)
-		log("Tracability model created with # links = " + cast_v2s(read_nr_out(tracability_model["model"])))
+		log("Tracability model created with # links = " + cast_v2s(dict_len(tracability_model["model"])))
 
 	return result!

+ 4 - 4
bootstrap/modelling.alc

@@ -335,9 +335,9 @@ String function instantiate_link(model : Element, type : String, name : String,
 
 		options = allowedAssociationsBetween(model, source, destination)
 
-		if (read_nr_out(options) == 1):
+		if (set_len(options) == 1):
 			type = set_pop(options)
-		elif (read_nr_out(options) == 0):
+		elif (set_len(options) == 0):
 			log("ERROR: cannot find possible link between entries")
 			log("    for " + source)
 			log("    to " + destination)
@@ -597,10 +597,10 @@ Element function get_func_AL_model(al_model : Element):
 	// Find the initial function
 	initial_function = allInstances(al_model, "Initial")
 
-	if (read_nr_out(initial_function) == 0):
+	if (set_len(initial_function) == 0):
 		log("Could not find function to execute in this model!")
 		return read_root()!
-	elif (read_nr_out(initial_function) > 1):
+	elif (set_len(initial_function) > 1):
 		log("Too many functions to execute in this model!")
 		return read_root()!
 	else:

+ 7 - 7
bootstrap/object_operations.alc

@@ -16,7 +16,7 @@ Element function allInstances(model : Element, type_name : String):
 		result = set_create()
 		accepted = get_subclasses(model["metamodel"], type_name)
 
-		while (read_nr_out(accepted) > 0):
+		while (set_len(accepted) > 0):
 			class = set_pop(accepted)
 			results = reverseKeyLookupMulti(model["type_mapping"], class)
 			set_merge(result, results)
@@ -116,12 +116,12 @@ Element function getAttributeList(model : Element, element : String):
 	mm = model["metamodel"]["model"]
 	types = get_superclasses(model["metamodel"], read_type(model, element))
 
-	while (read_nr_out(types) > 0):
+	while (set_len(types) > 0):
 		type = set_pop(types)
 
 		// Add our own attributes
 		keys = dict_keys(mm[type])
-		while (read_nr_out(keys) > 0):
+		while (set_len(keys) > 0):
 			attr_name = set_pop(keys)
 			if (is_physical_string(attr_name)):
 				attr_type = reverseKeyLookup(mm, mm[type][attr_name])
@@ -138,7 +138,7 @@ Element function getInstantiatableAttributes(model : Element, element : String):
 	result = dict_create()
 
 	all_links = allOutgoingAssociationInstances(model, element, "Attribute")
-	while (read_nr_out(all_links) > 0):
+	while (set_len(all_links) > 0):
 		link = set_pop(all_links)
 		// WARNING: do not change this to dict_add_fast, as this crashes random code...
 		dict_add(result, read_attribute(model, link, "name"), read_type(model, readAssociationDestination(model, link)))
@@ -211,7 +211,7 @@ Element function allAssociationDestinations(model : Element, name : String, asso
 	result = set_create()
 	tmp = allOutgoingAssociationInstances(model, name, association_type)
 
-	while (read_nr_out(tmp) > 0):
+	while (set_len(tmp) > 0):
 		set_add(result, readAssociationDestination(model, set_pop(tmp)))
 
 	return result!
@@ -223,7 +223,7 @@ Element function allAssociationOrigins(model : Element, name : String, associati
 	result = set_create()
 	tmp = allIncomingAssociationInstances(model, name, association_type)
 
-	while (read_nr_out(tmp) > 0):
+	while (set_len(tmp) > 0):
 		set_add(result, readAssociationSource(model, set_pop(tmp)))
 
 	return result!
@@ -243,7 +243,7 @@ Element function allowedAssociationsBetween(model : Element, src : String, dst :
 	type = read_type(model, src)
 	all_types = get_superclasses(model["metamodel"], type)
 
-	while (read_nr_out(all_types) > 0):
+	while (set_len(all_types) > 0):
 		type = set_pop(all_types)
 		nr_edges = read_nr_out(model["metamodel"]["model"][type])
 		i = 0

+ 8 - 13
bootstrap/ramify.alc

@@ -105,9 +105,7 @@ Element function ramify(model : Element):
 	String attr_name
 	Element masked_attributes
 	Element copied_attributes
-
-	Integer i
-	Integer cnt
+	Element local_copied_attributes
 
 	masked_attributes = set_create()
 	set_add(masked_attributes, "constraint")
@@ -120,7 +118,7 @@ Element function ramify(model : Element):
 	set_add(copied_attributes, "source_upper_cardinality")
 	set_add(copied_attributes, "target_upper_cardinality")
 
-	while (read_nr_out(keys) > 0):
+	while (list_len(keys) > 0):
 		key = list_pop(keys, 0)
 		entry = old_m[key]
 
@@ -134,14 +132,13 @@ Element function ramify(model : Element):
 			instantiate_link(new_model, "Inheritance", "", "Post_" + key, "PostElement")
 
 			i = 0
-			cnt = read_nr_out(copied_attributes)
-			while (i < cnt):
-				attr_name = read_edge_dst(read_out(copied_attributes, i))
+			local_copied_attributes = set_copy(copied_attributes)
+			while (set_len(local_copied_attributes) > 0):
+				attr_name = set_pop(copied_attributes)
 				if (element_neq(read_attribute(model, key, attr_name), read_root())):
 					// Attribute was defined, so reassign in both LHS and RHS
 					instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
 					instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
-				i = i + 1
 
 		elif (type_name == "AttributeLink"):
 			// Got an attribute, so find out the source and name
@@ -176,15 +173,13 @@ Element function ramify(model : Element):
 				// Queue for later
 				list_append(keys, key)
 				
-			i = 0
-			cnt = read_nr_out(copied_attributes)
-			while (i < cnt):
-				attr_name = read_edge_dst(read_out(copied_attributes, i))
+			local_copied_attributes = set_copy(copied_attributes)
+			while (set_len(local_copied_attributes) > 0):
+				attr_name = set_pop(local_copied_attributes)
 				if (element_neq(read_attribute(model, key, attr_name), read_root())):
 					// Attribute was defined, so reassign in both LHS and RHS
 					instantiate_attribute(new_model, "Pre_" + key, attr_name, read_attribute(model, key, attr_name))
 					instantiate_attribute(new_model, "Post_" + key, attr_name, read_attribute(model, key, attr_name))
-				i = i + 1
 
 		elif (type_name == "Inheritance"):
 			old_source = reverseKeyLookup(model["model"], read_edge_src(entry))

+ 1 - 1
bootstrap/random.alc

@@ -29,4 +29,4 @@ Element function random_choice(list : Element):
 	if (list_len(list) == 0):
 		return read_root()!
 	else:
-		return read_edge_dst(read_out(list, random_interval(0, read_nr_out(list) - 1)))!
+		return read_edge_dst(read_out(list, random_interval(0, list_len(list) - 1)))!

+ 12 - 13
bootstrap/semi_primitives.alc

@@ -187,7 +187,7 @@ String function set_to_string(s : Element):
 
 	result = "{"
 	s = set_copy(s)
-	while (i < read_nr_out(s)):
+	while (i < set_len(s)):
 		result = (result + cast_v2s(set_pop(s))) + ", "
 	
 	result = result + "}"
@@ -200,8 +200,8 @@ String function list_to_string(s : Element):
 
 	result = "["
 	i = 0
-	while (i < read_nr_out(s)):
-		result = result + cast_v2s(dict_read(s, i))
+	while (i < list_len(s)):
+		result = result + cast_v2s(list_read(s, i))
 		result = result + ", "
 		i = i + 1
 	
@@ -226,7 +226,7 @@ String function dict_to_string(d : Element):
 	result = "{"
 
 	keys = dict_keys(d)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 
 		result = result + cast_v2s(key)
@@ -241,7 +241,7 @@ String function dict_to_string(d : Element):
 Element function set_overlap(sa : Element, sb : Element):
 	Element result
 
-	if (read_nr_out(sa) > read_nr_out(sb)):
+	if (set_len(sa) > set_len(sb)):
 		// Pick the smallest set to iterate over, so switch if sa is not the smallest
 		result = sa
 		sa = sb
@@ -251,17 +251,16 @@ Element function set_overlap(sa : Element, sb : Element):
 	sa = set_copy(sa)
 
 	// Iterate over each element of sa and only add it to the result if it is also in sb
-	while (i < read_nr_out(sa)):
+	while (set_len(sa) > 0):
 		elem = set_pop(sa)
 		if (set_in(sb, elem)):
 			// Shared between both
 			set_add(result, elem)
-		i = i + 1
 
 	return result!
 
 Boolean function set_equality(sa : Element, sb : Element):
-	if (read_nr_out(sa) != read_nr_out(sb)):
+	if (set_len(sa) != set_len(sb)):
 		return False!
 
 	sa = set_copy(sa)
@@ -278,7 +277,7 @@ Boolean function dict_eq(da : Element, db : Element):
 	Element keys
 	Element key
 	keys = dict_keys(da)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		if (value_neq(da[key], db[key])):
 			// Value that is not equal
@@ -294,7 +293,7 @@ Element function dict_copy(d : Element):
 	result = dict_create()
 
 	keys = dict_keys(d)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		dict_add_fast(result, key, dict_read_node(d, key))
 
@@ -306,7 +305,7 @@ Element function set_to_list(s : Element):
 
 	result = list_create()
 	tmp = set_copy(s)
-	while (read_nr_out(tmp) > 0):
+	while (set_len(tmp) > 0):
 		list_append(result, set_pop(tmp))
 
 	return result!
@@ -322,7 +321,7 @@ Void function dict_overwrite(d : Element, key : Element, value : Element):
 
 Void function set_merge(a : Element, b : Element):
 	b = set_copy(b)
-	while (read_nr_out(b) > 0):
+	while (set_len(b) > 0):
 		set_add(a, set_pop(b))
 	return!
 
@@ -334,7 +333,7 @@ Element function make_reverse_dictionary(dict : Element):
 
 	reverse = dict_create()
 	keys = dict_keys(dict)
-	while (read_nr_out(keys) > 0):
+	while (set_len(keys) > 0):
 		key = set_pop(keys)
 		value = cast_id2s(dict[key])
 		if (dict_in(reverse, value)):

+ 39 - 43
bootstrap/transform.alc

@@ -25,10 +25,10 @@ Element function make_matching_schedule(schedule_model : Element, LHS : String,
 	workset = set_create()
 	all_elements = allAssociationDestinations(schedule_model, LHS, "LHS_contains")
 	full_all_elements = set_copy(all_elements)
-	required_size = read_nr_out(all_elements)
+	required_size = set_len(all_elements)
 
 	// Need to keep adding to the schedule
-	while (read_nr_out(schedule) < required_size):
+	while (list_len(schedule) < required_size):
 
 		// workset is empty, but we still need to add to the list
 		// Therefore, we pick a random, unbound node, and add it to the workset
@@ -39,7 +39,7 @@ Element function make_matching_schedule(schedule_model : Element, LHS : String,
 		set_add(workset, new_element)
 
 		// Handle the workset
-		while (read_nr_out(workset) > 0):
+		while (set_len(workset) > 0):
 			// Still elements in the workset, so pop from these first
 			next = set_pop(workset)
 
@@ -102,7 +102,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		if (bool_and(src_in, dst_in)):
 			// Source and destination are bound
 			options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
-			if (read_nr_out(options) > 0):
+			if (set_len(options) > 0):
 				options = set_overlap(options, allIncomingAssociationInstances(host_model, map[dst_label], original_typename))
 
 		elif (src_in):
@@ -124,7 +124,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		String value
 
 		oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
-		while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) < 2)):
+		while (bool_and(set_len(oc) > 0, set_len(options) < 2)):
 			poll = set_pop(oc)
 			if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
 				// This incoming link is already defined, so we just have one option: the destination of the link we matched
@@ -132,10 +132,10 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 				if (bool_not(set_in(options, value))):
 					set_add(options, value)
 
-		if (read_nr_out(options) < 2):
+		if (set_len(options) < 2):
 			ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
 			String value
-			while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) < 2)):
+			while (bool_and(set_len(ic) > 0, set_len(options) < 2)):
 				poll = set_pop(ic)
 				if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
 					// This incoming link is already defined, so we just have one option: the destination of the link we matched
@@ -143,12 +143,12 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 					if (bool_not(set_in(options, value))):
 						set_add(options, value)
 			
-		if (read_nr_out(options) == 0):
+		if (set_len(options) == 0):
 			// Is a node and no connections, so we just pick all options
 			options = allInstances(host_model, original_typename)
 			guaranteed_instance = True
 
-		elif (read_nr_out(options) > 1):
+		elif (set_len(options) > 1):
 			// Multiple "only" options, which will not work out: no options!
 			return set_create()!
 
@@ -157,7 +157,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 	String option
 
 	filtered_options = set_create()
-	while (read_nr_out(options) > 0):
+	while (set_len(options) > 0):
 		option = set_pop(options)
 
 		// Check for detecting same element twice
@@ -200,12 +200,12 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 	// Check whether all attributes have a satisfied condition
 	attributes_copy = dict_keys(getAttributeList(schedule_model, current_element))
 
-	while (read_nr_out(options) > 0):
+	while (set_len(options) > 0):
 		option = set_pop(options)
 		attributes = set_copy(attributes_copy)
 
 		result = True
-		while (read_nr_out(attributes) > 0):
+		while (set_len(attributes) > 0):
 			attribute = set_pop(attributes)
 			if (bool_not(string_startswith(attribute, "constraint_"))):
 				continue!
@@ -234,7 +234,6 @@ Element function full_match(host_model : Element, schedule_model : Element, curr
 	String NAC
 	Element mappings
 	Element mapping
-	Integer i
 	Element result
 	Element final_mappings
 	Boolean allowed
@@ -249,18 +248,16 @@ Element function full_match(host_model : Element, schedule_model : Element, curr
 	NACs = allAssociationDestinations(schedule_model, current, "NACLink")
 
 	// For each possible mapping, we check all NACs!
-	while (read_nr_out(mappings) > 0):
+	while (set_len(mappings) > 0):
 		mapping = set_pop(mappings)
-		i = 0
 		allowed = True
-		while (i < read_nr_out(NACs)):
-			NAC = read_edge_dst(read_out(NACs, i))
+		while (set_len(NACs) > 0):
+			NAC = set_pop(NACs)
 			result = match(host_model, schedule_model, NAC, mapping)
-			if (read_nr_out(result) > 0):
+			if (set_len(result) > 0):
 				// NAC could be matched, and therefore is not allowed
 				allowed = False
 				break!
-			i = i + 1
 		
 		if (allowed):
 			set_add(final_mappings, mapping)
@@ -286,27 +283,27 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	String option
 	Element options
 
-	mappings = dict_create()
+	mappings = set_create()
 	set_add(mappings, initial_mapping)
-	while (read_nr_out(schedule) > 0):
-		current_element = list_pop(schedule, read_nr_out(schedule) - 1)
+	while (list_len(schedule) > 0):
+		current_element = list_pop(schedule, list_len(schedule) - 1)
 		//log("Binding element with label " + cast_v2s(read_attribute(schedule_model, current_element, "label")))
 		new_mappings = dict_create()
 
-		while (read_nr_out(mappings) > 0):
+		while (set_len(mappings) > 0):
 			map = set_pop(mappings)
 			options = get_possible_bindings(host_model, schedule_model, current_element, map)
 
-			while (read_nr_out(options) > 0):
+			while (set_len(options) > 0):
 				option = set_pop(options)
 				new_map = dict_copy(map)
 				dict_add_fast(new_map, read_attribute(schedule_model, current_element, "label"), option)
 				set_add(new_mappings, new_map)
 
 		mappings = new_mappings
-		//log("Remaining options: " + cast_v2s(read_nr_out(mappings)))
+		//log("Remaining options: " + cast_v2s(set_len(mappings)))
 
-		if (read_nr_out(mappings) == 0):
+		if (set_len(mappings) == 0):
 			// Stop because we have no more options remaining!
 			return set_create()!
 
@@ -318,7 +315,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	new_mappings = dict_create()
 	constraint = read_attribute(schedule_model, LHS, "constraint")
 	if (element_neq(constraint, read_root())):
-		while (read_nr_out(mappings) > 0):
+		while (set_len(mappings) > 0):
 			map = set_pop(mappings)
 			func = get_func_AL_model(import_node(constraint))
 			result = func(host_model, map)
@@ -359,7 +356,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	RHS_map = dict_create()
 
 	RHS_elements = allAssociationDestinations(schedule_model, RHS, "RHS_contains")
-	while (read_nr_out(RHS_elements) > 0):
+	while (set_len(RHS_elements) > 0):
 		tmp = set_pop(RHS_elements)
 		label = read_attribute(schedule_model, tmp, "label")
 		set_add(RHS_labels, label)
@@ -367,7 +364,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 
 	remaining = set_overlap(LHS_labels, RHS_labels)
 	original_RHS_labels = set_copy(RHS_labels)
-	while (read_nr_out(remaining) > 0):
+	while (set_len(remaining) > 0):
 		elem = set_pop(remaining)
 		set_remove(LHS_labels, elem)
 		set_remove(RHS_labels, elem)
@@ -377,9 +374,9 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 
 	new_mapping = dict_copy(mapping)
 
-	while (read_nr_out(labels_to_add) > 0):
+	while (list_len(labels_to_add) > 0):
 		// Add the elements linked to these labels
-		label = list_pop(labels_to_add, read_nr_out(labels_to_add) - 1)
+		label = list_pop(labels_to_add, list_len(labels_to_add) - 1)
 		if (is_edge(schedule_model["model"][RHS_map[label]])):
 			// Edge
 			src = read_attribute(schedule_model, reverse[cast_id2s(read_edge_src(schedule_model["model"][RHS_map[label]]))], "label")
@@ -408,13 +405,13 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	Element result
 	Element func
 
-	while (read_nr_out(original_RHS_labels) > 0):
+	while (set_len(original_RHS_labels) > 0):
 		// Perform actions
 		label = set_pop(original_RHS_labels)
 
 		// Do all attribute actions that are defined
 		attributes = dict_keys(getAttributeList(schedule_model, RHS_map[label]))
-		while (read_nr_out(attributes) > 0):
+		while (set_len(attributes) > 0):
 			attribute = set_pop(attributes)
 			if (bool_not(string_startswith(attribute, "value_"))):
 				continue!
@@ -438,7 +435,7 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 			func = get_func_AL_model(import_node(action))
 			func(host_model, new_mapping[label], mapping)
 
-	while (read_nr_out(labels_to_remove) > 0):
+	while (set_len(labels_to_remove) > 0):
 		// Remove the elements linked to these labels
 		label = set_pop(labels_to_remove)
 		model_delete_element(host_model, mapping[label])
@@ -463,14 +460,14 @@ Element function transform(host_model : Element, schedule_model : Element):
 
 	// Now start transforming for real
 	all_composites = allInstances(schedule_model, "Composite")
-	if (read_nr_out(all_composites) == 1):
+	if (set_len(all_composites) == 1):
 		// Only one, so it is easy
 		current = set_pop(all_composites)
 	else:
 		// Filter out those that are themselves contained
-		while (read_nr_out(all_composites) > 0):
+		while (set_len(all_composites) > 0):
 			composite = set_pop(all_composites)
-			if (read_nr_out(allIncomingAssociationInstances(schedule_model, composite, "Contains")) == 0):
+			if (set_len(allIncomingAssociationInstances(schedule_model, composite, "Contains")) == 0):
 				// Isn't contained in any, so this is the root model!
 				current = composite
 
@@ -516,7 +513,7 @@ Boolean function transform_atomic(host_model : Element, schedule_model : Element
 	Element mapping
 	mappings = full_match(host_model, schedule_model, current, True)
 
-	if (read_nr_out(mappings) > 0):
+	if (set_len(mappings) > 0):
 		// Pick one!
 		mapping = random_choice(set_to_list(mappings))
 		String RHS
@@ -535,15 +532,14 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 
 	mappings = full_match(host_model, schedule_model, current, False)
 
-	if (read_nr_out(mappings) > 0):
+	if (set_len(mappings) > 0):
 		result = True
 	else:
 		result = False
 
-	//log("Matches in forall: " + cast_v2s(read_nr_out(mappings)))
-	while (read_nr_out(mappings) > 0):
+	//log("Matches in forall: " + cast_v2s(set_len(mappings)))
+	while (set_len(mappings) > 0):
 		mapping = set_pop(mappings)
-		// TODO check if there are actually no deletions happening in the meantime of other matched elements...
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
 		rewrite(host_model, schedule_model, RHS, mapping)
 
@@ -555,7 +551,7 @@ Boolean function transform_query(host_model : Element, schedule_model : Element,
 	Element mapping
 	mappings = full_match(host_model, schedule_model, current, True)
 
-	if (read_nr_out(mappings) > 0):
+	if (set_len(mappings) > 0):
 		return True!
 	else:
 		return False!

+ 3 - 3
bootstrap/utils.alc

@@ -17,7 +17,7 @@ String function JSON_print(model : Element):
 	keys_m = dict_keys(model["model"])
 	first = True
 
-	while (read_nr_out(keys_m) > 0):
+	while (set_len(keys_m) > 0):
 		v_m = set_pop(keys_m)
 		type = read_type(model["metamodel"], read_type(model, v_m))
 
@@ -36,7 +36,7 @@ String function JSON_print(model : Element):
 
 			// Has attributes
 			attr_keys = dict_keys(getAttributeList(model, v_m))
-			while (0 < read_nr_out(attr_keys)):
+			while (0 < set_len(attr_keys)):
 				attr_key = set_pop(attr_keys)
 				attr_value = read_attribute(model, v_m, attr_key)
 				if (element_eq(attr_value, read_root())):
@@ -91,7 +91,7 @@ Void function list_extend(lst : Element, ext : Element):
 Void function set_difference(set1 : Element, set2 : Element):
 	set2 = set_copy(set2)
 
-	while (read_nr_out(set2) > 0):
+	while (set_len(set2) > 0):
 		set_remove(set1, set_pop(set2))
 
 	return!