[Scummvm-cvs-logs] SF.net SVN: scummvm:[51800] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Fri Aug 6 22:34:28 CEST 2010
Revision: 51800
http://scummvm.svn.sourceforge.net/scummvm/?rev=51800&view=rev
Author: pidgeot
Date: 2010-08-06 20:34:27 +0000 (Fri, 06 Aug 2010)
Log Message:
-----------
DECOMPILER: Post-processing step to add metadata
to Kyra functions
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
tools/branches/gsoc2010-decompiler/decompiler/engine.h
tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-08-06 20:29:27 UTC (rev 51799)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-08-06 20:34:27 UTC (rev 51800)
@@ -161,6 +161,9 @@
return 0;
}
+ // Post-processing of CFG
+ engine->postCFG(insts, g);
+
// Code generation
CodeGenerator *cg = engine->getCodeGenerator(std::cout);
cg->generate(g);
Modified: tools/branches/gsoc2010-decompiler/decompiler/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/engine.h 2010-08-06 20:29:27 UTC (rev 51799)
+++ tools/branches/gsoc2010-decompiler/decompiler/engine.h 2010-08-06 20:34:27 UTC (rev 51800)
@@ -73,7 +73,7 @@
/**
* Retrieve the disassembler for the engine.
*
- * @param Reference to the std::vector to place the Instructions in.
+ * @param insts Reference to the std::vector to place the Instructions in.
* @return Pointer to a Disassembler for the engine.
*/
virtual Disassembler *getDisassembler(std::vector<Instruction> &insts) = 0;
@@ -95,6 +95,13 @@
virtual CodeGenerator *getCodeGenerator(std::ostream &output) = 0;
/**
+ * Post-processing step after CFG analysis.
+ * @param insts Reference to the std::vector to place the Instructions in.
+ * @param g Graph generated from the CFG analysis.
+ */
+ virtual void postCFG(std::vector<Instruction> &insts, Graph g) { }
+
+ /**
* Whether or not code flow analysis is supported for this engine.
*
* @return True if supported, false if not. If false is returned, code flow analysis should not take place, and -D should be implied.
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp 2010-08-06 20:29:27 UTC (rev 51799)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/disassembler.cpp 2010-08-06 20:34:27 UTC (rev 51800)
@@ -23,9 +23,7 @@
#include "disassembler.h"
#include "engine.h"
-#include <algorithm>
-#include <iostream>
-#include <sstream>
+//#include <algorithm>
#include <boost/format.hpp>
struct FunctionData {
@@ -556,22 +554,6 @@
for (InstIterator it = _insts.begin(); it != _insts.end(); ++it)
addrMap[it->_address] = it;
- // Add metadata to newly found functions
- for (FuncMap::iterator it = _engine->_functions.begin(); it != _engine->_functions.end(); ++it) {
- std::stringstream s;
- s << boost::format("sub0x%X") % it->second._startIt->_address;
- int maxArg = 0;
- for (ConstInstIterator instIt = it->second._startIt; instIt != it->second._endIt; ++instIt) {
- if (instIt->_name.compare("pushBPAdd") == 0) {
- if (maxArg < instIt->_params[0].getSigned()) {
- maxArg = instIt->_params[0].getSigned();
- }
- }
- }
- it->second._args = maxArg;
- it->second._retVal = true;
- }
-
std::sort(funcAddrs.begin(), funcAddrs.end());
//Create ranges from entry points
for (size_t i = 0; i < funcAddrs.size(); i++) {
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp 2010-08-06 20:29:27 UTC (rev 51799)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.cpp 2010-08-06 20:34:27 UTC (rev 51800)
@@ -23,6 +23,10 @@
#include "engine.h"
#include "disassembler.h"
+#include <iostream>
+#include <sstream>
+#include <boost/format.hpp>
+
::Disassembler *Kyra::Engine::getDisassembler(std::vector<Instruction> &insts) {
return new Disassembler(this, insts);
}
@@ -36,6 +40,24 @@
return NULL;
}
+void Kyra::Engine::postCFG(std::vector<Instruction> &insts, Graph g) {
+ // Add metadata to functions
+ for (FuncMap::iterator it = _functions.begin(); it != _functions.end(); ++it) {
+ std::stringstream s;
+ s << boost::format("sub0x%X") % it->second._startIt->_address;
+ int maxArg = 0;
+ for (ConstInstIterator instIt = it->second._startIt; instIt != it->second._endIt; ++instIt) {
+ if (instIt->_name.compare("pushBPAdd") == 0) {
+ if (maxArg < instIt->_params[0].getSigned()) {
+ maxArg = instIt->_params[0].getSigned();
+ }
+ }
+ }
+ it->second._args = maxArg;
+ it->second._retVal = true;
+ }
+}
+
bool Kyra::Engine::detectMoreFuncs() {
return true;
}
Modified: tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h 2010-08-06 20:29:27 UTC (rev 51799)
+++ tools/branches/gsoc2010-decompiler/decompiler/kyra/engine.h 2010-08-06 20:34:27 UTC (rev 51800)
@@ -38,6 +38,7 @@
::Disassembler *getDisassembler(std::vector<Instruction> &insts);
uint32 getDestAddress(ConstInstIterator it) const;
::CodeGenerator *getCodeGenerator(std::ostream &output);
+ void postCFG(std::vector<Instruction> &insts, Graph g);
bool supportsCodeGen() { return false; }
bool detectMoreFuncs();
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