[Scummvm-cvs-logs] SF.net SVN: scummvm:[51135] tools/branches/gsoc2010-decompiler/decompiler/ codegen.cpp
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Thu Jul 22 12:55:51 CEST 2010
Revision: 51135
http://scummvm.svn.sourceforge.net/scummvm/?rev=51135&view=rev
Author: pidgeot
Date: 2010-07-22 10:55:51 +0000 (Thu, 22 Jul 2010)
Log Message:
-----------
Cleanup codegen 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-22 10:24:08 UTC (rev 51134)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp 2010-07-22 10:55:51 UTC (rev 51135)
@@ -44,10 +44,7 @@
std::string CodeGenerator::indentString(std::string s) {
std::stringstream stream;
- std::string indent(kIndentAmount, ' ');
- for (uint i = 0; i < _indentLevel; i++)
- stream << indent;
- stream << s;
+ stream << std::string(kIndentAmount * _indentLevel, ' ') << s;
return stream.str();
}
@@ -103,7 +100,11 @@
}
void CodeGenerator::addOutputLine(std::string s) {
- _curGroup->_code.push_back(s);
+ std::stringstream stream;
+ stream << boost::format("%08X: ") % _curGroup->_start->_address;
+// stream << indentString(s);
+ stream << s;
+ _curGroup->_code.push_back(stream.str());
}
void CodeGenerator::writeAssignment(EntryPtr dst, EntryPtr src) {
@@ -116,7 +117,7 @@
_curGroup = GET(v);
// Check if we should add else start
- if (_curGroup->_startElse)
+ if (_curGroup->_startElse && _curGroup->_type != kIfCond)
addOutputLine("} else {");
// Check ingoing edges to see if we want to add any extra output
@@ -179,6 +180,11 @@
std::stringstream s;
switch (_curGroup->_type) {
case kIfCond:
+ if (_curGroup->_startElse)
+ {
+ _indentLevel--;
+ s << "} else ";
+ }
s << "if (" << _stack.pop() << ") {";
break;
case kWhileCond:
@@ -206,10 +212,11 @@
default:
{
uint32 dest = _engine->getDestAddress(it);
- if (dest == _curGroup->_next->_start->_address)
- continue;
- std::stringstream s;
- s << boost::format("goto %X") % dest;
+ if (dest != _curGroup->_next->_start->_address) {
+ std::stringstream s;
+ s << boost::format("goto %X") % dest;
+ addOutputLine(s.str());
+ }
}
break;
}
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