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

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Sun Jul 4 00:54:47 CEST 2010


Revision: 50637
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50637&view=rev
Author:   pidgeot
Date:     2010-07-03 22:54:46 +0000 (Sat, 03 Jul 2010)

Log Message:
-----------
Don't treat jumps to the while condition as a continue if it's the last
block in the loop

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

Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-07-03 22:22:07 UTC (rev 50636)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-07-03 22:54:46 UTC (rev 50637)
@@ -295,8 +295,17 @@
 			OutEdgeIterator oe = boost::out_edges(*v, _g).first;
 			GraphVertex target = boost::target(*oe, _g);
 			Group *targetGr = GET(target);
-			// ...to a while or do-while condition
+			// ...to a while or do-while condition...
 			if (targetGr->_type == kWhileCond || targetGr->_type == kDoWhileCond) {
+				// ...unless it is targeting a while condition...
+				if (targetGr->_type == kWhileCond) {
+					OutEdgeRange toer = boost::out_edges(target, _g);
+					for (OutEdgeIterator toe = toer.first; toe != toe.second; ++toe) {
+						// which jumps to the next sequential group
+						if (GET(boost::target(*toe, _g)) == targetGr->_next)
+							continue;
+					}
+				}
 				gr->_type = kContinue;
 			}
 		}
@@ -327,8 +336,8 @@
 			// else: Jump target of if immediately preceded by an unconditional jump...
 			if (targetGr->_prev->_end->_type != kJump && targetGr->_prev->_end->_type != kJumpRel)
 				continue;
-			// ...which is not a continue...
-			if (targetGr->_prev->_type == kContinue)
+			// ...which is not a break or a continue...
+			if (targetGr->_prev->_type == kContinue || targetGr->_prev->_type == kBreak)
 				continue;
 			// ...to later in the code
 			OutEdgeIterator toe = boost::out_edges(find(targetGr->_prev->_start->_address), _g).first;


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