Browse Source

Workaround for clang bug of ambiguous constructor using array indexing [].

cl-refactor
Daniel Hams 11 years ago
parent
commit
e805ba2791
  1. 8
      libethereum/AddressState.h
  2. 16
      libethereum/State.cpp
  3. 12
      libethereum/State.h

8
libethereum/AddressState.h

@ -43,7 +43,13 @@ public:
AddressState(u256 _balance, u256 _nonce, u256s _memory): m_type(AddressType::Contract), m_balance(_balance), m_nonce(_nonce), m_haveMemory(true)
{
for (unsigned i = 0; i < _memory.size(); ++i)
m_memory[(u256)i] = _memory[i];
{
auto mFinder = m_memory.find((u256)i);
if (mFinder == m_memory.end())
m_memory.emplace((u256)i,_memory[i]);
else
mFinder->second = _memory[i];
}
}
void incNonce() { m_nonce++; }

16
libethereum/State.cpp

@ -1158,15 +1158,27 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256s
break;
}*/
case Instruction::MLOAD:
{
require(1);
stack.back() = tempMem[stack.back()];
auto mFinder = tempMem.find(stack.back());
if (mFinder != tempMem.end())
stack.back() = mFinder->second;
else
throw BadInstruction();
break;
}
case Instruction::MSTORE:
{
require(2);
tempMem[stack.back()] = stack[stack.size() - 2];
auto mFinder = tempMem.find(stack.back());
if (mFinder == tempMem.end())
tempMem.emplace(stack.back(), stack[stack.size() - 2]);
else
mFinder->second = stack[stack.size() - 2];
stack.pop_back();
stack.pop_back();
break;
}
case Instruction::SLOAD:
require(1);
stack.back() = store(stack.back());

12
libethereum/State.h

@ -272,7 +272,11 @@ inline std::ostream& operator<<(std::ostream& _out, State const& _s)
for (auto const& j: memdb)
{
_out << std::endl << " [" << j.first << ":" << asHex(j.second) << "]";
mem[j.first] = RLP(j.second).toInt<u256>();
auto mFinder = mem.find(j.first);
if (mFinder == mem.end())
mem.emplace(j.first, RLP(j.second).toInt<u256>());
else
mFinder->second = RLP(j.second).toInt<u256>();
}
_out << std::endl << mem;
}
@ -301,7 +305,11 @@ inline std::ostream& operator<<(std::ostream& _out, State const& _s)
for (auto const& j: memdb)
{
_out << std::endl << " [" << j.first << ":" << asHex(j.second) << "]";
mem[j.first] = RLP(j.second).toInt<u256>();
auto mFinder = mem.find(j.first);
if (mFinder == mem.end())
mem.emplace(j.first, RLP(j.second).toInt<u256>());
else
mFinder->second = RLP(j.second).toInt<u256>();
}
_out << std::endl << mem;
}

Loading…
Cancel
Save