Переглянути джерело

fixed broken conformance test by reinstating old semantincs of find_attribute_type and creating new function that returns the type in a string format

tpinna 10 роки тому
батько
коміт
2c03cc76dd
2 змінених файлів з 25 додано та 17 видалено
  1. 1 1
      bootstrap/modelling.alc
  2. 24 16
      integration/code/pn_interface.alc

+ 1 - 1
bootstrap/modelling.alc

@@ -102,7 +102,7 @@ Element function find_attribute_type(model : Element, elem : String, name : Stri
 		log("Undefined attribute!")
 		log("Undefined attribute!")
 		return read_root()
 		return read_root()
 	else:
 	else:
-		return getName(model["metamodel"], read_edge_dst(dict_read_edge(mm_elem, name)))
+		return getName(model["metamodel"], dict_read_edge(mm_elem, name))
 
 
 Element function get_superclasses(model : Element, elem : Element):
 Element function get_superclasses(model : Element, elem : Element):
 	Element result
 	Element result

+ 24 - 16
integration/code/pn_interface.alc

@@ -7,6 +7,20 @@ include "io.alh"
 include "metamodels.alh"
 include "metamodels.alh"
 include "modelling.alh"
 include "modelling.alh"
 
 
+Element function find_attribute_type_s(model : Element, elem : String, name : String):
+	Element mm_elem
+	Element direct_type
+
+	direct_type = dict_read_node(model["type_mapping"], model["model"][elem])
+	mm_elem = find_attribute_definer(model["metamodel"], direct_type, name)
+
+	if (element_eq(mm_elem, read_root())):
+		// Couldn't find element, so is not allowed!
+		log("Undefined attribute!")
+		return read_root()
+	else:
+		return getName(model["metamodel"], dict_read_edge(mm_elem, name))
+
 Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
 Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
 	//print header name
 	//print header name
 	String tf_pn_node_name
 	String tf_pn_node_name
@@ -14,7 +28,7 @@ Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
 	log(string_join("name: ",tf_pn_node_name) )
 	log(string_join("name: ",tf_pn_node_name) )
 	log(string_join("type: ", getName(tf_pn_model["metamodel"], dict_read_node(tf_pn_model["type_mapping"], tf_pn_node)) ))
 	log(string_join("type: ", getName(tf_pn_model["metamodel"], dict_read_node(tf_pn_model["type_mapping"], tf_pn_node)) ))
 	//log(getName(tf_pn_model["metamodel"], dict_read_node(tf_pn_model["type_mapping"], tf_pn_node)))
 	//log(getName(tf_pn_model["metamodel"], dict_read_node(tf_pn_model["type_mapping"], tf_pn_node)))
-	log("ATTRIBUTELIST:")
+	log("attributes:")
 	//get the list of attributes
 	//get the list of attributes
 	Element tf_pn_attributelist
 	Element tf_pn_attributelist
 	tf_pn_attributelist = dict_keys(getAttributeList(tf_pn_model, tf_pn_node_name))
 	tf_pn_attributelist = dict_keys(getAttributeList(tf_pn_model, tf_pn_node_name))
@@ -23,21 +37,18 @@ Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
 	while (integer_lt(0, read_nr_out(tf_pn_attributelist))):
 	while (integer_lt(0, read_nr_out(tf_pn_attributelist))):
 		//print attribute name and its value
 		//print attribute name and its value
 		tf_pn_attributename = set_pop(tf_pn_attributelist)
 		tf_pn_attributename = set_pop(tf_pn_attributelist)
-		tf_pn_attributetype = find_attribute_type(tf_pn_model, tf_pn_node_name, tf_pn_attributename)
+		tf_pn_attributetype = find_attribute_type_s(tf_pn_model, tf_pn_node_name, tf_pn_attributename)
 		if( tf_pn_attributetype == "String"):
 		if( tf_pn_attributetype == "String"):
-			log(string_join(string_join(tf_pn_attributename, " : "),read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename)))
+			log(string_join(string_join(string_join(" ",tf_pn_attributename), " : "),read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename)))
 		elif (tf_pn_attributetype == "Integer"):
 		elif (tf_pn_attributetype == "Integer"):
-			log(string_join(string_join(tf_pn_attributename, " : "),cast_i2s(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))))
+			log(string_join(string_join(string_join(" ",tf_pn_attributename), " : "),cast_i2s(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))))
 		else:
 		else:
 			log(string_join(tf_pn_attributename, " : "))
 			log(string_join(tf_pn_attributename, " : "))
 			log(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))
 			log(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))
 	return 0
 	return 0
 
 
-//namespace is tf_ma_
 Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
 Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
-	//log("executing: tf_matchAll()")
 	Element tf_ma_metamodelTransf
 	Element tf_ma_metamodelTransf
-	//log(tf_ma_pattern)
 	tf_ma_metamodelTransf = dict_read(dict_read(tf_ma_transformation, "metamodel"), "model")
 	tf_ma_metamodelTransf = dict_read(dict_read(tf_ma_transformation, "metamodel"), "model")
 	Element tf_ma_pattern_nodes
 	Element tf_ma_pattern_nodes
 	tf_ma_pattern_nodes = create_node()
 	tf_ma_pattern_nodes = create_node()
@@ -46,30 +57,27 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
 	Element tf_ma_ramified_node
 	Element tf_ma_ramified_node
 	while (integer_lt(0, read_nr_out(tf_ma_pattern_nodes))):
 	while (integer_lt(0, read_nr_out(tf_ma_pattern_nodes))):
 		tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_nodes))
 		tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_nodes))
-		//plabel not found		
-		//log(readAttribute(tf_ma_transformation,tf_ma_ramified_node, "plabel"))
+		//tf_printNode(tf_ma_transformation, tf_ma_ramified_node)
 		Element tf_ma_attrlist
 		Element tf_ma_attrlist
 	return 0
 	return 0
 
 
-//namespace tf_er_
 Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
 Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
-	//log("find matches based on lhs")
 	Element tf_er_lhs
 	Element tf_er_lhs
+	// get the lhs of the rule
 	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 = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
+	// find the matches of the rule
 	tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
 	tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
 	return 0
 	return 0
 
 
-//namespace tf_tf_
 Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
 Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
-	//log("getting rule")
 	//create a list of all rules	
 	//create a list of all rules	
 	Element tf_tf_rules
 	Element tf_tf_rules
-	tf_tf_rules = allInstances(tf_tf_transformation, dict_read(dict_read(dict_read(tf_tf_transformation, "metamodel"), "model"), "Rule"))	//print rules
-	//log("execute rule")
+	tf_tf_rules = allInstances(tf_tf_transformation, dict_read(dict_read(dict_read(tf_tf_transformation, "metamodel"), "model"), "Rule"))
+	//execute rules in random order 
 	Element tf_tf_rule
 	Element tf_tf_rule
 	while (integer_lt(0, read_nr_out(tf_tf_rules))):
 	while (integer_lt(0, read_nr_out(tf_tf_rules))):
 		tf_tf_rule = set_pop(tf_tf_rules)
 		tf_tf_rule = set_pop(tf_tf_rules)
-		tf_printNode(tf_tf_transformation, tf_tf_rule)
+		//tf_printNode(tf_tf_transformation, tf_tf_rule)
 		tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
 		tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
 	return 0
 	return 0