[Scummvm-cvs-logs] SF.net SVN: scummvm:[51077] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Wed Jul 21 02:09:56 CEST 2010
Revision: 51077
http://scummvm.svn.sourceforge.net/scummvm/?rev=51077&view=rev
Author: pidgeot
Date: 2010-07-21 00:09:56 +0000 (Wed, 21 Jul 2010)
Log Message:
-----------
Add BinaryOp, Comparison, CondJump handling
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp
Modified: tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp 2010-07-20 23:15:07 UTC (rev 51076)
+++ tools/branches/gsoc2010-decompiler/decompiler/codegen.cpp 2010-07-21 00:09:56 UTC (rev 51077)
@@ -118,17 +118,36 @@
switch (it->_type) {
// We handle plain dups here because their behavior should be identical across instruction sets and this prevents implementation error.
case kDup:
- {
- std::stringstream s;
- EntryPtr p = _stack.pop()->dup(s);
- if (s.str().length() > 0)
+ {
+ std::stringstream s;
+ EntryPtr p = _stack.pop()->dup(s);
+ if (s.str().length() > 0)
+ addOutputLine(s.str());
+ _stack.push(p);
+ _stack.push(p);
+ break;
+ }
+ case kCondJump:
+ case kCondJumpRel:
+ {
+ processInst(*it);
+ std::stringstream s;
+ switch (_curGroup->_type) {
+ case kIfCond:
+ s << "if (" << _stack.pop() << ") {";
+ break;
+ case kWhileCond:
+ s << "while (" << _stack.pop() << ") {";
+ break;
+ case kDoWhileCond:
+ s << "while (" << _stack.pop() << ")";
+ break;
+ }
addOutputLine(s.str());
- _stack.push(p);
- _stack.push(p);
+ }
break;
+ default:
+ processInst(*it);
}
- default:
- processInst(*it);
- }
} while (it++ != _curGroup->_end);
}
Modified: tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp 2010-07-20 23:15:07 UTC (rev 51076)
+++ tools/branches/gsoc2010-decompiler/decompiler/scummv6/codegen.cpp 2010-07-21 00:09:56 UTC (rev 51077)
@@ -73,11 +73,32 @@
break;
}
break;
+ case kBinaryOp:
+ case kComparison:
+ {
+ EntryPtr rhs = _stack.pop();
+ EntryPtr lhs = _stack.pop();
+ _stack.push(new BinaryOpEntry(lhs, rhs, inst._operator));
+ break;
+ }
+ case kCondJumpRel:
+ switch (_curGroup->_type) {
+ case kIfCond:
+ case kWhileCond:
+ if (inst._opcode == 0x5C) // jumpTrue
+ _stack.push(new UnaryOpEntry(_stack.pop(), "!"));
+ break;
+ case kDoWhileCond:
+ if (inst._opcode == 0x5D) // jumpFalse
+ _stack.push(new UnaryOpEntry(_stack.pop(), "!"));
+ break;
+ }
+ break;
default:
{
std::stringstream s;
s << boost::format("Unknown opcode %X at address %08X") % inst._opcode % inst._address;
- _curGroup->_code.push_back(indentString(s.str()));
+ 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