Browse Source

Merge pull request #66 from danielhams/osxdevelop

Fix missing parens Id::name and Clang compilation guards + fixes
cl-refactor
Gav Wood 11 years ago
parent
commit
1ac9ac8c8e
  1. 10
      libethereum/AddressState.h
  2. 32
      libethereum/State.cpp
  3. 16
      libethereum/State.h

10
libethereum/AddressState.h

@ -43,7 +43,17 @@ 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)
#ifdef __clang__
{
auto mFinder = m_memory.find((u256)i);
if (mFinder == m_memory.end())
m_memory.insert(std::pair<u256,u256>((u256)i,_memory[i]));
else
mFinder->second = _memory[i];
}
#else
m_memory[(u256)i] = _memory[i];
#endif
}
void incNonce() { m_nonce++; }

32
libethereum/State.cpp

@ -181,10 +181,14 @@ void State::ensureCached(Address _a, bool _requireMemory, bool _forceCreate) con
TrieDB<h256, Overlay> memdb(const_cast<Overlay*>(&m_db), it->second.oldRoot()); // promise we won't alter the overlay! :)
map<u256, u256>& mem = it->second.setHaveMemory();
for (auto const& i: memdb)
#ifdef __clang__
if (mem.find(i.first) == mem.end())
mem.insert(make_pair(i.first, RLP(i.second).toInt<u256>()));
else
mem.at(i.first) = RLP(i.second).toInt<u256>();
#else
mem[i.first] = RLP(i.second).toInt<u256>();
#endif
}
}
@ -713,10 +717,14 @@ void State::executeBare(Transaction const& _t, Address _sender)
m_cache[newAddress] = AddressState(0, 0, AddressType::Contract);
auto& mem = m_cache[newAddress].memory();
for (uint i = 0; i < _t.data.size(); ++i)
#ifdef __clang__
if (mem.find(i) == mem.end())
mem.insert(make_pair(i, _t.data[i]));
else
mem.at(i) = _t.data[i];
#else
mem[i] = _t.data[i];
#endif
#if ETH_SENDER_PAYS_SETUP
subBalance(_sender, _t.value + fee);
@ -758,11 +766,15 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256s
{
if (_v)
{
#ifdef __clang__
auto it = myStore.find(_n);
if (it == myStore.end())
myStore.insert(make_pair(_n, _v));
else
myStore.at(_n) = _v;
#else
myStore[_n] = _v;
#endif
}
else
myStore.erase(_n);
@ -1164,15 +1176,35 @@ void State::execute(Address _myAddress, Address _txSender, u256 _txValue, u256s
break;
}*/
case Instruction::MLOAD:
{
require(1);
#ifdef __clang__
auto mFinder = tempMem.find(stack.back());
if (mFinder != tempMem.end())
stack.back() = mFinder->second;
else
stack.back() = 0;
#else
stack.back() = tempMem[stack.back()];
#endif
break;
}
case Instruction::MSTORE:
{
require(2);
#ifdef __clang__
auto mFinder = tempMem.find(stack.back());
if (mFinder == tempMem.end())
tempMem.insert(make_pair(stack.back(), stack[stack.size() - 2]));
else
mFinder->second = stack[stack.size() - 2];
#else
tempMem[stack.back()] = stack[stack.size() - 2];
#endif
stack.pop_back();
stack.pop_back();
break;
}
case Instruction::SLOAD:
require(1);
stack.back() = store(stack.back());

16
libethereum/State.h

@ -273,7 +273,15 @@ inline std::ostream& operator<<(std::ostream& _out, State const& _s)
for (auto const& j: memdb)
{
_out << std::endl << " [" << j.first << ":" << asHex(j.second) << "]";
#ifdef __clang__
auto mFinder = mem.find(j.first);
if (mFinder == mem.end())
mem.insert(std::make_pair(j.first, RLP(j.second).toInt<u256>()));
else
mFinder->second = RLP(j.second).toInt<u256>();
#else
mem[j.first] = RLP(j.second).toInt<u256>();
#endif
}
_out << std::endl << mem;
}
@ -302,7 +310,15 @@ inline std::ostream& operator<<(std::ostream& _out, State const& _s)
for (auto const& j: memdb)
{
_out << std::endl << " [" << j.first << ":" << asHex(j.second) << "]";
#ifdef __clang__
auto mFinder = mem.find(j.first);
if (mFinder == mem.end())
mem.insert(std::make_pair(j.first, RLP(j.second).toInt<u256>()));
else
mFinder->second = RLP(j.second).toInt<u256>();
#else
mem[j.first] = RLP(j.second).toInt<u256>();
#endif
}
_out << std::endl << mem;
}

Loading…
Cancel
Save