aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-10-08 20:43:32 +0800
committerGav Wood <i@gavwood.com>2014-10-08 20:43:32 +0800
commitb4865f961bfa946c38545403e515d8825ebb0399 (patch)
treec8da24e9951ba8b2a3316fdefcb88a0ed16cfceb
parent8c1c9ac6646a93837c5fcd9c446097ae797c25da (diff)
downloaddexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar.gz
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar.bz2
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar.lz
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar.xz
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.tar.zst
dexon-solidity-b4865f961bfa946c38545403e515d8825ebb0399.zip
PoC-7 JUMPDEST done the intended way.
Windows pedantic build fix.
-rw-r--r--Assembly.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/Assembly.cpp b/Assembly.cpp
index 11ee9122..695c9ffa 100644
--- a/Assembly.cpp
+++ b/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;
}