mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
PoC-7 JUMPDEST done the intended way.
Windows pedantic build fix.
This commit is contained in:
parent
8c1c9ac664
commit
b4865f961b
31
Assembly.cpp
31
Assembly.cpp
@ -129,7 +129,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
|
||||
_out << " PUSH[tag" << i.data() << "]";
|
||||
break;
|
||||
case Tag:
|
||||
_out << " tag" << i.data() << ":";
|
||||
_out << " tag" << i.data() << ": JUMPDEST";
|
||||
break;
|
||||
case PushData:
|
||||
_out << " PUSH*[" << hex << (unsigned)i.data() << "]";
|
||||
@ -149,17 +149,6 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
|
||||
|
||||
ostream& Assembly::streamOut(ostream& _out, string const& _prefix) const
|
||||
{
|
||||
_out << _prefix << ".pre:" << endl;
|
||||
for (AssemblyItem const& i: m_items)
|
||||
switch (i.m_type)
|
||||
{
|
||||
case PushTag:
|
||||
_out << _prefix << " PUSH [tag" << i.m_data << "]" << endl;
|
||||
_out << _prefix << " JUMPDEST" << endl;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
_out << _prefix << ".code:" << endl;
|
||||
for (AssemblyItem const& i: m_items)
|
||||
switch (i.m_type)
|
||||
@ -183,7 +172,7 @@ ostream& Assembly::streamOut(ostream& _out, string const& _prefix) const
|
||||
_out << _prefix << " PUSH #[$" << h256(i.m_data).abridged() << "]" << endl;
|
||||
break;
|
||||
case Tag:
|
||||
_out << _prefix << "tag" << i.m_data << ": " << endl;
|
||||
_out << _prefix << "tag" << i.m_data << ": " << endl << _prefix << " JUMPDEST" << endl;
|
||||
break;
|
||||
case PushData:
|
||||
_out << _prefix << " PUSH [" << hex << (unsigned)i.m_data << "]" << endl;
|
||||
@ -364,11 +353,9 @@ bytes Assembly::assemble() const
|
||||
ret.reserve(totalBytes);
|
||||
vector<unsigned> tagPos(m_usedTags);
|
||||
map<unsigned, unsigned> tagRef;
|
||||
map<unsigned, unsigned> pretagRef;
|
||||
multimap<h256, unsigned> dataRef;
|
||||
unsigned bytesPerTag = dev::bytesRequired(totalBytes);
|
||||
byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag;
|
||||
bytes preret;
|
||||
|
||||
for (auto const& i: m_subs)
|
||||
m_data[i.first] = i.second.assemble();
|
||||
@ -406,11 +393,6 @@ bytes Assembly::assemble() const
|
||||
ret.push_back(tagPush);
|
||||
tagRef[ret.size()] = (unsigned)i.m_data;
|
||||
ret.resize(ret.size() + bytesPerTag);
|
||||
|
||||
preret.push_back(tagPush);
|
||||
pretagRef[preret.size()] = (unsigned)i.m_data;
|
||||
preret.resize(preret.size() + bytesPerTag);
|
||||
preret.push_back((byte)Instruction::JUMPDEST);
|
||||
break;
|
||||
}
|
||||
case PushData: case PushSub:
|
||||
@ -432,6 +414,7 @@ bytes Assembly::assemble() const
|
||||
}
|
||||
case Tag:
|
||||
tagPos[(unsigned)i.m_data] = ret.size();
|
||||
ret.push_back((byte)Instruction::JUMPDEST);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
@ -442,12 +425,6 @@ bytes Assembly::assemble() const
|
||||
toBigEndian(tagPos[i.second], r);
|
||||
}
|
||||
|
||||
for (auto const& i: pretagRef)
|
||||
{
|
||||
bytesRef r(preret.data() + i.first, bytesPerTag);
|
||||
toBigEndian(tagPos[i.second], r);
|
||||
}
|
||||
|
||||
if (m_data.size())
|
||||
{
|
||||
ret.push_back(0);
|
||||
@ -466,5 +443,5 @@ bytes Assembly::assemble() const
|
||||
}
|
||||
}
|
||||
}
|
||||
return preret + ret;
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user