Change CompilerStack.reset to have keepSettings flag instead of keepSources

This commit is contained in:
Alex Beregszaszi 2019-03-25 15:16:25 +00:00
parent cca73f9354
commit d6dda7279c
2 changed files with 14 additions and 19 deletions

View File

@ -135,24 +135,20 @@ void CompilerStack::addSMTLib2Response(h256 const& _hash, string const& _respons
m_smtlib2Responses[_hash] = _response;
}
void CompilerStack::reset(bool _keepSources)
{
if (_keepSources)
{
m_stackState = SourcesSet;
for (auto sourcePair: m_sources)
sourcePair.second.reset();
}
else
void CompilerStack::reset(bool _keepSettings)
{
m_stackState = Empty;
m_sources.clear();
}
m_smtlib2Responses.clear();
m_unhandledSMTLib2Queries.clear();
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();

View File

@ -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);