mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6338 from ethereum/compilerstack-setsource
Introduce setSources in CompilerStack
This commit is contained in:
@@ -169,6 +169,17 @@ bool CompilerStack::addSource(string const& _name, string const& _content)
|
||||
return existed;
|
||||
}
|
||||
|
||||
void CompilerStack::setSources(StringMap const& _sources)
|
||||
{
|
||||
if (m_stackState == SourcesSet)
|
||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Cannot change sources once set."));
|
||||
if (m_stackState != Empty)
|
||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Must set sources before parsing."));
|
||||
for (auto const& source: _sources)
|
||||
m_sources[source.first].scanner = make_shared<Scanner>(CharStream(/*content*/source.second, /*name*/source.first));
|
||||
m_stackState = SourcesSet;
|
||||
}
|
||||
|
||||
bool CompilerStack::parse()
|
||||
{
|
||||
if (m_stackState != SourcesSet)
|
||||
|
||||
@@ -152,6 +152,9 @@ public:
|
||||
/// @returns true if a source object by the name already existed and was replaced.
|
||||
bool addSource(std::string const& _name, std::string const& _content);
|
||||
|
||||
/// Sets the sources. Must be set before parsing.
|
||||
void setSources(StringMap const& _sources);
|
||||
|
||||
/// Adds a response to an SMTLib2 query (identified by the hash of the query input).
|
||||
/// Must be set before parsing.
|
||||
void addSMTLib2Response(h256 const& _hash, std::string const& _response);
|
||||
|
||||
@@ -647,8 +647,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
|
||||
CompilerStack compilerStack(m_readFile);
|
||||
|
||||
StringMap sourceList = std::move(_inputsAndSettings.sources);
|
||||
for (auto const& source: sourceList)
|
||||
compilerStack.addSource(source.first, source.second);
|
||||
compilerStack.setSources(sourceList);
|
||||
for (auto const& smtLib2Response: _inputsAndSettings.smtLib2Responses)
|
||||
compilerStack.addSMTLib2Response(smtLib2Response.first, smtLib2Response.second);
|
||||
compilerStack.setEVMVersion(_inputsAndSettings.evmVersion);
|
||||
|
||||
Reference in New Issue
Block a user