VMFactory - a new way of creating VMs

This commit is contained in:
Paweł Bylica 2014-12-10 17:41:53 +01:00
parent eafe303e08
commit c1ffbbe797
2 changed files with 8 additions and 7 deletions

View File

@ -32,7 +32,7 @@
#include <libdevcore/CommonIO.h> #include <libdevcore/CommonIO.h>
#include <libdevcore/CommonData.h> #include <libdevcore/CommonData.h>
#include <libevmcore/Instruction.h> #include <libevmcore/Instruction.h>
#include <libevm/VM.h> #include <libevm/VMFactory.h>
#include "vm.h" #include "vm.h"
using namespace std; using namespace std;
@ -142,14 +142,14 @@ void doMyTests(json_spirit::mValue& v)
} }
bytes output; bytes output;
eth::VM vm(fev.gas); auto vm = eth::VMFactory::create(fev.gas);
u256 gas; u256 gas;
bool vmExceptionOccured = false; bool vmExceptionOccured = false;
try try
{ {
output = vm.go(fev, fev.simpleTrace()).toBytes(); output = vm->go(fev, fev.simpleTrace()).toBytes();
gas = vm.gas(); gas = vm->gas();
} }
catch (eth::VMException const& _e) catch (eth::VMException const& _e)
{ {

7
vm.cpp
View File

@ -22,6 +22,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <libethereum/Executive.h> #include <libethereum/Executive.h>
#include <libevm/VMFactory.h>
#include "vm.h" #include "vm.h"
using namespace std; using namespace std;
@ -298,14 +299,14 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
} }
bytes output; bytes output;
VM vm(fev.gas); auto vm = eth::VMFactory::create(fev.gas);
u256 gas; u256 gas;
bool vmExceptionOccured = false; bool vmExceptionOccured = false;
try try
{ {
output = vm.go(fev, fev.simpleTrace()).toBytes(); output = vm->go(fev, fev.simpleTrace()).toBytes();
gas = vm.gas(); gas = vm->gas();
} }
catch (VMException const& _e) catch (VMException const& _e)
{ {