Browse Source

Fixed pn_print_exec

Yentl Van Tendeloo 8 years ago
parent
commit
a394937684
4 changed files with 32 additions and 8 deletions
  1. 3 0
      bootstrap/modelling.alc
  2. 3 2
      bootstrap/ramify.alc
  3. 24 4
      bootstrap/transform.alc
  4. 2 2
      integration/code/pn_print.mvc

+ 3 - 0
bootstrap/modelling.alc

@@ -606,6 +606,9 @@ Element function construct_model_raw(metamodel : Element):
 		elif (command == "instantiate_attribute_ref"):
 			input()
 			instantiate_attribute_ref(model, input(), input(), input())
+		elif (command == "instantiate_attribute_code"):
+			input()
+			instantiate_attribute_code(model, input(), input(), construct_function())
 		elif (command == "instantiate_link"):
 			input()
 			instantiate_link(model, input(), input(), input(), input())

+ 3 - 2
bootstrap/ramify.alc

@@ -3,6 +3,7 @@ include "object_operations.alh"
 include "modelling.alh"
 include "metamodels.alh"
 include "model_management.alh"
+include "conformance_scd.alh"
 
 Element function ramify(model : Element):
 	// Create new model structure
@@ -146,7 +147,7 @@ Element function ramify(model : Element):
 
 			if (dict_in(new_model["model"], "Pre_" + old_source)):
 				// Only if it is a class that it originates from is a class, should we add this
-				if (read_type(model, old_source) == "Class"):
+				if (is_nominal_instance(model, old_source, "Element")):
 					// If the attribute is one used in the conformance check, we should mask it
 					// Add the attribute in the new model, altering its name and making it optional
 					log("Adding attribute " + attr_name)
@@ -154,7 +155,7 @@ Element function ramify(model : Element):
 					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")
 				else:
-					log("Non-class origin for attribute link " + key)
+					log("Non-element origin for attribute link " + key)
 			else:
 				// Queue for later
 				list_append(keys, key)

+ 24 - 4
bootstrap/transform.alc

@@ -143,9 +143,16 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 			else:
 				// Check local constraints and add only if positive
 				Element constraint_function
-				constraint_function = read_attribute(schedule_model, current_element, "constraint")
 				Boolean result
-				result = constraint_function(host_model, option)
+				Element params
+
+				constraint_function = read_attribute(schedule_model, current_element, "constraint")
+				params = create_node()
+				dict_add(params, "model", host_model)
+				dict_add(params, "option", option)
+				log("Invoking constraint in match!")
+				result = execute_AL_model(constraint_function, params)
+				log("Result of constraint: " + cast_e2s(result))
 				if (result):
 					set_add(filtered_options, option)
 
@@ -323,7 +330,14 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 		label = set_pop(original_RHS_labels)
 		action = read_attribute(schedule_model, RHS_map[label], "action")
 		if (element_neq(action, read_root())):
-			action(host_model, new_mapping[label], mapping)
+			Element params
+			params = create_node()
+			dict_add(params, "model", host_model)
+			dict_add(params, "name", new_mapping[label])
+			dict_add(params, "mapping", mapping)
+			log("Execute RHS Action")
+			execute_AL_model(action, params)
+			log("Finished!")
 
 	while (read_nr_out(labels_to_remove) > 0):
 		// Remove the elements linked to these labels
@@ -334,7 +348,13 @@ Void function rewrite(host_model : Element, schedule_model : Element, RHS : Stri
 	// Execute global action (whatever it may be)
 	action = read_attribute(schedule_model, RHS, "action")
 	if (element_neq(action, read_root())):
-		action(host_model, new_mapping)
+		Element params
+		params = create_node()
+		dict_add(params, "model", host_model)
+		dict_add(params, "mapping", new_mapping)
+		log("Execute global RHS Action")
+		execute_AL_model(action, params)
+		log("Finished!")
 
 	return!
 

+ 2 - 2
integration/code/pn_print.mvc

@@ -15,8 +15,8 @@ RAM_PN_R print {
                     action = $
                         include "primitives.alh"
                         include "modelling.alh"
-                        Void function action(host_model : Element, name : String, mapping : Element):
-                            output((cast_v2s(read_attribute(host_model, name, "name")) + " --> ") + cast_v2s(read_attribute(host_model, name, "tokens")))
+                        Void function action(params : Element):
+                            output((cast_v2s(read_attribute(params["model"], params["name"], "name")) + " --> ") + cast_v2s(read_attribute(params["model"], params["name"], "tokens")))
                             return!
                         $
                 }