Browse Source

Fix MvC tests as well

Yentl Van Tendeloo 8 years ago
parent
commit
10e724e53b

BIN
bootstrap/bootstrap.m.gz


+ 1 - 0
bootstrap/modelling.alc

@@ -648,5 +648,6 @@ Element function get_func_AL_model(model_location : String):
 		initial_function = al_model["model"][set_pop(allAssociationDestinations(al_model, set_pop(initial_function), "initial_funcdef"))]
 		log("Found initial_function: " + cast_e2s(initial_function))
 		log("Keys: " + set_to_string(dict_keys(initial_function)))
+		log("Resolved " + model_location)
 
 	return initial_function!

+ 2 - 14
bootstrap/ramify.alc

@@ -50,7 +50,7 @@ Element function ramify(model : Element):
 	instantiate_node(new_model, "Class", "LHS_Root")
 	instantiate_attribute(new_model, "LHS_Root", "lower_cardinality", 1)
 	instantiate_attribute(new_model, "LHS_Root", "upper_cardinality", 1)
-	model_define_attribute(new_model, "LHS_Root", "LHS_constraint", True, "ActionLanguage")
+	model_define_attribute(new_model, "LHS_Root", "constraint", True, "ActionLanguage")
 
 	//  Class LHS : LHS_Root {}
 	instantiate_node(new_model, "Class", "LHS")
@@ -66,7 +66,7 @@ Element function ramify(model : Element):
 	//	}
 	instantiate_node(new_model, "Class", "PreElement")
 	model_define_attribute(new_model, "PreElement", "label", False, "String")
-	model_define_attribute(new_model, "PreElement", "matching_constraint", True, "ActionLanguage")
+	model_define_attribute(new_model, "PreElement", "constraint", True, "ActionLanguage")
 
 	// Association LHS_contains (LHS_Root, PreElement) {}
 	instantiate_link(new_model, "Association", "LHS_contains", "LHS_Root", "PreElement")
@@ -117,12 +117,9 @@ Element function ramify(model : Element):
 	set_add(copied_attributes, "source_upper_cardinality")
 	set_add(copied_attributes, "target_upper_cardinality")
 
-	log("Start RAM")
-	log("Set: " + list_to_string(keys))
 	while (read_nr_out(keys) > 0):
 		key = list_pop(keys, 0)
 		entry = old_m[key]
-		log("CHECK " + key)
 
 		type_name = read_type(model, key)
 		if (type_name == "Class"):
@@ -133,14 +130,10 @@ Element function ramify(model : Element):
 			instantiate_link(new_model, "Inheritance", "", "Pre_" + key, "PreElement")
 			instantiate_link(new_model, "Inheritance", "", "Post_" + key, "PostElement")
 
-			log("Added " + key)
-
 		elif (type_name == "AttributeLink"):
 			// Got an attribute, so find out the source and name
-			log("Attribute link!")
 			old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
 			attr_name = read_attribute(model, key, "name")
-			log("Search " + old_source)
 			log("Got " + set_to_string(dict_keys(new_model["model"])))
 
 			// TODO distinguish between Simple and Complex Attributes
@@ -174,9 +167,6 @@ Element function ramify(model : Element):
 			else:
 				// Queue for later
 				list_append(keys, key)
-				log("Wait for S " + old_source)
-				log("Wait for T " + old_target)
-				log("Got: " + set_to_string(dict_keys(new_model["model"])))
 				
 		elif (type_name == "Inheritance"):
 			old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
@@ -205,8 +195,6 @@ Element function ramify(model : Element):
 				else:
 					log("Masked attribute: " + attr_name)
 					log("  for " + old_source)
-		else:
-			log("DROP " + key)
 
 	// Define schedule over these elements
 

+ 33 - 4
bootstrap/transform.alc

@@ -72,23 +72,32 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 
 	typename = read_type(schedule_model, current_element)
 	original_typename = string_substr(typename, 4, string_len(typename))
+	
+	log("Getting possible bindings for " + current_element)
+	log("    type: " + typename)
 
 	if (is_edge(schedule_model["model"][current_element])):
+		log("    is_edge")
 		// Is an edge, so check for already bound source/target
 		src_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][current_element])), "label")
 		dst_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][current_element])), "label")
 
 		if (bool_and(set_in(dict_keys(map), src_label), set_in(dict_keys(map), dst_label))):
 			// Source and destination are bound
+			log("    SD bound")
 			options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
+			log("    Outgoing associations instances: " + set_to_string(options))
+			log("    Incoming associations instances: " + set_to_string(allIncomingAssociationInstances(host_model, map[dst_label], original_typename)))
 			options = set_overlap(options, allIncomingAssociationInstances(host_model, map[dst_label], original_typename))
 
 		elif (set_in(dict_keys(map), src_label)):
 			// Source is bound
+			log("    S bound")
 			options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
 
 		elif (set_in(dict_keys(map), dst_label)):
 			// Destination is bound
+			log("    D bound")
 			options = allIncomingAssociationInstances(host_model, map[dst_label], original_typename)
 
 		else:
@@ -97,37 +106,44 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 			//TODO should actually return all
 			return create_node()!
 	else:
+		log("    is_node")
 		// Is a node, so find whether or not there are some connections that are already resolved
 		Element ic
 		Element oc
 		String poll
 
-		ic = allIncomingAssociationInstances(schedule_model, current_element, "Pre_Element")
-		oc = allOutgoingAssociationInstances(schedule_model, current_element, "Pre_Element")
+		ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
+		oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
 
 		while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) == 0)):
 			poll = set_pop(ic)
+			log("    poll I " + poll)
 			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
 				set_add(options, readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")]))
 			
 		while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) == 0)):
 			poll = set_pop(oc)
+			log("    poll O " + poll)
 			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
 				set_add(options, readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")]))
 
 		if (read_nr_out(options) == 0):
 			// Is a node and no connections, so we just pick all options
+			log("    empty")
 			options = allInstances(host_model, original_typename)
 		elif (read_nr_out(options) > 1):
 			// Multiple "only" options, which will not work out: no options!
+			log("    multi!")
 			return create_node()!
 
 	// Filter options further
 	Element filtered_options
 	String option
 
+	log("    Got options: " + set_to_string(options))
+
 	filtered_options = create_node()
 	while (read_nr_out(options) > 0):
 		option = set_pop(options)
@@ -150,6 +166,9 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 				func = get_func_AL_model(constraint_function)
 				result = func(host_model, option)
 
+				log("Execute constraint on " + dict_to_string(option))
+				log("Result: " + cast_e2s(result))
+
 				if (result):
 					set_add(filtered_options, option)
 
@@ -229,14 +248,22 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 		mappings = new_mappings
 
 	// Finished, so try the global constraint
-	Element constraint
+	String constraint
+	Element func
+	Boolean result
 
 	new_mappings = create_node()
 	constraint = read_attribute(schedule_model, LHS, "constraint")
 	if (element_neq(constraint, read_root())):
 		while (read_nr_out(mappings) > 0):
 			map = set_pop(mappings)
-			if (constraint(host_model, map)):
+			func = get_func_AL_model(constraint)
+			result = func(host_model, map)
+
+			log("Execute global constraint on " + dict_to_string(map))
+			log("Result: " + cast_e2s(result))
+
+			if (result):
 				set_add(new_mappings, map)
 		mappings = new_mappings
 
@@ -382,6 +409,7 @@ Boolean function transform_composite(host_model : Element, schedule_model : Elem
 	while (is_nominal_instance(schedule_model, current, "Rule")):
 		// Still a rule that we must execute
 		typename = read_type(schedule_model, current)
+		log("RULE: " + current)
 		if (typename == "Atomic"):
 			result = transform_atomic(host_model, schedule_model, current)
 		elif (typename == "Query"):
@@ -435,6 +463,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	while (read_nr_out(mappings) > 0):
 		mapping = set_pop(mappings)
 		// TODO check if there are actually no deletions happening in the meantime of other matched elements...
+		log("Execute RHS for binding: " + dict_to_string(mapping))
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
 		rewrite(host_model, schedule_model, RHS, mapping)
 

+ 1 - 0
core/core_algorithm.alc

@@ -594,6 +594,7 @@ Void function user_function_skip_init(user_id : String):
 
 								// 3) Transform
 
+								log("EXECUTE TRANSFORMATION " + cast_e2s(read_attribute(core, transformation_id, "name")))
 								result = transform(merged_model, schedule_model)
 								output("Transformation executed with result: " + cast_v2s(result))
 

+ 1 - 0
integration/code/pn_simulate.mvc

@@ -38,6 +38,7 @@ RAM_PN_R s {
                         include "primitives.alh"
                         include "modelling.alh"
                         Void function action(host_model : Element, name : String, mapping : Element):
+                            log("MARK " + name)
                             unset_attribute(host_model, name, "executing")
                             instantiate_attribute(host_model, name, "executing", True)
                             return!