Browse Source

ExecutionEngine stub and -i program option for interpreting EVM Code

cl-refactor
Paweł Bylica 10 years ago
parent
commit
ec7609f0ad
  1. 18
      evmcc/ExecutionEngine.cpp
  2. 17
      evmcc/ExecutionEngine.h
  3. 29
      evmcc/evmcc.cpp
  4. 2
      windows/evmcc.vcxproj
  5. 2
      windows/evmcc.vcxproj.filters

18
evmcc/ExecutionEngine.cpp

@ -0,0 +1,18 @@
#include "ExecutionEngine.h"
namespace evmcc
{
ExecutionEngine::ExecutionEngine()
{
}
int ExecutionEngine::run(const dev::bytes& bytecode)
{
return 0;
}
}

17
evmcc/ExecutionEngine.h

@ -0,0 +1,17 @@
#pragma once
#include <libdevcore/Common.h>
namespace evmcc
{
class ExecutionEngine
{
public:
ExecutionEngine();
int run(const dev::bytes& bytecode);
};
}

29
evmcc/evmcc.cpp

@ -11,6 +11,7 @@
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include "Compiler.h" #include "Compiler.h"
#include "ExecutionEngine.h"
using namespace dev; using namespace dev;
@ -27,28 +28,23 @@ int main(int argc, char** argv)
std::string input_file; std::string input_file;
bool opt_dissassemble = false; bool opt_dissassemble = false;
bool opt_show_bytes = false; bool opt_show_bytes = false;
bool opt_compile = false; bool opt_compile = false;
bool opt_interpret = false;
bool opt_unknown = false; bool opt_unknown = false;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
{ {
std::string option = argv[i]; std::string option = argv[i];
if (option == "-b") if (option == "-b")
{
opt_show_bytes = true; opt_show_bytes = true;
}
else if (option == "-c") else if (option == "-c")
{
opt_compile = true; opt_compile = true;
}
else if (option == "-d") else if (option == "-d")
{ opt_dissassemble = true;
opt_dissassemble = true; else if (option == "-i")
} opt_interpret = true;
else if (option[0] != '-' && input_file.empty()) else if (option[0] != '-' && input_file.empty())
{ input_file = option;
input_file = option;
}
else else
{ {
opt_unknown = true; opt_unknown = true;
@ -58,7 +54,7 @@ int main(int argc, char** argv)
if (opt_unknown || if (opt_unknown ||
input_file.empty() || input_file.empty() ||
(!opt_show_bytes && !opt_compile && !opt_dissassemble)) (!opt_show_bytes && !opt_compile && !opt_dissassemble && !opt_interpret))
{ {
show_usage(); show_usage();
exit(1); exit(1);
@ -94,5 +90,12 @@ int main(int argc, char** argv)
evmcc::Compiler().compile(bytecode); evmcc::Compiler().compile(bytecode);
} }
if (opt_interpret)
{
auto engine = evmcc::ExecutionEngine();
auto result = engine.run(bytecode);
return result;
}
return 0; return 0;
} }

2
windows/evmcc.vcxproj

@ -21,9 +21,11 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\evmcc\Compiler.cpp" /> <ClCompile Include="..\evmcc\Compiler.cpp" />
<ClCompile Include="..\evmcc\evmcc.cpp" /> <ClCompile Include="..\evmcc\evmcc.cpp" />
<ClCompile Include="..\evmcc\ExecutionEngine.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\evmcc\Compiler.h" /> <ClInclude Include="..\evmcc\Compiler.h" />
<ClInclude Include="..\evmcc\ExecutionEngine.h" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{D51A4898-BD9E-4961-BCAE-1FE7F854BB4D}</ProjectGuid> <ProjectGuid>{D51A4898-BD9E-4961-BCAE-1FE7F854BB4D}</ProjectGuid>

2
windows/evmcc.vcxproj.filters

@ -3,8 +3,10 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\evmcc\evmcc.cpp" /> <ClCompile Include="..\evmcc\evmcc.cpp" />
<ClCompile Include="..\evmcc\Compiler.cpp" /> <ClCompile Include="..\evmcc\Compiler.cpp" />
<ClCompile Include="..\evmcc\ExecutionEngine.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\evmcc\Compiler.h" /> <ClInclude Include="..\evmcc\Compiler.h" />
<ClInclude Include="..\evmcc\ExecutionEngine.h" />
</ItemGroup> </ItemGroup>
</Project> </Project>
Loading…
Cancel
Save