Explorar el Código

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

Yentl Van Tendeloo hace 8 años
padre
commit
5aca36e6b3
Se han modificado 3 ficheros con 59 adiciones y 4 borrados
  1. 4 0
      bootstrap/modelling.alc
  2. 3 3
      bootstrap/ramify.alc
  3. 52 1
      bootstrap/transform.alc

+ 4 - 0
bootstrap/modelling.alc

@@ -371,6 +371,10 @@ Element function read_attribute(model : Element, element : String, attribute : S
 					return read_edge_dst(edge)!
 			i = i + 1
 
+		log("Attribute not found!")
+	else:
+		log("Element does not exist!")
+
 	// Not found: either element doesn't exist, or we couldn't find it
 	return read_root()!
 

+ 3 - 3
bootstrap/ramify.alc

@@ -145,8 +145,8 @@ Element function ramify(model : Element):
 					// Add the attribute in the new model, altering its name and making it optional
 					log("Adding attribute " + attr_name)
 					log("  to " + old_source)
-					model_define_attribute(new_model, "Pre_" + old_source, attr_name + "_constraint", True, "ActionLanguage")
-					model_define_attribute(new_model, "Post_" + old_source, attr_name + "_value", True, "ActionLanguage")
+					model_define_attribute(new_model, "Pre_" + old_source, "constraint_" + attr_name, True, "ActionLanguage")
+					model_define_attribute(new_model, "Post_" + old_source, "value_" + attr_name, True, "ActionLanguage")
 				else:
 					log("Non-element origin for attribute link " + key)
 			else:
@@ -184,7 +184,7 @@ Element function ramify(model : Element):
 			// Primitive values themselves are not copied, so skip that here
 
 			attr_name = read_attribute(model, type_name, "name")
-			if (read_type(model["metamodel"], type_name) == "Attribute"):
+			if (is_nominal_instance(model["metamodel"], type_name, "Attribute")):
 				old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
 
 				if (set_in(copied_attributes, attr_name)):

+ 52 - 1
bootstrap/transform.alc

@@ -172,7 +172,58 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 				if (result):
 					set_add(filtered_options, option)
 
-	return filtered_options!
+	Element attributes
+	String attribute
+	Element value
+	Element func
+	Boolean result
+	Element attributes_copy
+
+	options = filtered_options
+	filtered_options = create_node()
+	log("Checking options: " + set_to_string(options))
+
+	// Check whether all attributes have a satisfied condition
+	attributes_copy = dict_keys(getAttributeList(schedule_model, current_element))
+	log("Defined attributes: " + set_to_string(attributes_copy))
+
+	while (read_nr_out(options) > 0):
+		option = set_pop(options)
+		attributes = set_copy(attributes_copy)
+		log(" opt: " + option)
+
+		result = True
+		while (read_nr_out(attributes) > 0):
+			attribute = set_pop(attributes)
+			if (bool_not(string_startswith(attribute, "constraint_"))):
+				continue!
+
+			log("Check attribute: " + attribute)
+			value = read_attribute(schedule_model, current_element, attribute)
+			// Attribute might be undefined, so skip if it is
+			if (element_neq(value, read_root())):
+				log("Read value: " + cast_e2s(value))
+				func = get_func_AL_model(value)
+				log("Func: " + cast_e2s(func))
+				log("EXEC")
+				result = func(host_model, option, attribute)
+				log("Got result of constraint eval: " + cast_v2s(result))
+			else:
+				log("Attribute unconstrained, so add always")
+				result = True
+
+			if (bool_not(result)):
+				break!
+
+		// Check value of last result, which will be True if all passed, or False otherwise
+		if (result):
+			log("Adding")
+			set_add(filtered_options, option)
+		else:
+			log("Dropping")
+
+	options = filtered_options
+	return options!
 
 Element function full_match(host_model : Element, schedule_model : Element, current : String):
 	Element NACs