diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-05-17 18:21:37 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-05-26 10:20:10 +0800 |
commit | 66eab1caf63f9221a279abf71de953524fe9c2ad (patch) | |
tree | deec1c6b67f411d4a1efdee9400640e5c61a989e /libsolidity/inlineasm/AsmAnalysis.cpp | |
parent | b5080860d5f2d141b8fccceaa635378a86c996a8 (diff) | |
download | dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar.gz dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar.bz2 dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar.lz dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar.xz dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.tar.zst dexon-solidity-66eab1caf63f9221a279abf71de953524fe9c2ad.zip |
Change switch case string to Literal
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.cpp')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index ecc63372..a83a93a8 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -292,21 +292,29 @@ bool AsmAnalyzer::operator()(Switch const& _switch) return false; expectDeposit(1, initialStackHeight, locationOf(*_switch.expression)); - map<string, bool> caseNames; + set<tuple<LiteralKind, string>> cases; for (auto const& _case: _switch.cases) { - /// Note: the parser ensures there is only one default case - if (caseNames[_case.name]) + if (_case.value) { - m_errors.push_back(make_shared<Error>( - Error::Type::DeclarationError, - "Duplicate case defined: " + _case.name, - _case.location - )); - return false; + int const initialStackHeight = m_stackHeight; + if (!(*this)(*_case.value)) + return false; + expectDeposit(1, initialStackHeight, _case.value->location); + m_stackHeight--; + + /// Note: the parser ensures there is only one default case + auto val = make_tuple(_case.value->kind, _case.value->value); + if (!cases.insert(val).second) + { + m_errors.push_back(make_shared<Error>( + Error::Type::DeclarationError, + "Duplicate case defined", + _case.location + )); + return false; + } } - else - caseNames[_case.name] = true; if (!(*this)(_case.body)) return false; |