This repository was archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (38 loc) · 1.4 KB
/
main.cpp
File metadata and controls
51 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef JDECOMPILER_MAIN_CPP
#define JDECOMPILER_MAIN_CPP
#include "function-definitions.cpp"
#include "finish.cpp"
int main(int argc, const char* args[]) {
using namespace jdecompiler;
using std::boolalpha;
atexit(&finish);
signal(SIGSEGV, &finishSigSegvHandler);
cout << boolalpha;
cerr << boolalpha;
if(!JDecompiler::init(argc, args))
return 0;
JDecompiler::getInstance().readClassFiles();
for(const auto& nameAndClass : JDecompiler::getInstance().getDecompilationClasses()) {
const ClassHolder& clazz = nameAndClass.second;
if(clazz->canStringify()) {
log("stringify of", nameAndClass.first);
try {
if(JDecompiler::getInstance().writeToConsole()) {
cout << clazz->toString() << endl;
} else {
BinaryOutputStream* outfile = new FileBinaryOutputStream(clazz.outputPath);
outfile->writeString(clazz->toString());
delete outfile;
}
} catch(const Exception& ex) {
cerr << "Exception while decompiling class " << nameAndClass.second->thisType.getClassEncodedName() << ": " << ex.toString() << endl;
} catch(const exception& ex) {
const char* errorMessage = ex.what();
cerr << "Exception while decompiling class " << nameAndClass.second->thisType.getClassEncodedName() << ": " <<
typenameof(ex) << (*errorMessage == '\0' ? "" : ": ") << errorMessage << endl;
}
}
}
return 0;
}
#endif