diff options
author | Yoichi Hirai <yhirai@pira.jp> | 2016-10-06 22:31:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-06 22:31:17 +0800 |
commit | e69173f910e8454a7dc13f79598e7e9fd5c147c9 (patch) | |
tree | e94715cb2b47b1876970ff29ab20313ba464d8d1 | |
parent | f52634a3391e75a00985c5d3cae9c1b9bb00952f (diff) | |
parent | c7508942feb5c2169f0d463cf4982b580710caf0 (diff) | |
download | dexon-solidity-e69173f910e8454a7dc13f79598e7e9fd5c147c9.tar.gz dexon-solidity-e69173f910e8454a7dc13f79598e7e9fd5c147c9.tar.zst dexon-solidity-e69173f910e8454a7dc13f79598e7e9fd5c147c9.zip |
Merge pull request #1158 from ethereum/inline-assembly-suicide
Support suicide in inline assembly
-rw-r--r-- | Changelog.md | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmParser.cpp | 7 | ||||
-rw-r--r-- | test/libsolidity/InlineAssembly.cpp | 5 |
3 files changed, 14 insertions, 2 deletions
diff --git a/Changelog.md b/Changelog.md index a454f651..8e639a2d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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: diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index 5c7163ee..196b314d 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -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()) { diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 8d1a1d6c..9e96246d 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -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 }")); |