|
|
@@ -84,10 +84,11 @@ Boolean function node_match(transf_model : Element, transf_elem : Element, host_
|
|
|
type1 = getTypeName(transf_model, transf_elem)
|
|
|
String type2
|
|
|
type2 = string_join(getTypeName(host_model, host_elem), "_LHS")
|
|
|
- log(type1)
|
|
|
- log(type2)
|
|
|
if (type1 != type2):
|
|
|
return False
|
|
|
+ log("--> matched")
|
|
|
+ log(string_join(string_join(type1, " : "), getName(transf_model, transf_elem)))
|
|
|
+ log(string_join(string_join(type2, " : "), getName(host_model, host_elem)))
|
|
|
return True
|
|
|
|
|
|
Integer function are_connected(model: Element, el1:Element, el2:Element):
|
|
|
@@ -158,7 +159,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewTransfElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewTransfElem))):
|
|
|
list_append(nl, elem)
|
|
|
dict_add(nss, "N_pattern_out", nl)
|
|
|
|
|
|
@@ -169,7 +170,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewHostElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewHostElem))):
|
|
|
list_append(nl, elem)
|
|
|
dict_add(nss, "N_host_out", nl)
|
|
|
|
|
|
@@ -180,7 +181,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewTransfElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewTransfElem))):
|
|
|
list_append(nl, elem)
|
|
|
dict_add(nss, "N_pattern_in", nl)
|
|
|
|
|
|
@@ -191,7 +192,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewHostElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewHostElem))):
|
|
|
list_append(nl, elem)
|
|
|
dict_add(nss, "N_host_in", nl)
|
|
|
|
|
|
@@ -203,7 +204,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewTransfElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewTransfElem))):
|
|
|
connectedness = are_connected(TransfModel, NewTransfElem, elem)
|
|
|
if (connectedness == 0): // if not connected, keep in V
|
|
|
list_append(nl, elem)
|
|
|
@@ -216,21 +217,21 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
|
|
|
log(cast_i2s(connectedness))
|
|
|
dict_add(nss, "V_pattern", nl)
|
|
|
|
|
|
- //new V_PATTERN
|
|
|
+ //new V_HOST
|
|
|
ol = OldSearchState["V_host"]
|
|
|
nl = create_node()
|
|
|
index = 0
|
|
|
while (index < list_len(ol)): //loop trough old list
|
|
|
elem = list_read(ol, index)
|
|
|
index = index + 1
|
|
|
- if(elem != NewTransfElem): //WARNING is this the right check?
|
|
|
+ if(bool_not(element_eq(elem, NewHostElem))):
|
|
|
connectedness = are_connected(HostModel, NewHostElem, elem)
|
|
|
if (connectedness == 0): // if not connected, keep in V
|
|
|
list_append(nl, elem)
|
|
|
elif (connectedness == 1): //if connected in outwards manner, don't keep in v and add to outlist
|
|
|
- list_append(nss["N_pattern_out"], elem)
|
|
|
+ list_append(nss["N_host_out"], elem)
|
|
|
elif (connectedness == 2): //if connected in inwards manner, don't keep in v and add to inlist
|
|
|
- list_append(nss["N_pattern_in"], elem)
|
|
|
+ list_append(nss["N_host_in"], elem)
|
|
|
else:
|
|
|
log("new_SearchState: unsupported connectedness value")
|
|
|
log(cast_i2s(connectedness))
|
|
|
@@ -255,11 +256,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
|
|
|
pattern_size = SearchState["pattern_size"]
|
|
|
if pattern_size == list_len(current_match):
|
|
|
log("match found")
|
|
|
- Element matches
|
|
|
- matches = SearchState["matches"]
|
|
|
- set_add(matches, SearchState["curmatch"])
|
|
|
- dict_delete(SearchState, "matches")
|
|
|
- dict_add(SearchState, "matches", matches)
|
|
|
+ set_add(SearchState["matches"], SearchState["curmatch"])
|
|
|
log(cast_i2s(list_len(SearchState["matches"])))
|
|
|
return SearchState
|
|
|
|
|
|
@@ -374,7 +371,7 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
|
|
|
//find LHS
|
|
|
|
|
|
- log("FINDING LHS")
|
|
|
+ log("=== FINDING LHS")
|
|
|
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)
|
|
|
@@ -382,11 +379,11 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
|
|
|
//find NAC
|
|
|
|
|
|
- log("FINDING NAC")
|
|
|
+ log("=== FINDING NAC")
|
|
|
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"))
|
|
|
tf_er_nac = tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_nac)), tf_er_model)
|
|
|
- log(string_join(cast_i2s(list_len(tf_er_nac])), " matches found"))
|
|
|
+ log(string_join(cast_i2s(list_len(tf_er_nac)), " matches found"))
|
|
|
|
|
|
return 0
|
|
|
|