Jelajahi Sumber

updated attributelist so that inherited attributes are now found

tpinna 10 tahun lalu
induk
melakukan
0c6a04bc20
2 mengubah file dengan 22 tambahan dan 8 penghapusan
  1. 15 4
      bootstrap/object_operations.alc
  2. 7 4
      integration/code/pn_interface.alc

+ 15 - 4
bootstrap/object_operations.alc

@@ -85,13 +85,13 @@ Element function get_superclasses(model : Element, elem : Element):
 
 	return result
 
+
 Element function getAttributeList(model : Element, element : String):
 	Element result
 	Element keys
 	Element type
 	Element attr_name
 	String attr_type
-
 	result = create_node()
 	type = dict_read_node(model["type_mapping"], model["model"][element])
 	keys = dict_keys(type)
@@ -99,13 +99,24 @@ Element function getAttributeList(model : Element, element : String):
 	// Add our own attributes
 	while (0 < list_len(keys)):
 		attr_name = set_pop(keys)
-		//log("Test for " + cast_e2s(attr_name))
 		if (is_physical_string(attr_name)):
-			//log("Found attribute " + cast_v2s(attr_name))
-
 			attr_type = getName(model["metamodel"], type[attr_name])
 			dict_add(result, attr_name, attr_type)
 
+	Element superclasses
+	superclasses = get_superclasses(model["metamodel"], type)
+	while (0 < list_len(superclasses)):
+		type = set_pop(superclasses)
+		keys = dict_keys(type)
+		while (0 < list_len(keys)):
+			attr_name = set_pop(keys)
+			if (is_physical_string(attr_name)):
+				attr_type = getName(model["metamodel"], type[attr_name])
+				dict_add(result, attr_name, attr_type)
+		
+		
+		
+
 	// Go on to the metalevel
 	// TODO
 

+ 7 - 4
integration/code/pn_interface.alc

@@ -7,6 +7,7 @@ include "io.alh"
 include "metamodels.alh"
 include "modelling.alh"
 
+//helper function that returns the type of an attribute in string format
 Element function find_attribute_type_s(model : Element, elem : String, name : String):
 	Element mm_elem
 	Element direct_type
@@ -19,9 +20,10 @@ Element function find_attribute_type_s(model : Element, elem : String, name : St
 		log("Undefined attribute!")
 		return read_root()
 	else:
-		return getName(model["metamodel"], dict_read_edge(mm_elem, name))
+		return getName(model["metamodel"], read_edge_dst( dict_read_edge(mm_elem, name)))
 
-Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
+//function to print information about a node (attributes, type and name)
+Element function printNode(tf_pn_model: Element, tf_pn_node: Element):
 	//print header name
 	String tf_pn_node_name
 	tf_pn_node_name = getName(tf_pn_model, tf_pn_node)
@@ -47,6 +49,7 @@ Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
 			log(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))
 	return 0
 
+// given a pattern, this function will return all matches in a model
 Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
 	Element tf_ma_metamodelTransf
 	tf_ma_metamodelTransf = dict_read(dict_read(tf_ma_transformation, "metamodel"), "model")
@@ -57,8 +60,8 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
 	Element tf_ma_ramified_node
 	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_printNode(tf_ma_transformation, tf_ma_ramified_node)
-		Element tf_ma_attrlist
+		printNode(tf_ma_transformation, tf_ma_ramified_node)
+		log(read_attribute(tf_ma_transformation, getName(tf_ma_transformation, tf_ma_ramified_node), "plabel"))
 	return 0
 
 Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):