From 6afdee5958624a41fcb8f136d1a18f1d8dd816bb Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 5 Oct 2016 11:59:16 +0100 Subject: [PATCH] Support both suicide/selfdestruct in inline assembly --- Changelog.md | 4 ++++ libsolidity/inlineasm/AsmParser.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index a454f6513..8e639a2d3 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 5c7163ee8..196b314d2 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 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()) {