Просмотр исходного кода

adapted code so that multiple nacs are allowed

tpinna 10 лет назад
Родитель
Сommit
4c19930e20
1 измененных файлов с 9 добавлено и 6 удалено
  1. 9 6
      integration/code/pn_interface.alc

+ 9 - 6
integration/code/pn_interface.alc

@@ -371,7 +371,7 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
 	//TODO support for multiple ruleTypes
 	
 	//find LHS
-	//TODO if no lhs
+	//TODO if no lhs (is this allowed to happen?)
 	Element tf_er_lhs
 	tf_er_lhs = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
 	tf_er_lhs = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
@@ -385,14 +385,17 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
 	Element tf_er_nac
 	tf_er_nac = create_node()
 	if(nr_of_lhs_matches > 0): //TODO unless there is no lhs, then we might have situations were we just want to prevent nodes from spawning
-		tf_er_nac = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "nac"))
-		//TODO make this a loop
-		tf_er_nac = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_nac)), tf_er_model)
+		Element tf_er_nac_
+		tf_er_nac_ = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "nac"))
+		Element partial_nac_matches
+		while (read_nr_out(tf_er_nac_) > 0):
+			partial_nac_matches = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_nac_)), tf_er_model)
+			while (read_nr_out(partial_nac_matches)>0):
+				list_append(tf_er_nac, set_pop(partial_nac_matches))
 		nr_of_nac_matches = list_len(tf_er_nac)
 		//log(string_join(cast_i2s(list_len(tf_er_nac)), " matches found"))
 		
 	//remove from lhs matches that share a node with a nac match
-	//TODO join lhs and nacs to conclusive amount of matches
 	Element final_matches
 	final_matches = create_node()
 	Element lhs_match
@@ -426,7 +429,7 @@ Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Elemen
 	//create a list of all rules	
 	Element tf_tf_rules
 	tf_tf_rules = allInstances(tf_tf_transformation, dict_read(dict_read(dict_read(tf_tf_transformation, "metamodel"), "model"), "Rule"))
-	//TODO give order to syntax
+	//TODO give order to rules
 	//execute rules in random order 
 	Element tf_tf_rule
 	while (integer_lt(0, read_nr_out(tf_tf_rules))):