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.
38 lines
767 B
38 lines
767 B
10 years ago
|
|
||
|
#include "Runtime.h"
|
||
|
|
||
10 years ago
|
#include <llvm/IR/GlobalVariable.h>
|
||
|
#include <llvm/IR/Function.h>
|
||
10 years ago
|
#include <llvm/IR/IntrinsicInst.h>
|
||
10 years ago
|
|
||
10 years ago
|
namespace dev
|
||
|
{
|
||
|
namespace eth
|
||
|
{
|
||
|
namespace jit
|
||
10 years ago
|
{
|
||
|
|
||
10 years ago
|
Runtime::Runtime(RuntimeData* _data, Env* _env) :
|
||
10 years ago
|
m_data(*_data),
|
||
|
m_env(*_env),
|
||
10 years ago
|
m_currJmpBuf(m_jmpBuf)
|
||
|
{}
|
||
10 years ago
|
|
||
10 years ago
|
bytes Runtime::getReturnData() const // FIXME: Reconsider returning by copy
|
||
10 years ago
|
{
|
||
|
// TODO: Handle large indexes
|
||
10 years ago
|
auto offset = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataOffset]));
|
||
|
auto size = static_cast<size_t>(llvm2eth(m_data.elems[RuntimeData::ReturnDataSize]));
|
||
|
|
||
10 years ago
|
assert(offset + size <= m_memory.size() || size == 0);
|
||
|
if (offset + size > m_memory.size())
|
||
|
return {};
|
||
|
|
||
10 years ago
|
auto dataBeg = m_memory.begin() + offset;
|
||
|
return {dataBeg, dataBeg + size};
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|