[Scummvm-cvs-logs] SF.net SVN: scummvm:[50636] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Sun Jul 4 00:22:07 CEST 2010
Revision: 50636
http://scummvm.svn.sourceforge.net/scummvm/?rev=50636&view=rev
Author: pidgeot
Date: 2010-07-03 22:22:07 +0000 (Sat, 03 Jul 2010)
Log Message:
-----------
Detection of the end of an else block
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
tools/branches/gsoc2010-decompiler/decompiler/graph.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp 2010-07-03 21:57:56 UTC (rev 50635)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp 2010-07-03 22:22:07 UTC (rev 50636)
@@ -327,11 +327,15 @@
// 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)
+ continue;
// ...to later in the code
OutEdgeIterator toe = boost::out_edges(find(targetGr->_prev->_start->_address), _g).first;
Group *targetTargetGr = GET(boost::target(*toe, _g));
if (targetTargetGr->_start->_address > targetGr->_prev->_end->_address) {
- targetGr->_else = true;
+ targetGr->_startElse = true;
+ targetTargetGr->_prev->_endElse = true;
}
}
}
Modified: tools/branches/gsoc2010-decompiler/decompiler/graph.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/graph.h 2010-07-03 21:57:56 UTC (rev 50635)
+++ tools/branches/gsoc2010-decompiler/decompiler/graph.h 2010-07-03 22:22:07 UTC (rev 50636)
@@ -53,7 +53,8 @@
InstIterator _end; ///< Last instruction in the group.
int _stackLevel; ///< Level of the stack upon entry.
GroupType _type; ///< Type of the group.
- bool _else; ///< Group is start of an else block.
+ bool _startElse; ///< Group is start of an else block.
+ bool _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.
@@ -78,7 +79,8 @@
_stackLevel = -1;
_type = kNormal;
_prev = prev;
- _else = false;
+ _startElse = false;
+ _endElse = false;
if (_prev != NULL)
_prev->_next = this;
_next = NULL;
@@ -114,8 +116,10 @@
break;
}
output << "\\n";
- if (group->_else)
+ if (group->_startElse)
output << "Start of else\\n";
+ if (group->_endElse)
+ output << "End of else\\n";
InstIterator inst = group->_start;
do {
output << boost::format("%08x: %s") % inst->_address % inst->_name;
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