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

kjdf at users.sourceforge.net kjdf at users.sourceforge.net
Fri Jul 10 18:14:23 CEST 2009


Revision: 42344
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42344&view=rev
Author:   kjdf
Date:     2009-07-10 16:14:23 +0000 (Fri, 10 Jul 2009)

Log Message:
-----------
decompiler: recursive while loop structuring and pretty-printing

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 16:01:40 UTC (rev 42343)
+++ tools/branches/gsoc2009-decompiler/decompiler/graph.cpp	2009-07-10 16:14:23 UTC (rev 42344)
@@ -72,9 +72,19 @@
 			ret	<< ", dom=" << u->_dominator->_number;
 		ret << ">\\n" << graphvizEscapeLabel(u->toString()) << "\"];" << endl;
 		foreach (Node *v, u->_out)
-			ret << '"' << u << "\" -> \"" << v << '"' << ";" << endl;
+			ret << '"' << u << "\" -> \"" << v << "\";" << endl;
 	}
 	ret << "}" << endl;
+
+	foreach (ControlFlowGraph *subgraph, graph->_subgraphs)
+		ret << graphvizPrintSubgraph(subgraph, fontname, fontsize);
+
+	foreach (Node *u, graph->_nodes) {
+		WhileLoop *loop = dynamic_cast<WhileLoop*>(u);
+		if (loop && loop->_body->_entry)
+			ret << '"' << u << "\" -> \"" << loop->_body->_entry << "\"[color=blue,style=dashed]" << endl;
+	}
+
 	return ret.str();
 }
 
@@ -228,8 +238,6 @@
 	stringstream ret;
 	ret << "digraph G {" << endl;
 	ret << graphvizPrintSubgraph(this, fontname, fontsize);
-	foreach (ControlFlowGraph *graph, _subgraphs)
-		ret << graphvizPrintSubgraph(graph, fontname, fontsize);
 	ret << "}" << endl;
 	return ret.str();
 }
@@ -312,7 +320,6 @@
 
 list< list<Node*> > ControlFlowGraph::stronglyConnectedComponents() {
 	list< list<Node*> > ret;
-	orderNodes();
 	list<Node*> nodes = inPostOrder(_nodes);
 	nodes.reverse();
 	foreach (Node *u, nodes)
@@ -325,7 +332,7 @@
 }
 
 
-
+// TODO force same proxy nodes for all nodes?
 ControlFlowGraph *ControlFlowGraph::yank(set<Node*> &nodes) {
 	ControlFlowGraph *subgraph = new ControlFlowGraph;
 	_subgraphs.push_back(subgraph);
@@ -356,6 +363,16 @@
 
 
 void ControlFlowGraph::structureLoops() {
+	if (!_entry)
+		return;
+	foreach (Node *u, _nodes) {
+		u->_component = 0;
+		u->_dominator = 0;
+		u->_interval = 0;
+		u->_number = 0;
+	}
+	orderNodes();
+	assignDominators();
 	foreach (list<Node*> component, stronglyConnectedComponents()) {
 		list<Node*> entries = componentEntryPoints(component);
 		if (entries.size() == 1) {

Modified: tools/branches/gsoc2009-decompiler/decompiler/node.cpp
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/node.cpp	2009-07-10 16:01:40 UTC (rev 42343)
+++ tools/branches/gsoc2009-decompiler/decompiler/node.cpp	2009-07-10 16:14:23 UTC (rev 42344)
@@ -113,6 +113,8 @@
 		graph->replaceEdges(u, entry, this);
 	graph->addEdge(this, exit);
 	graph->_nodes.remove(entry);
+
+	_body->structureLoops();
 }
 
 


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