aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-28 21:16:15 +0800
committerChristian <c@ethdev.com>2015-01-28 21:25:42 +0800
commit2903799074a1bb60377fc2adba2d3b0bf2acdfbb (patch)
tree6e3bc237e51e20bc41bb9a7336de4080c2bad73b
parent95d8d7b1f00d3521d20a3735472e359d03d71816 (diff)
downloaddexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar.gz
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar.bz2
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar.lz
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar.xz
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.tar.zst
dexon-solidity-2903799074a1bb60377fc2adba2d3b0bf2acdfbb.zip
Find some reasonable contract if nothing is supplied.
-rw-r--r--CompilerStack.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/CompilerStack.cpp b/CompilerStack.cpp
index 044e0dea..0b8218bb 100644
--- a/CompilerStack.cpp
+++ b/CompilerStack.cpp
@@ -286,10 +286,12 @@ CompilerStack::Contract const& CompilerStack::getContract(string const& _contrac
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("No compiled contracts found."));
string contractName = _contractName;
if (_contractName.empty())
- // try to find the "last contract"
- for (ASTPointer<ASTNode> const& node: m_sourceOrder.back()->ast->getNodes())
- if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
- contractName = contract->getName();
+ // try to find some user-supplied contract
+ for (auto const& it: m_sources)
+ if (!StandardSources.count(it.first))
+ for (ASTPointer<ASTNode> const& node: it.second.ast->getNodes())
+ if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
+ contractName = contract->getName();
auto it = m_contracts.find(contractName);
if (it == m_contracts.end())
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract " + _contractName + " not found."));