mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6388 from ethereum/compilerstack-reset
Change CompilerStack.reset() to have keepSettings flag
This commit is contained in:
commit
d8c42a0270
@ -135,24 +135,20 @@ void CompilerStack::addSMTLib2Response(h256 const& _hash, string const& _respons
|
||||
m_smtlib2Responses[_hash] = _response;
|
||||
}
|
||||
|
||||
void CompilerStack::reset(bool _keepSources)
|
||||
void CompilerStack::reset(bool _keepSettings)
|
||||
{
|
||||
if (_keepSources)
|
||||
{
|
||||
m_stackState = SourcesSet;
|
||||
for (auto sourcePair: m_sources)
|
||||
sourcePair.second.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stackState = Empty;
|
||||
m_sources.clear();
|
||||
}
|
||||
m_stackState = Empty;
|
||||
m_sources.clear();
|
||||
m_smtlib2Responses.clear();
|
||||
m_unhandledSMTLib2Queries.clear();
|
||||
m_libraries.clear();
|
||||
m_evmVersion = langutil::EVMVersion();
|
||||
m_optimiserSettings = OptimiserSettings::minimal();
|
||||
if (!_keepSettings)
|
||||
{
|
||||
m_remappings.clear();
|
||||
m_libraries.clear();
|
||||
m_evmVersion = langutil::EVMVersion();
|
||||
m_optimiserSettings = OptimiserSettings::minimal();
|
||||
m_metadataLiteralSources = false;
|
||||
}
|
||||
m_globalContext.reset();
|
||||
m_scopes.clear();
|
||||
m_sourceOrder.clear();
|
||||
@ -160,15 +156,6 @@ void CompilerStack::reset(bool _keepSources)
|
||||
m_errorReporter.clear();
|
||||
}
|
||||
|
||||
bool CompilerStack::addSource(string const& _name, string const& _content)
|
||||
{
|
||||
bool existed = m_sources.count(_name) != 0;
|
||||
reset(true);
|
||||
m_sources[_name].scanner = make_shared<Scanner>(CharStream(_content, _name));
|
||||
m_stackState = SourcesSet;
|
||||
return existed;
|
||||
}
|
||||
|
||||
void CompilerStack::setSources(StringMap const& _sources)
|
||||
{
|
||||
if (m_stackState == SourcesSet)
|
||||
|
@ -109,10 +109,9 @@ public:
|
||||
/// @returns the current state.
|
||||
State state() const { return m_stackState; }
|
||||
|
||||
/// Resets the compiler to a state where the sources are not parsed or even removed.
|
||||
/// Sets the state to SourcesSet if @a _keepSources is true, otherwise to Empty.
|
||||
/// All settings, with the exception of remappings, are reset.
|
||||
void reset(bool _keepSources = false);
|
||||
/// Resets the compiler to an empty state. Unless @a _keepSettings is set to true,
|
||||
/// all settings are reset as well.
|
||||
void reset(bool _keepSettings = false);
|
||||
|
||||
// Parses a remapping of the format "context:prefix=target".
|
||||
static boost::optional<Remapping> parseRemapping(std::string const& _remapping);
|
||||
@ -148,10 +147,6 @@ public:
|
||||
/// Must be set before parsing.
|
||||
void useMetadataLiteralSources(bool _metadataLiteralSources);
|
||||
|
||||
/// Adds a source object (e.g. file) to the parser. After this, parse has to be called again.
|
||||
/// @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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user