mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Find some reasonable contract if nothing is supplied.
This commit is contained in:
parent
95d8d7b1f0
commit
2903799074
@ -286,10 +286,12 @@ CompilerStack::Contract const& CompilerStack::getContract(string const& _contrac
|
|||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("No compiled contracts found."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("No compiled contracts found."));
|
||||||
string contractName = _contractName;
|
string contractName = _contractName;
|
||||||
if (_contractName.empty())
|
if (_contractName.empty())
|
||||||
// try to find the "last contract"
|
// try to find some user-supplied contract
|
||||||
for (ASTPointer<ASTNode> const& node: m_sourceOrder.back()->ast->getNodes())
|
for (auto const& it: m_sources)
|
||||||
if (auto contract = dynamic_cast<ContractDefinition const*>(node.get()))
|
if (!StandardSources.count(it.first))
|
||||||
contractName = contract->getName();
|
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);
|
auto it = m_contracts.find(contractName);
|
||||||
if (it == m_contracts.end())
|
if (it == m_contracts.end())
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract " + _contractName + " not found."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Contract " + _contractName + " not found."));
|
||||||
|
Loading…
Reference in New Issue
Block a user