mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2263 from ethereum/compilerstack
Add state checks in ComplerStack (to avoid crash)
This commit is contained in:
commit
242e431881
@ -451,9 +451,6 @@ Json::Value const& CompilerStack::interface(string const& _contractName) const
|
|||||||
|
|
||||||
Json::Value const& CompilerStack::metadata(string const& _contractName, DocumentationType _type) const
|
Json::Value const& CompilerStack::metadata(string const& _contractName, DocumentationType _type) const
|
||||||
{
|
{
|
||||||
if (m_stackState < AnalysisSuccessful)
|
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
|
||||||
|
|
||||||
return metadata(contract(_contractName), _type);
|
return metadata(contract(_contractName), _type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,23 +488,32 @@ Json::Value const& CompilerStack::metadata(Contract const& _contract, Documentat
|
|||||||
string const& CompilerStack::onChainMetadata(string const& _contractName) const
|
string const& CompilerStack::onChainMetadata(string const& _contractName) const
|
||||||
{
|
{
|
||||||
if (m_stackState != CompilationSuccessful)
|
if (m_stackState != CompilationSuccessful)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
return contract(_contractName).onChainMetadata;
|
return contract(_contractName).onChainMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
||||||
{
|
{
|
||||||
|
if (m_stackState < ParsingSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
return *source(_sourceName).scanner;
|
return *source(_sourceName).scanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceUnit const& CompilerStack::ast(string const& _sourceName) const
|
SourceUnit const& CompilerStack::ast(string const& _sourceName) const
|
||||||
{
|
{
|
||||||
|
if (m_stackState < ParsingSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
return *source(_sourceName).ast;
|
return *source(_sourceName).ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContractDefinition const& CompilerStack::contractDefinition(string const& _contractName) const
|
ContractDefinition const& CompilerStack::contractDefinition(string const& _contractName) const
|
||||||
{
|
{
|
||||||
|
if (m_stackState != CompilationSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
return *contract(_contractName).contract;
|
return *contract(_contractName).contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,6 +742,9 @@ void CompilerStack::compileContract(
|
|||||||
|
|
||||||
std::string CompilerStack::defaultContractName() const
|
std::string CompilerStack::defaultContractName() const
|
||||||
{
|
{
|
||||||
|
if (m_stackState != CompilationSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
||||||
|
|
||||||
return contract("").contract->name();
|
return contract("").contract->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user