Browse Source

Fixed reading attributes

Yentl Van Tendeloo 8 years ago
parent
commit
e03dfe6fc7
4 changed files with 30 additions and 12 deletions
  1. BIN
      bootstrap/bootstrap.m.gz
  2. 4 0
      bootstrap/modelling.alc
  3. 2 2
      bootstrap/ramify.alc
  4. 24 10
      bootstrap/transform.alc

BIN
bootstrap/bootstrap.m.gz


+ 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()!
 

+ 2 - 2
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:

+ 24 - 10
bootstrap/transform.alc

@@ -192,21 +192,35 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		attributes = set_copy(attributes_copy)
 		log(" opt: " + option)
 
+		result = True
 		while (read_nr_out(attributes) > 0):
 			attribute = set_pop(attributes)
-			log("Check attribute: " + attribute)
+			if (bool_not(string_startswith(attribute, "constraint_"))):
+				continue!
 
+			log("Check attribute: " + attribute)
 			value = read_attribute(schedule_model, current_element, attribute)
-			func = get_func_AL_model(value)
-			log("EXEC")
-			result = func(host_model, option, attribute)
-			log("Got result of constraint eval: " + cast_v2s(result))
-
-			if (result):
-				log("Adding")
-				set_add(filtered_options, option)
+			// 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("Dropping")
+				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!