From b80aa77de0e4441dab0ae1cc371010b056ae5ed0 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 28 Jan 2015 14:16:15 +0100 Subject: [PATCH] Find some reasonable contract if nothing is supplied. --- libsolidity/CompilerStack.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index 044e0deab..0b8218bb3 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/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 const& node: m_sourceOrder.back()->ast->getNodes()) - if (auto contract = dynamic_cast(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 const& node: it.second.ast->getNodes()) + if (auto contract = dynamic_cast(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."));