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

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Fri Jul 23 05:12:19 CEST 2010


Revision: 51191
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51191&view=rev
Author:   pidgeot
Date:     2010-07-23 03:12:18 +0000 (Fri, 23 Jul 2010)

Log Message:
-----------
Filter out unnecessary jumps from output

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

Modified: tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-07-23 02:42:09 UTC (rev 51190)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp	2010-07-23 03:12:18 UTC (rev 51191)
@@ -213,10 +213,31 @@
 					break;
 				default:
 					{
-						uint32 dest = _engine->getDestAddress(it);
-						if (dest != _curGroup->_next->_start->_address) {
+						bool printJump = true;
+						OutEdgeRange r = boost::out_edges(v, _g);
+						for (OutEdgeIterator e = r.first; e != r.second && printJump; ++e) {
+							// Don't output jump to next vertex
+							if (boost::target(*e, _g) == _curGroup->_next->_vertex) {
+								printJump = false;
+								break;
+							}
+
+							// Don't output jump if next vertex starts an else block
+							if (_curGroup->_next->_startElse) {
+								printJump = false;
+								break;
+							}
+
+							OutEdgeRange targetR = boost::out_edges(boost::target(*e, _g), _g);
+							for (OutEdgeIterator targetE = targetR.first; targetE != targetR.second; ++targetE) {
+								// Don't output jump to while loop that has jump to next vertex
+								if (boost::target(*targetE, _g) == _curGroup->_next->_vertex)
+									printJump = false;
+							}
+						}
+						if (printJump) {
 							std::stringstream s;
-							s << boost::format("jump %X") % dest;
+							s << boost::format("jump %X;") % _engine->getDestAddress(it);
 							addOutputLine(s.str());
 						}
 					}


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