mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
documentation, checks and renaming
This commit is contained in:
parent
99a7aefb75
commit
5fd7942173
@ -57,7 +57,7 @@ using namespace dev;
|
|||||||
using namespace dev::solidity;
|
using namespace dev::solidity;
|
||||||
|
|
||||||
CompilerStack::CompilerStack(ReadFile::Callback const& _readFile):
|
CompilerStack::CompilerStack(ReadFile::Callback const& _readFile):
|
||||||
m_readFile(_readFile), m_parseSuccessful(false) {}
|
m_readFile(_readFile), m_success(false) {}
|
||||||
|
|
||||||
void CompilerStack::setRemappings(vector<string> const& _remappings)
|
void CompilerStack::setRemappings(vector<string> const& _remappings)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ void CompilerStack::setRemappings(vector<string> const& _remappings)
|
|||||||
|
|
||||||
void CompilerStack::reset(bool _keepSources)
|
void CompilerStack::reset(bool _keepSources)
|
||||||
{
|
{
|
||||||
m_parseSuccessful = false;
|
m_success = false;
|
||||||
if (_keepSources)
|
if (_keepSources)
|
||||||
for (auto sourcePair: m_sources)
|
for (auto sourcePair: m_sources)
|
||||||
sourcePair.second.reset();
|
sourcePair.second.reset();
|
||||||
@ -116,7 +116,7 @@ bool CompilerStack::parse()
|
|||||||
//reset
|
//reset
|
||||||
m_errors.clear();
|
m_errors.clear();
|
||||||
ASTNode::resetID();
|
ASTNode::resetID();
|
||||||
m_parseSuccessful = false;
|
m_success = false;
|
||||||
|
|
||||||
if (SemVerVersion{string(VersionString)}.isPrerelease())
|
if (SemVerVersion{string(VersionString)}.isPrerelease())
|
||||||
{
|
{
|
||||||
@ -148,8 +148,7 @@ bool CompilerStack::parse()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_parseSuccessful = Error::containsOnlyWarnings(m_errors);
|
return Error::containsOnlyWarnings(m_errors);
|
||||||
return m_parseSuccessful;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerStack::analyze()
|
bool CompilerStack::analyze()
|
||||||
@ -241,8 +240,8 @@ bool CompilerStack::analyze()
|
|||||||
noErrors = false;
|
noErrors = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parseSuccessful = noErrors;
|
m_success = noErrors;
|
||||||
return m_parseSuccessful;
|
return m_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerStack::parse(string const& _sourceCode)
|
bool CompilerStack::parse(string const& _sourceCode)
|
||||||
@ -264,7 +263,7 @@ bool CompilerStack::parseAndAnalyze(std::string const& _sourceCode)
|
|||||||
|
|
||||||
vector<string> CompilerStack::contractNames() const
|
vector<string> CompilerStack::contractNames() const
|
||||||
{
|
{
|
||||||
if (!m_parseSuccessful)
|
if (!m_success)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
vector<string> contractNames;
|
vector<string> contractNames;
|
||||||
for (auto const& contract: m_contracts)
|
for (auto const& contract: m_contracts)
|
||||||
@ -275,7 +274,7 @@ vector<string> CompilerStack::contractNames() const
|
|||||||
|
|
||||||
bool CompilerStack::compile(bool _optimize, unsigned _runs, map<string, h160> const& _libraries)
|
bool CompilerStack::compile(bool _optimize, unsigned _runs, map<string, h160> const& _libraries)
|
||||||
{
|
{
|
||||||
if (!m_parseSuccessful)
|
if (!m_success)
|
||||||
if (!parseAndAnalyze())
|
if (!parseAndAnalyze())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -436,7 +435,7 @@ 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_parseSuccessful)
|
if (!m_success)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
return metadata(contract(_contractName), _type);
|
return metadata(contract(_contractName), _type);
|
||||||
@ -444,7 +443,7 @@ Json::Value const& CompilerStack::metadata(string const& _contractName, Document
|
|||||||
|
|
||||||
Json::Value const& CompilerStack::metadata(Contract const& _contract, DocumentationType _type) const
|
Json::Value const& CompilerStack::metadata(Contract const& _contract, DocumentationType _type) const
|
||||||
{
|
{
|
||||||
if (!m_parseSuccessful)
|
if (!m_success)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
@ -475,7 +474,7 @@ 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_parseSuccessful)
|
if (!m_success)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Parsing was not successful."));
|
||||||
|
|
||||||
return contract(_contractName).onChainMetadata;
|
return contract(_contractName).onChainMetadata;
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
/// @returns false on error.
|
/// @returns false on error.
|
||||||
bool parse(std::string const& _sourceCode);
|
bool parse(std::string const& _sourceCode);
|
||||||
/// performs the analyisis steps (imports, scopesetting, syntaxCheck, referenceResolving,
|
/// performs the analyisis steps (imports, scopesetting, syntaxCheck, referenceResolving,
|
||||||
/// typechecking, staticAnalysis) on the set sources
|
/// typechecking, staticAnalysis) on previously set sources
|
||||||
/// @returns false on error.
|
/// @returns false on error.
|
||||||
bool analyze();
|
bool analyze();
|
||||||
/// Parses and analyzes all source units that were added
|
/// Parses and analyzes all source units that were added
|
||||||
@ -276,7 +276,7 @@ private:
|
|||||||
/// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum
|
/// list of path prefix remappings, e.g. mylibrary: github.com/ethereum = /usr/local/ethereum
|
||||||
/// "context:prefix=target"
|
/// "context:prefix=target"
|
||||||
std::vector<Remapping> m_remappings;
|
std::vector<Remapping> m_remappings;
|
||||||
bool m_parseSuccessful;
|
bool m_success;
|
||||||
std::map<std::string const, Source> m_sources;
|
std::map<std::string const, Source> m_sources;
|
||||||
std::shared_ptr<GlobalContext> m_globalContext;
|
std::shared_ptr<GlobalContext> m_globalContext;
|
||||||
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
|
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
|
||||||
|
Loading…
Reference in New Issue
Block a user