|
@ -1,6 +1,7 @@ |
|
|
|
|
|
|
|
|
#include <iostream> |
|
|
#include <iostream> |
|
|
#include <fstream> |
|
|
#include <fstream> |
|
|
|
|
|
#include <ostream> |
|
|
#include <string> |
|
|
#include <string> |
|
|
#include <vector> |
|
|
#include <vector> |
|
|
|
|
|
|
|
@ -22,6 +23,7 @@ void show_usage() |
|
|
std::cerr << "usage: evmcc (-b|-c|-d)+ <inputfile.bc>\n"; |
|
|
std::cerr << "usage: evmcc (-b|-c|-d)+ <inputfile.bc>\n"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) |
|
|
int main(int argc, char** argv) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -30,6 +32,7 @@ int main(int argc, char** argv) |
|
|
bool opt_show_bytes = false; |
|
|
bool opt_show_bytes = false; |
|
|
bool opt_compile = false; |
|
|
bool opt_compile = false; |
|
|
bool opt_interpret = false; |
|
|
bool opt_interpret = false; |
|
|
|
|
|
bool opt_dump_graph = false; |
|
|
bool opt_unknown = false; |
|
|
bool opt_unknown = false; |
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) |
|
|
for (int i = 1; i < argc; i++) |
|
@ -43,6 +46,8 @@ int main(int argc, char** argv) |
|
|
opt_dissassemble = true; |
|
|
opt_dissassemble = true; |
|
|
else if (option == "-i") |
|
|
else if (option == "-i") |
|
|
opt_interpret = true; |
|
|
opt_interpret = true; |
|
|
|
|
|
else if (option == "-g") |
|
|
|
|
|
opt_dump_graph = true; |
|
|
else if (option[0] != '-' && input_file.empty()) |
|
|
else if (option[0] != '-' && input_file.empty()) |
|
|
input_file = option; |
|
|
input_file = option; |
|
|
else |
|
|
else |
|
@ -89,9 +94,18 @@ int main(int argc, char** argv) |
|
|
|
|
|
|
|
|
if (opt_compile) |
|
|
if (opt_compile) |
|
|
{ |
|
|
{ |
|
|
auto module = eth::jit::Compiler().compile(bytecode); |
|
|
auto compiler = eth::jit::Compiler(); |
|
|
|
|
|
auto module = compiler.compile(bytecode); |
|
|
llvm::raw_os_ostream out(std::cout); |
|
|
llvm::raw_os_ostream out(std::cout); |
|
|
module->print(out, nullptr); |
|
|
module->print(out, nullptr); |
|
|
|
|
|
|
|
|
|
|
|
if (opt_dump_graph) |
|
|
|
|
|
{ |
|
|
|
|
|
std::ofstream ofs("blocks.dot"); |
|
|
|
|
|
compiler.dumpBasicBlockGraph(ofs); |
|
|
|
|
|
ofs.close(); |
|
|
|
|
|
std::cout << "Basic blocks graph written to block.dot\n"; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (opt_interpret) |
|
|
if (opt_interpret) |
|
|