Browse Source

Merge branch 'testing' of msdl.uantwerpen.be:yentl/modelverse into testing

Yentl Van Tendeloo 8 years ago
parent
commit
cc85691ae4
4 changed files with 31 additions and 20 deletions
  1. 3 0
      bootstrap/modelling.alc
  2. 23 20
      bootstrap/transform.alc
  3. 4 0
      bootstrap/typing.alc
  4. 1 0
      interface/HUTN/includes/typing.alh

+ 3 - 0
bootstrap/modelling.alc

@@ -357,6 +357,7 @@ String function instantiate_link(model : Element, type : String, name : String,
 	return actual_name!
 
 Void function model_delete_element(model : Element, name : String):
+	remove_type(model, name)
 	delete_element(model["model"][name])
 	return!
 
@@ -414,6 +415,8 @@ Void function unset_attribute(model : Element, element : String, attribute : Str
 
 	while (set_len(attr_links) > 0):
 		attr_link = set_pop(attr_links)
+		remove_type(model, reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
+		remove_type(model, attr_link)
 		dict_delete(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
 		delete_element(model["model"][attr_link])
 

+ 23 - 20
bootstrap/transform.alc

@@ -172,28 +172,31 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		if (bool_not(set_in(bound, option))):
 			// Option is already present with another label, so skip this!
 
-			// Check if it conforms to the desired type
-			if (bool_not(guaranteed_instance)):
-				if (bool_not(is_nominal_instance(host_model, option, original_typename))):
-					// Not an actual instance, so skip!
-					continue!
-
-			// Check for local (matching) constraints of element
-			if (element_eq(read_attribute(schedule_model, current_element, "constraint"), read_root())):
-				// No local constraints, so all is well
-				set_add(filtered_options, option)
-			else:
-				// Check local constraints and add only if positive
-				Element constraint_function
-				Boolean result
-				Element func
-
-				constraint_function = read_attribute(schedule_model, current_element, "constraint")
-				func = get_func_AL_model(import_node(constraint_function))
-				result = func(host_model, option)
+			if (dict_in(host_model["model"], option)):
+				// Check if it conforms to the desired type
+				if (bool_not(guaranteed_instance)):
+					if (bool_not(is_nominal_instance(host_model, option, original_typename))):
+						// Not an actual instance, so skip!
+						continue!
 
-				if (result):
+				// Check for local (matching) constraints of element
+				if (element_eq(read_attribute(schedule_model, current_element, "constraint"), read_root())):
+					// No local constraints, so all is well
 					set_add(filtered_options, option)
+				else:
+					// Check local constraints and add only if positive
+					Element constraint_function
+					Boolean result
+					Element func
+
+					constraint_function = read_attribute(schedule_model, current_element, "constraint")
+					func = get_func_AL_model(import_node(constraint_function))
+					result = func(host_model, option)
+
+					if (result):
+						set_add(filtered_options, option)
+			else:
+				log("ERROR in found option: not in model")
 
 	Element attributes
 	String attribute

+ 4 - 0
bootstrap/typing.alc

@@ -38,3 +38,7 @@ Void function retype(model : Element, element : String, type : String):
 
 Element function new_type_mapping():
 	return dict_create()!
+
+Void function remove_type(model : Element, name : String):
+	dict_delete(model["type_mapping"], name)
+	return !

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

@@ -3,3 +3,4 @@ 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 remove_type(model : Element, name : String)