From 48108f5433812a3e409908695083593723c2e80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 22 Oct 2014 16:40:05 +0200 Subject: [PATCH] Implement VMFace with jit::VM --- libevmjit/VM.cpp | 7 ++++--- libevmjit/VM.h | 14 +++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libevmjit/VM.cpp b/libevmjit/VM.cpp index 16011241e..c6364eadb 100644 --- a/libevmjit/VM.cpp +++ b/libevmjit/VM.cpp @@ -1,7 +1,7 @@ #include "VM.h" -#include +#include #include "ExecutionEngine.h" #include "Compiler.h" @@ -13,7 +13,7 @@ namespace eth namespace jit { -bytes VM::go(ExtVMFace& _ext) +bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _steps) { auto module = Compiler().compile(_ext.code); @@ -30,7 +30,8 @@ bytes VM::go(ExtVMFace& _ext) BOOST_THROW_EXCEPTION(StackTooSmall(1,0)); } - return std::move(engine.returnData); + m_output = std::move(engine.returnData); + return {m_output.data(), m_output.size()}; // TODO: This all bytesConstRef stuff sucks } } diff --git a/libevmjit/VM.h b/libevmjit/VM.h index 3e7884b10..934e16ed0 100644 --- a/libevmjit/VM.h +++ b/libevmjit/VM.h @@ -2,6 +2,7 @@ #pragma once #include +#include #include namespace dev @@ -11,20 +12,15 @@ namespace eth namespace jit { -class VM +class VM: public VMFace { public: - /// Construct VM object. - explicit VM(u256 _gas = 0): m_gas(_gas) {} + explicit VM(u256 _gas = 0): VMFace(_gas) {} - void reset(u256 _gas = 0) { m_gas = _gas; } - - bytes go(ExtVMFace& _ext); - - u256 gas() const { return m_gas; } + virtual bytesConstRef go(ExtVMFace& _ext, OnOpFunc const& _onOp = {}, uint64_t _steps = (uint64_t)-1) final; private: - u256 m_gas = 0; + bytes m_output; }; }