[Scummvm-cvs-logs] SF.net SVN: scummvm:[42342] tools/branches/gsoc2009-decompiler/decompiler

kjdf at users.sourceforge.net kjdf at users.sourceforge.net
Fri Jul 10 17:46:55 CEST 2009


Revision: 42342
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42342&view=rev
Author:   kjdf
Date:     2009-07-10 15:46:55 +0000 (Fri, 10 Jul 2009)

Log Message:
-----------
decompiler: register proxy nodes with appropriate graphs when yanking

Modified Paths:
--------------
    tools/branches/gsoc2009-decompiler/decompiler/graph.cpp
    tools/branches/gsoc2009-decompiler/decompiler/node.cpp

Modified: tools/branches/gsoc2009-decompiler/decompiler/graph.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/graph.cpp	2009-07-10 15:11:21 UTC (rev 42341)
+++ tools/branches/gsoc2009-decompiler/decompiler/graph.cpp	2009-07-10 15:46:55 UTC (rev 42342)
@@ -325,7 +325,11 @@
 }
 
 
+
 ControlFlowGraph *ControlFlowGraph::yank(set<Node*> &nodes) {
+	ControlFlowGraph *subgraph = new ControlFlowGraph;
+	_subgraphs.push_back(subgraph);
+	list<Node*> newNodes;
 	foreach (Node *u, _nodes)
 		foreach (Node *v, _nodes) 
 			if (contains(nodes, u) != contains(nodes, v)) { // replace all cross-graph edges with proxies
@@ -334,11 +338,15 @@
 				while (n--)
 					v->_in.push_back(new ProxyNode(u));
 				foreach (Node *&node, u->_out)
-					if (node == v)
-						node = new ProxyNode(v);
+					if (node == v) {
+						node = new ProxyNode(node);
+						if (contains(nodes, u))
+							subgraph->_nodes.push_back(node);
+						else
+							newNodes.push_back(node);
+					}
 			}
-	ControlFlowGraph *subgraph = new ControlFlowGraph;
-	_subgraphs.push_back(subgraph);
+	copy(newNodes.begin(), newNodes.end(), back_inserter(_nodes));
 	foreach (Node *u, nodes) {
 		subgraph->_nodes.push_back(u);
 		_nodes.remove(u);

Modified: tools/branches/gsoc2009-decompiler/decompiler/node.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/node.cpp	2009-07-10 15:11:21 UTC (rev 42341)
+++ tools/branches/gsoc2009-decompiler/decompiler/node.cpp	2009-07-10 15:46:55 UTC (rev 42342)
@@ -78,7 +78,7 @@
 
 string ProxyNode::toString() {
 	ostringstream ret;
-	ret << "goto " << _node->address() << endl;
+	ret << "goto " << phex(_node->address()) << endl;
 	return ret.str();
 }
 
@@ -101,8 +101,13 @@
 		if (u != exit)
 			_body->setEntry(u->address());
 
-	foreach (Node *u, entry->_out)
+	foreach (Node *u, entry->_out) {
 		u->_in.remove(entry);
+		if (u != exit) {
+			graph->_nodes.remove(u);
+			delete u;
+		}
+	}
 	entry->_out.clear();
 	foreach (Node *u, list<Node*>(entry->_in))
 		graph->replaceEdges(u, entry, this);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list