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

further updates to searchstate copy

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

+ 47 - 12
integration/code/pn_interface.alc

@@ -87,7 +87,12 @@ Boolean function node_match(transf_model : Element, transf_elem : Element, host_
 	return True
 
 Element function new_SearchState(OldSearchState : Element, TransfModel : Element, NewTransfElem: Element, HostModel : Element, NewHostElem : Element):
-	Element nss
+
+	//some variables
+	Element nss // new searchstate
+	nss = create_node()
+	Integer index // used for list looping
+	Element elem // reusable loop variable
 	
 	//new MATCHES
 	dict_add(nss, "matches", OldSearchState["matches"]) //hopefully works as a reference
@@ -111,20 +116,50 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
 	dict_add(nss, "curmatch", new_curmatch) //add curmatch to state
 	
 	//new N_PATTERN_OUT (copy everything but the new match elements)
-	//TODO
-	dict_add(nss, "N_pattern_out", create_node())
+	Element ol //old list = old pattern out
+	Element nl //new list = new N pattern out
+	ol = OldSearchState["N_pattern_out"]
+	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?
+			list_append(nl, elem)
+	dict_add(nss, "N_pattern_out", nl)
 	
 	//new N_HOST_OUT (copy everything but the new match elements)
-	//TODO
-	dict_add(nss, "N_host_out", create_node())
+	ol = OldSearchState["N_host_out"]
+	nl = create_node()
+	index = 0
+	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?
+			list_append(nl, elem)
+	dict_add(nss, "N_host_out", nl)
 	
 	//new N_PATTERN_IN (copy everything but the new match elements)
-	//TODO
-	dict_add(nss, "N_pattern_in", create_node())
+	ol = OldSearchState["N_pattern_in"]
+	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?
+			list_append(nl, elem)
+	dict_add(nss, "N_pattern_in", nl)
 	
 	//new N_HOST_IN (copy everything but the new match elements
-	//TODO
-	dict_add(nss, "N_host_in", create_node())
+	ol = OldSearchState["N_host_in"]
+	nl = create_node()
+	index = 0
+	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?
+			list_append(nl, elem)
+	dict_add(nss, "N_host_in", nl)
 	
 	//new V_PATTERN
 	//copy everything but:
@@ -132,7 +167,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
 	//	- outgoing nodes from new match elements
 	//	- incoming nodes from new match elements
 	//TODO
-	dict_add(nss, "V_pattern", tf_ma_ramified_nodes)
+	dict_add(nss, "V_pattern", nl)
 	
 	//new V_PATTERN
 	//copy everything but:
@@ -140,7 +175,7 @@ Element function new_SearchState(OldSearchState : Element, TransfModel : Element
 	//	- outgoing nodes from new match elements
 	//	- incoming nodes from new match elements
 	//TODO
-	dict_add(nss, "V_host", host_nodes)
+	dict_add(nss, "V_host", nl)
 	
 	// copy pattern_size
 	dict_add(nss, "pattern_size", dict_read(OldSearchState["pattern_size"])
@@ -176,7 +211,7 @@ Element function transf_vf2(SearchState: Element, transf_m : Element, host_m : E
 		pattern_node = list_read(pattern_list, index1)
 		index1 = index1 + 1
 		index2 = 0
-		while (index < list_len(host_list)):
+		while (index2 < list_len(host_list)):
 			host_node = list_read(host_list, index2)
 			index2= index2 + 1
 			if(node_match(transf_m, pattern_node, host_m, host_node)):