Merge pull request #1158 from ethereum/inline-assembly-suicide

Support suicide in inline assembly
This commit is contained in:
Yoichi Hirai 2016-10-06 16:31:17 +02:00 committed by GitHub
commit e69173f910
3 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,9 @@
### 0.4.3 (unreleased)
Features:
* Inline assembly: support both `sucide` and `selfdestruct` opcodes
(note: `suicide` is deprecated)
### 0.4.2 (2016-09-17)
Bugfixes:

View File

@ -133,6 +133,7 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
// Allowed instructions, lowercase names.
static map<string, dev::solidity::Instruction> s_instructions;
if (s_instructions.empty())
{
for (auto const& instruction: solidity::c_instructions)
{
if (
@ -141,12 +142,14 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
)
continue;
string name = instruction.first;
if (instruction.second == solidity::Instruction::SUICIDE)
name = "selfdestruct";
transform(name.begin(), name.end(), name.begin(), [](unsigned char _c) { return tolower(_c); });
s_instructions[name] = instruction.second;
}
// add alias for selfdestruct
s_instructions["selfdestruct"] = solidity::Instruction::SUICIDE;
}
Statement ret;
switch (m_scanner->currentToken())
{

View File

@ -87,6 +87,11 @@ BOOST_AUTO_TEST_CASE(simple_instructions)
BOOST_CHECK(successParse("{ dup1 dup1 mul dup1 sub }"));
}
BOOST_AUTO_TEST_CASE(suicide_selfdestruct)
{
BOOST_CHECK(successParse("{ suicide selfdestruct }"));
}
BOOST_AUTO_TEST_CASE(keywords)
{
BOOST_CHECK(successParse("{ byte return }"));