[Scummvm-cvs-logs] SF.net SVN: scummvm:[41675] tools/branches/gsoc2009-decompiler/decompiler
kjdf at users.sourceforge.net
kjdf at users.sourceforge.net
Fri Jun 19 15:49:39 CEST 2009
Revision: 41675
http://scummvm.svn.sourceforge.net/scummvm/?rev=41675&view=rev
Author: kjdf
Date: 2009-06-19 13:49:39 +0000 (Fri, 19 Jun 2009)
Log Message:
-----------
decompiler: removed -fno-exceptions from CXXOPTS (needed for boost/program options), fixed warnings
Modified Paths:
--------------
tools/branches/gsoc2009-decompiler/decompiler/Makefile
tools/branches/gsoc2009-decompiler/decompiler/misc.h
tools/branches/gsoc2009-decompiler/decompiler/parser.h
tools/branches/gsoc2009-decompiler/decompiler/reader.h
Added Paths:
-----------
tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp
Removed Paths:
-------------
tools/branches/gsoc2009-decompiler/decompiler/decompiler.cc
Modified: tools/branches/gsoc2009-decompiler/decompiler/Makefile
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/Makefile 2009-06-19 13:30:00 UTC (rev 41674)
+++ tools/branches/gsoc2009-decompiler/decompiler/Makefile 2009-06-19 13:49:39 UTC (rev 41675)
@@ -32,7 +32,7 @@
CXXFLAGS+= -Wimplicit -Wundef -Wnon-virtual-dtor -Wwrite-strings
# Disable exceptions, and enabled checking of pointers returned by "new"
-CXXFLAGS+= -fno-exceptions -fcheck-new
+CXXFLAGS+= -fcheck-new
#######################################################################
# Default commands - put the necessary replacements in config.mk #
@@ -73,7 +73,9 @@
decompiler$(EXEEXT): decompiler.o
$(CXX) $(LDFLAGS) -o $@ $+ -lboost_program_options
+decompiler.o: cfg.h graph.h instruction.h misc.h parser.h reader.h
+
######################################################################
# The build rules follow - normally you should have no need to
# touch whatever comes after here.
Deleted: tools/branches/gsoc2009-decompiler/decompiler/decompiler.cc
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/decompiler.cc 2009-06-19 13:30:00 UTC (rev 41674)
+++ tools/branches/gsoc2009-decompiler/decompiler/decompiler.cc 2009-06-19 13:49:39 UTC (rev 41675)
@@ -1,60 +0,0 @@
-#include <iostream>
-
-#include <boost/program_options.hpp>
-
-#include "parser.h"
-#include "cfg.h"
-
-using namespace std;
-using namespace boost::program_options;
-
-
-variables_map parseArgs(int argc, char **argv) {
- variables_map vars;
- options_description visible("Allowed options");
- visible.add_options()
- ("help", "this message")
- ("disasm", "print disassembly and exit")
- ("blocks", "print basic blocks and exit")
- ("graph", "print graph and exit");
- options_description options("Allowed options");
- options.add(visible).add_options()
- ("inputfile", value<string>(), "input file");
- positional_options_description pos;
- pos.add("inputfile", 1);
- try {
- store(command_line_parser(argc, argv).options(options).positional(pos).run(), vars);
- notify(vars);
- } catch (error) {
- }
- if (vars.count("help") || !vars.count("inputfile")) {
- cout << argv[0] << " [option...] file" << endl << endl;
- cout << visible;
- exit(0);
- }
- return vars;
-}
-
-
-int main(int argc, char **argv) {
- variables_map vars = parseArgs(argc, argv);
- Script script(new Scumm6Parser, vars["inputfile"].as<string>().c_str());
- if (vars.count("disasm")) {
- for (size_t i = 0; i < script.size(); i++)
- script.print(cout, i);
- exit(0);
- }
- CFG cfg(script);
- if (vars.count("blocks")) {
- cfg.printBasicBlocks(cout);
- exit(0);
- }
- // cfg.removeJumpsToJumps();
- // cfg.removeDeadBlocks();
- cfg._graph.assignIntervals(cfg._nodes[0]);
- if (vars.count("graph")) {
- cfg.printDot(cout);
- exit(0);
- }
- return 0;
-}
Copied: tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp (from rev 41674, tools/branches/gsoc2009-decompiler/decompiler/decompiler.cc)
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp (rev 0)
+++ tools/branches/gsoc2009-decompiler/decompiler/decompiler.cpp 2009-06-19 13:49:39 UTC (rev 41675)
@@ -0,0 +1,60 @@
+#include <iostream>
+
+#include <boost/program_options.hpp>
+
+#include "parser.h"
+#include "cfg.h"
+
+using namespace std;
+using namespace boost::program_options;
+
+
+variables_map parseArgs(int argc, char **argv) {
+ variables_map vars;
+ options_description visible("Allowed options");
+ visible.add_options()
+ ("help", "this message")
+ ("disasm", "print disassembly and exit")
+ ("blocks", "print basic blocks and exit")
+ ("graph", "print graph and exit");
+ options_description options("Allowed options");
+ options.add(visible).add_options()
+ ("inputfile", value<string>(), "input file");
+ positional_options_description pos;
+ pos.add("inputfile", 1);
+ try {
+ store(command_line_parser(argc, argv).options(options).positional(pos).run(), vars);
+ notify(vars);
+ } catch (error) {
+ }
+ if (vars.count("help") || !vars.count("inputfile")) {
+ cout << argv[0] << " [option...] file" << endl << endl;
+ cout << visible;
+ exit(0);
+ }
+ return vars;
+}
+
+
+int main(int argc, char **argv) {
+ variables_map vars = parseArgs(argc, argv);
+ Script script(new Scumm6Parser, vars["inputfile"].as<string>().c_str());
+ if (vars.count("disasm")) {
+ for (size_t i = 0; i < script.size(); i++)
+ script.print(cout, i);
+ exit(0);
+ }
+ CFG cfg(script);
+ if (vars.count("blocks")) {
+ cfg.printBasicBlocks(cout);
+ exit(0);
+ }
+ // cfg.removeJumpsToJumps();
+ // cfg.removeDeadBlocks();
+ cfg._graph.assignIntervals(cfg._nodes[0]);
+ if (vars.count("graph")) {
+ cfg.printDot(cout);
+ exit(0);
+ }
+ return 0;
+}
Modified: tools/branches/gsoc2009-decompiler/decompiler/misc.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/misc.h 2009-06-19 13:30:00 UTC (rev 41674)
+++ tools/branches/gsoc2009-decompiler/decompiler/misc.h 2009-06-19 13:49:39 UTC (rev 41675)
@@ -45,10 +45,10 @@
}
uint16 read_le_uint16(ifstream &f) {
- uint16 ret = 0;
+ int ret = 0;
ret |= f.get();
ret |= f.get() << 8;
- return ret;
+ return (uint16) ret;
}
#endif
Modified: tools/branches/gsoc2009-decompiler/decompiler/parser.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/parser.h 2009-06-19 13:30:00 UTC (rev 41674)
+++ tools/branches/gsoc2009-decompiler/decompiler/parser.h 2009-06-19 13:49:39 UTC (rev 41675)
@@ -207,7 +207,7 @@
case 'VERB':
read_le_uint32(f);
uint16 minOffset = 65535;
- for (uint8 code = f.get(); code != 0; code = f.get()) {
+ for (int code = f.get(); code != 0; code = f.get()) {
uint16 offset = read_le_uint16(f);
printf("%2x - %.4x\n", code, offset);
if (offset < minOffset)
@@ -222,7 +222,7 @@
ifstream f;
f.open(filename, ios::binary);
parseHeader(f);
- while (_reader->readInstruction(f, script, f.tellg()))
+ while (_reader->readInstruction(f, script, (uint32) f.tellg()))
;
}
Modified: tools/branches/gsoc2009-decompiler/decompiler/reader.h
===================================================================
--- tools/branches/gsoc2009-decompiler/decompiler/reader.h 2009-06-19 13:30:00 UTC (rev 41674)
+++ tools/branches/gsoc2009-decompiler/decompiler/reader.h 2009-06-19 13:49:39 UTC (rev 41675)
@@ -40,8 +40,8 @@
for (uint32 i = 0; i < _format.size(); i++)
switch (_format[i]) {
case 'b': {
- uint16 b = f.get();
- ssret << ' ' << b;
+ int b = f.get();
+ ssret << ' ' << (uint16) b;
break;
}
case 'w': {
@@ -56,16 +56,16 @@
}
case 'o': { // offset, fixed to be counted from the beginning of instruction
int len = _format[++i] - '0';
- int16 w = len + (int16) read_le_uint16(f);
- arguments.push_back(w);
+ int w = len + read_le_uint16(f);
+ arguments.push_back((int16) w);
ssret << ' ' << (w>=0?"+":"") << w;
break;
}
case 's':
ssret << " \"";
- for (char c = f.get(); c != 0; c = f.get())
- if ((uint8) c == 0xff || c == 0xfe) {
- uint8 cmd = f.get();
+ for (int c = f.get(); c != 0; c = f.get())
+ if (c == 0xff || c == 0xfe) {
+ int cmd = f.get();
switch (cmd) {
case 4: {
uint16 w = (uint16) read_le_uint16(f);
@@ -146,8 +146,8 @@
bool readInstruction(ifstream& f, Script *script, uint32 addr) {
// if (f.tellg() >= 0x67) return false; // CUT
- uint8 opcode = f.get();
- if (f.eof()) {
+ int opcode = f.get();
+ if (!f.good()) {
return false;
} else if (!_dispatchTable[opcode]) {
fprintf(stderr, "! [%s] unhandled opcode 0x%02x (%d) at address 0x%02x (%d)\n", _name.c_str(), opcode, opcode, addr, addr);
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