From d6dda7279cc60047255c3a776df2a967d6cdced8 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 25 Mar 2019 15:16:25 +0000 Subject: [PATCH] Change CompilerStack.reset to have keepSettings flag instead of keepSources --- libsolidity/interface/CompilerStack.cpp | 26 +++++++++++-------------- libsolidity/interface/CompilerStack.h | 7 +++---- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index f020def9f..0d9c74fc4 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -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(); diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 52357d642..2bcb6f0f1 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -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 parseRemapping(std::string const& _remapping);