[Scummvm-cvs-logs] SF.net SVN: scummvm:[50576] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Fri Jul 2 00:31:48 CEST 2010
Revision: 50576
http://scummvm.svn.sourceforge.net/scummvm/?rev=50576&view=rev
Author: pidgeot
Date: 2010-07-01 22:31:48 +0000 (Thu, 01 Jul 2010)
Log Message:
-----------
Move short-circuit detection into its own method
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
tools/branches/gsoc2010-decompiler/decompiler/control_flow.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp 2010-07-01 22:23:05 UTC (rev 50575)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp 2010-07-01 22:31:48 UTC (rev 50576)
@@ -157,20 +157,12 @@
// Group ends after a jump
if (curInst->_type == kJump || curInst->_type == kJumpRel || curInst->_type == kCondJump || curInst->_type == kCondJumpRel) {
-/* if (stackLevel != expectedStackLevel) {
- s.push(expectedStackLevel);
- expectedStackLevel = stackLevel;
- }*/
stackLevel = grNext->_stackLevel;
continue;
}
// Group ends before target of a jump
if (in_degree(next, _g) != 1) {
-/* if (stackLevel != expectedStackLevel) {
- s.push(expectedStackLevel);
- expectedStackLevel = stackLevel;
- }*/
stackLevel = grNext->_stackLevel;
continue;
}
@@ -184,8 +176,13 @@
merge(cur, next);
}
- // Short-circuit analysis
- GraphVertex cur = find(curInst);
+ detectShortCircuit();
+}
+
+void ControlFlow::detectShortCircuit() {
+ InstIterator lastInst = _insts.end();
+ --lastInst;
+ GraphVertex cur = find(lastInst);
Group *gr = GET(cur);
while (gr->_prev != NULL) {
bool doMerge = false;
@@ -207,6 +204,7 @@
GraphVertex target = boost::target(*it, _g);
doMerge &= (std::find(succs.begin(), succs.end(), target) != succs.end() || target == cur);
}
+
if (doMerge) {
gr = gr->_prev;
merge(prev, cur);
Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.h 2010-07-01 22:23:05 UTC (rev 50575)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.h 2010-07-01 22:31:48 UTC (rev 50576)
@@ -95,6 +95,11 @@
void createGroups();
/**
+ * Merged groups that are part of the same short-circuited condition check.
+ */
+ void detectShortCircuit();
+
+ /**
* Performs control flow analysis.
*
* @returns The control flow graph after analysis.
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