aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-10-19 06:17:06 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-19 06:54:32 +0800
commit8d3cfa8cff85b1aed7c1b77a0886a58b09144a36 (patch)
tree07f1265778190ab201647827682a0d6261295918 /libsolidity/interface
parent2ce35b77becab2395dce218b106a7ce904a1b141 (diff)
downloaddexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar.gz
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar.bz2
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar.lz
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar.xz
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.tar.zst
dexon-solidity-8d3cfa8cff85b1aed7c1b77a0886a58b09144a36.zip
Simplify contract lookup in CompileStack
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/CompilerStack.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 8edce879..5713256a 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -764,11 +764,15 @@ CompilerStack::Contract const& CompilerStack::contract(string const& _contractNa
{
if (m_contracts.empty())
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("No compiled contracts found."));
+
auto it = m_contracts.find(_contractName);
+ if (it != m_contracts.end())
+ return it->second;
+
// To provide a measure of backward-compatibility, if a contract is not located by its
// fully-qualified name, a lookup will be attempted purely on the contract's name to see
// if anything will satisfy.
- if (it == m_contracts.end() && _contractName.find(":") == string::npos)
+ if (_contractName.find(":") == string::npos)
{
for (auto const& contractEntry: m_contracts)
{
@@ -779,12 +783,13 @@ CompilerStack::Contract const& CompilerStack::contract(string const& _contractNa
string foundName;
getline(ss, source, ':');
getline(ss, foundName, ':');
- if (foundName == _contractName) return contractEntry.second;
+ if (foundName == _contractName)
+ return contractEntry.second;
}
- // If we get here, both lookup methods failed.
- BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract " + _contractName + " not found."));
}
- return it->second;
+
+ // If we get here, both lookup methods failed.
+ BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract \"" + _contractName + "\" not found."));
}
CompilerStack::Source const& CompilerStack::source(string const& _sourceName) const