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

2
windows/evmcc.vcxproj

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

2
windows/evmcc.vcxproj.filters

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