aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-05-11 20:11:53 +0800
committerGitHub <noreply@github.com>2017-05-11 20:11:53 +0800
commit242e43188161d15d36d831652b03095690524c72 (patch)
tree4853473f6909909a939682c5dd624bae0e6ea791 /libsolidity
parenta6586f75044fe24c3bf25761adaec3275060dda5 (diff)
parentc0f31e4c1b79854bb5960dfe45bcecb907d63f84 (diff)
downloaddexon-solidity-242e43188161d15d36d831652b03095690524c72.tar.gz
dexon-solidity-242e43188161d15d36d831652b03095690524c72.tar.zst
dexon-solidity-242e43188161d15d36d831652b03095690524c72.zip
Merge pull request #2263 from ethereum/compilerstack
Add state checks in ComplerStack (to avoid crash)
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/interface/CompilerStack.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 9c9c9614..5c836358 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -451,9 +451,6 @@ Json::Value const& CompilerStack::interface(string const& _contractName) 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);
}
@@ -491,23 +488,32 @@ Json::Value const& CompilerStack::metadata(Contract const& _contract, Documentat
string const& CompilerStack::onChainMetadata(string const& _contractName) const
{
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;
}
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;
}
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;
}
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;
}
@@ -736,6 +742,9 @@ void CompilerStack::compileContract(
std::string CompilerStack::defaultContractName() const
{
+ if (m_stackState != CompilationSuccessful)
+ BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
+
return contract("").contract->name();
}