You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

59 lines
813 B

#include "Runtime.h"
#include <libevm/VM.h>
#include "Type.h"
namespace evmcc
{
static Runtime* g_runtime;
extern "C"
{
EXPORT i256 gas;
EXPORT void rt_exit(int32_t _returnCode)
{
auto returnCode = static_cast<ReturnCode>(_returnCode);
if (returnCode == ReturnCode::OutOfGas)
BOOST_THROW_EXCEPTION(dev::eth::OutOfGas());
}
}
Runtime::Runtime(dev::u256 _gas, std::unique_ptr<dev::eth::ExtVMFace> _ext):
m_ext(std::move(_ext))
{
assert(!g_runtime);
g_runtime = this;
gas = eth2llvm(_gas);
}
Runtime::~Runtime()
{
g_runtime = nullptr;
}
StackImpl& Runtime::getStack()
{
return g_runtime->m_stack;
}
MemoryImpl& Runtime::getMemory()
{
return g_runtime->m_memory;
}
dev::eth::ExtVMFace& Runtime::getExt()
{
return *g_runtime->m_ext;
}
dev::u256 Runtime::getGas()
{
return llvm2eth(gas);
}
}