Browse Source

Convenient Memory::require() overload

cl-refactor
Paweł Bylica 10 years ago
parent
commit
59000cd85d
  1. 11
      evmcc/Memory.cpp
  2. 4
      evmcc/Memory.h

11
evmcc/Memory.cpp

@ -173,10 +173,15 @@ void Memory::require(llvm::Value* _size)
m_builder.CreateCall(m_require, _size);
}
void Memory::registerReturnData(llvm::Value* _index, llvm::Value* _size)
void Memory::require(llvm::Value* _offset, llvm::Value* _size)
{
auto sizeRequired = m_builder.CreateAdd(_index, _size, "sizeRequired");
require(sizeRequired); // Make sure that memory is allocated and count gas
auto sizeRequired = m_builder.CreateAdd(_offset, _size, "sizeRequired");
require(sizeRequired);
}
void Memory::registerReturnData(llvm::Value* _index, llvm::Value* _size)
{
require(_index, _size); // Make sure that memory is allocated and count gas
m_builder.CreateStore(_index, m_returnDataOffset);
m_builder.CreateStore(_size, m_returnDataSize);

4
evmcc/Memory.h

@ -20,8 +20,12 @@ public:
void storeByte(llvm::Value* _addr, llvm::Value* _byte);
llvm::Value* getSize();
/// Requires this amount of memory. And counts gas fee for that memory.
void require(llvm::Value* _size);
/// Requires the amount of memory to for data defined by offset and size. And counts gas fee for that memory.
void require(llvm::Value* _offset, llvm::Value* _size);
void registerReturnData(llvm::Value* _index, llvm::Value* _size);
static dev::bytesConstRef getReturnData();

Loading…
Cancel
Save