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

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Mon Jul 19 12:00:21 CEST 2010


Revision: 51022
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51022&view=rev
Author:   pidgeot
Date:     2010-07-19 10:00:20 +0000 (Mon, 19 Jul 2010)

Log Message:
-----------
Print decompiled code at end of code generation

Modified Paths:
--------------
    tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
    tools/branches/gsoc2010-decompiler/decompiler/graph.h

Modified: tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-07-19 09:29:57 UTC (rev 51021)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-07-19 10:00:20 UTC (rev 51022)
@@ -73,7 +73,7 @@
 		GraphVertex v = e.first;
 		process(v);
 		OutEdgeRange r = boost::out_edges(v, _g);
-		for (OutEdgeIterator i = r.first; i != r.second; i++) {
+		for (OutEdgeIterator i = r.first; i != r.second; ++i) {
 			GraphVertex target = boost::target(*i, _g);
 			if (seen.find(target) == seen.end()) {
 				dfsStack.push(DFSEntry(target, _stack));
@@ -82,7 +82,13 @@
 		}
 	}
 
-	// TODO: Print output
+	// Print output
+	p = GET(entryPoint);
+	while (p->_next != NULL) {
+		for (std::vector<std::string>::iterator it = p->_code.begin(); it != p->_code.end(); ++it)
+			_output << *it << std::endl;
+		p = p->_next;
+	}
 }
 
 void CodeGenerator::process(GraphVertex v) {

Modified: tools/branches/gsoc2010-decompiler/decompiler/graph.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/graph.h	2010-07-19 09:29:57 UTC (rev 51021)
+++ tools/branches/gsoc2010-decompiler/decompiler/graph.h	2010-07-19 10:00:20 UTC (rev 51022)
@@ -27,6 +27,7 @@
 
 #include <ostream>
 #include <utility>
+#include <vector>
 
 #include <boost/format.hpp>
 
@@ -204,15 +205,16 @@
   friend void ::boost::intrusive_ptr_release(Group *p); ///< Allow access by reference counting methods in boost namespace.
 
 public:
-	GraphVertex _vertex;      ///< Vertex the group belongs to.
-	ConstInstIterator _start; ///< First instruction in the group.
-	ConstInstIterator _end;   ///< Last instruction in the group.
-	int _stackLevel;          ///< Level of the stack upon entry.
-	GroupType _type;          ///< Type of the group.
-	bool _startElse;          ///< Group is start of an else block.
-	Group *_endElse;          ///< Group is end of an else block.
-	Group *_prev;             ///< Pointer to the previous group, when ordered by address. Used for short-circuit analysis.
-	Group *_next;             ///< Pointer to the next group, when ordered by address.
+	GraphVertex _vertex;            ///< Vertex the group belongs to.
+	ConstInstIterator _start;       ///< First instruction in the group.
+	ConstInstIterator _end;         ///< Last instruction in the group.
+	int _stackLevel;                ///< Level of the stack upon entry.
+	GroupType _type;                ///< Type of the group.
+	bool _startElse;                ///< Group is start of an else block.
+	Group *_endElse;                ///< Group is end of an else block.
+	Group *_prev;                   ///< Pointer to the previous group, when ordered by address. Used for short-circuit analysis.
+	Group *_next;                   ///< Pointer to the next group, when ordered by address.
+	std::vector<std::string> _code; ///< Container for decompiled lines of code.
 
 	/**
 	 * Parameterless constructor for Group. Required for use with STL and Boost, should not be called manually.


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