|
|
@@ -115,9 +115,6 @@ Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
|
return 2 //incoming
|
|
|
else:
|
|
|
return 0 //the edge is not connected
|
|
|
- else:
|
|
|
- log("is_connected_to: unsupported type for second element")
|
|
|
- log(string_join("type = ", el2_mmt))
|
|
|
else:
|
|
|
if( element_eq(read_edge_src(el1) , el2)):
|
|
|
return 2 //incoming
|
|
|
@@ -143,10 +140,9 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
OldCurMatchKeys = dict_keys(OldSearchState["curmatch"])
|
|
|
Element new_curmatch //the new curmatch
|
|
|
new_curmatch = create_node()
|
|
|
- Element oldkey // loop variable
|
|
|
while (integer_lt(0, list_len(OldCurMatchKeys))): //copying the old curmatch
|
|
|
- oldkey = set_pop(OldCurMatchKeys)
|
|
|
- dict_add(new_curmatch, oldkey, OldSearchState["curmatch"][oldkey]) //WARNING dict_read_node needed???
|
|
|
+ index = set_pop(OldCurMatchKeys)
|
|
|
+ dict_add(new_curmatch, index, OldSearchState["curmatch"][index])
|
|
|
Element newPair // the new pair to be added
|
|
|
newPair = create_node()
|
|
|
dict_add(newPair, "pn", NewTransfElem) //PatternNode
|
|
|
@@ -332,21 +328,16 @@ Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Elem
|
|
|
|
|
|
Element tf_ma_metamodelTransf //transformation metamodel
|
|
|
tf_ma_metamodelTransf = tf_ma_transformation["metamodel"]["model"]
|
|
|
- Element pre2ram_et // type of the pre2ram edge
|
|
|
- pre2ram_et = dict_read(tf_ma_metamodelTransf, "pre2ram")
|
|
|
Element tf_ma_pattern_edges //all pre2ram edges
|
|
|
- tf_ma_pattern_edges = allOutgoingAssociationInstances(tf_ma_transformation, tf_ma_pattern, pre2ram_et)
|
|
|
+ tf_ma_pattern_edges = allOutgoingAssociationInstances(tf_ma_transformation, tf_ma_pattern, dict_read(tf_ma_metamodelTransf, "pre2ram"))
|
|
|
Element tf_ma_ramified_nodes //dict in the form plabel->node
|
|
|
tf_ma_ramified_nodes = create_node()
|
|
|
- Element tf_ma_ramified_node
|
|
|
+ //get the destinations
|
|
|
while (integer_lt(0, list_len(tf_ma_pattern_edges))):
|
|
|
- tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_edges))
|
|
|
- list_append(tf_ma_ramified_nodes, tf_ma_ramified_node)
|
|
|
+ list_append(tf_ma_ramified_nodes, read_edge_dst(set_pop(tf_ma_pattern_edges)))
|
|
|
|
|
|
//find all nodes in the graph that are not related to attributes: ie a userdefined type
|
|
|
|
|
|
- Element hostmodel_mm //metamodel of hostgraph
|
|
|
- hostmodel_mm = tf_ma_model["metamodel"]["model"]
|
|
|
Element hostmodel_keys //keys of all elements in the model
|
|
|
hostmodel_keys = dict_keys(tf_ma_model["model"])
|
|
|
Element host_nodes //all nodes in the host graph
|
|
|
@@ -407,8 +398,6 @@ Element function mergeLHSNAC(tf_er_lhs : Element, tf_er_nac: Element):
|
|
|
Element function extractPivots(final_matches : Element, tf_er_transformation : Element, tf_er_model : Element):
|
|
|
Integer match_index
|
|
|
match_index = 0
|
|
|
- Element pattern_match_node
|
|
|
- Element host_match_node
|
|
|
Element lhs_match
|
|
|
Element lhs_match_keys
|
|
|
Element lhs_match_key
|
|
|
@@ -421,27 +410,21 @@ Element function extractPivots(final_matches : Element, tf_er_transformation : E
|
|
|
lhs_match_keys = dict_keys(lhs_match)
|
|
|
while (read_nr_out(lhs_match_keys) > 0):
|
|
|
lhs_match_key = set_pop(lhs_match_keys)
|
|
|
- pattern_match_node = lhs_match[lhs_match_key]["pn"]
|
|
|
- host_match_node = lhs_match[lhs_match_key]["hn"]
|
|
|
- pivotOutName = read_attribute(tf_er_transformation, getName(tf_er_transformation, pattern_match_node), "pivotOut")
|
|
|
+ pivotOutName = read_attribute(tf_er_transformation, getName(tf_er_transformation, lhs_match[lhs_match_key]["pn"]), "pivotOut")
|
|
|
if(pivotOutName != ""):
|
|
|
if ( bool_not(set_in(pivotSet, pivotOutName))):
|
|
|
set_add(pivotSet, pivotOutName)
|
|
|
if (dict_in(pivots, pivotOutName)):
|
|
|
dict_delete(pivots, pivotOutName)
|
|
|
dict_add(pivots, pivotOutName, create_node())
|
|
|
- set_add(pivots[pivotOutName], getName(tf_er_model,host_match_node))
|
|
|
+ set_add(pivots[pivotOutName], getName(tf_er_model,lhs_match[lhs_match_key]["hn"]))
|
|
|
return 0
|
|
|
|
|
|
Element function rhs_rewrite(final_matches : Element,plabel_to_rhsnode:Element, tf_er_transformation:Element, tf_er_model:Element ):
|
|
|
//loop over all matches
|
|
|
- Integer match_index
|
|
|
- match_index = 0
|
|
|
Element rhs_plabels
|
|
|
Element rhs_plabel
|
|
|
Element rhs_action
|
|
|
- String new_TypeName
|
|
|
- String new_MetaTypeName
|
|
|
Element rhs_to_host //keep this mapping, so that we know wich nodes in the hostmodel new edges connect
|
|
|
Element lhs_match_keys
|
|
|
Element lhs_match_key
|
|
|
@@ -449,9 +432,8 @@ Element function rhs_rewrite(final_matches : Element,plabel_to_rhsnode:Element,
|
|
|
Element lhs_match
|
|
|
Integer source_plabel
|
|
|
Integer destination_plabel
|
|
|
- while (match_index < read_nr_out(final_matches)):
|
|
|
- lhs_match = list_read(final_matches, match_index)
|
|
|
- match_index = match_index +1
|
|
|
+ while (read_nr_out(final_matches)>0):
|
|
|
+ lhs_match = set_pop(final_matches)
|
|
|
//get set of plables
|
|
|
rhs_plabels = dict_keys(plabel_to_rhsnode)
|
|
|
//loop trough every node in the match
|
|
|
@@ -473,22 +455,19 @@ Element function rhs_rewrite(final_matches : Element,plabel_to_rhsnode:Element,
|
|
|
//for each remaining rhs-key (it is not in the match, so should be added)
|
|
|
while (read_nr_out(rhs_plabels) > 0):
|
|
|
rhs_plabel = set_pop(rhs_plabels)
|
|
|
- //get type and metatype
|
|
|
- new_TypeName = string_substr(getTypeName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel]), 0,-4)
|
|
|
- new_MetaTypeName = getMetaTypeName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel])
|
|
|
//if it is a node, than we can simply add it
|
|
|
- if (new_MetaTypeName == "Class"):
|
|
|
- host_match_node = instantiate_node(tf_er_model, new_TypeName, "")
|
|
|
+ if (bool_not(is_edge(plabel_to_rhsnode[rhs_plabel]))):
|
|
|
+ host_match_node = instantiate_node(tf_er_model, string_substr(getTypeName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel]), 0,-4), "")
|
|
|
//run the function
|
|
|
rhs_action = read_attribute(tf_er_transformation,getName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel]), "function")
|
|
|
rhs_action = tf_er_transformation["actions"][rhs_action]
|
|
|
rhs_action(tf_er_model, tf_er_model["model"][host_match_node])
|
|
|
- elif (new_MetaTypeName == "l5"):
|
|
|
+ else:
|
|
|
//if it is an edge, we can only add it of source and edge exist, else we have to store the edge and get it later
|
|
|
source_plabel = read_attribute(tf_er_transformation, getName(tf_er_transformation, read_edge_src(plabel_to_rhsnode[rhs_plabel]) ) , "plabel")
|
|
|
destination_plabel = read_attribute(tf_er_transformation, getName(tf_er_transformation, read_edge_dst(plabel_to_rhsnode[rhs_plabel]) ) , "plabel")
|
|
|
if(bool_and(dict_in(rhs_to_host, source_plabel), dict_in(rhs_to_host, destination_plabel))):
|
|
|
- rhs_action = instantiate_link(tf_er_model, new_TypeName, "", getName(tf_er_transformation, read_edge_src(plabel_to_rhsnode[rhs_plabel])), getName(tf_er_transformation, read_edge_dst(plabel_to_rhsnode[rhs_plabel])))
|
|
|
+ rhs_action = instantiate_link(tf_er_model, string_substr(getTypeName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel]), 0,-4), "", getName(tf_er_transformation, read_edge_src(plabel_to_rhsnode[rhs_plabel])), getName(tf_er_transformation, read_edge_dst(plabel_to_rhsnode[rhs_plabel])))
|
|
|
//run function
|
|
|
rhs_action = read_attribute(tf_er_transformation,getName(tf_er_transformation, plabel_to_rhsnode[rhs_plabel]), "function")
|
|
|
rhs_action = tf_er_transformation["actions"][rhs_action]
|
|
|
@@ -496,8 +475,7 @@ Element function rhs_rewrite(final_matches : Element,plabel_to_rhsnode:Element,
|
|
|
else:
|
|
|
//TODO this is wrong and might cause an infinite loop
|
|
|
set_add(rhs_plabels, rhs_plabel)
|
|
|
- else:
|
|
|
- log("unsupported metatype in rhs")
|
|
|
+
|
|
|
return 0
|
|
|
|
|
|
Element function tf_executeFRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
|