[Scummvm-cvs-logs] SF.net SVN: scummvm:[51113] tools/branches/gsoc2010-decompiler/decompiler/ codegen.cpp
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Wed Jul 21 23:52:23 CEST 2010
Revision: 51113
http://scummvm.svn.sourceforge.net/scummvm/?rev=51113&view=rev
Author: pidgeot
Date: 2010-07-21 21:52:22 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Minor cleanup
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-21 21:52:15 UTC (rev 51112)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp 2010-07-21 21:52:22 UTC (rev 51113)
@@ -92,7 +92,7 @@
}
// Print output
- // TODO: Proper indenting, terminate if/whiles, start do/whiles
+ // TODO: Proper indenting
p = GET(entryPoint);
while (p != NULL) {
for (std::vector<std::string>::iterator it = p->_code.begin(); it != p->_code.end(); ++it)
@@ -114,27 +114,30 @@
void CodeGenerator::process(GraphVertex v) {
_curGroup = GET(v);
- // Check if we should add else start or end
+ // Check if we should add else start
if (_curGroup->_startElse)
addOutputLine("} else {");
- else {
- // Check ingoing edges to see if we want to add any extra output
- InEdgeRange ier = boost::in_edges(v, _g);
- for (InEdgeIterator ie = ier.first; ie != ier.second; ++ie) {
- GraphVertex in = boost::source(*ie, _g);
- GroupPtr inGroup = GET(in);
- if (inGroup == _curGroup->_prev)
- continue;
- switch (inGroup->_type) {
- case kDoWhileCond:
- addOutputLine("do {");
- break;
- case kWhileCond:
- case kIfCond:
+
+ // Check ingoing edges to see if we want to add any extra output
+ InEdgeRange ier = boost::in_edges(v, _g);
+ for (InEdgeIterator ie = ier.first; ie != ier.second; ++ie) {
+ GraphVertex in = boost::source(*ie, _g);
+ GroupPtr inGroup = GET(in);
+ if (inGroup == _curGroup->_prev)
+ continue;
+ switch (inGroup->_type) {
+ case kDoWhileCond:
+ addOutputLine("do {");
+ break;
+ case kIfCond:
+ if (!_curGroup->_startElse)
addOutputLine("}");
- break;
- default:
- break;
+ break;
+ case kWhileCond:
+ addOutputLine("}");
+ break;
+ default:
+ break;
}
}
}
@@ -177,6 +180,7 @@
}
} while (it++ != _curGroup->_end);
+ // Add else end if necessary
if (_curGroup->_endElse != NULL)
addOutputLine("}");
}
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