Merge pull request #5377 from ethereum/resetYulString

Reset yul string repository.
This commit is contained in:
chriseth 2018-11-09 16:06:51 +01:00 committed by GitHub
commit dffbeebf60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -47,6 +47,8 @@
#include <libevmasm/Exceptions.h>
#include <libyul/YulString.h>
#include <libdevcore/SwarmHash.h>
#include <libdevcore/JSON.h>
@ -104,6 +106,7 @@ void CompilerStack::reset(bool _keepSources)
m_stackState = Empty;
m_sources.clear();
}
yul::YulStringRepository::instance().reset();
m_libraries.clear();
m_evmVersion = EVMVersion();
m_optimize = false;

View File

@ -35,9 +35,9 @@ namespace yul
class YulStringRepository: boost::noncopyable
{
public:
YulStringRepository(): m_strings{std::make_shared<std::string>()}
YulStringRepository()
{
m_ids[std::string{}] = 0;
reset();
}
static YulStringRepository& instance()
{
@ -61,6 +61,14 @@ public:
return *m_strings.at(_id);
}
void reset()
{
m_strings.clear();
m_ids.clear();
m_strings.emplace_back(std::make_shared<std::string>());
m_ids[std::string{}] = 0;
}
private:
std::vector<std::shared_ptr<std::string>> m_strings;
std::map<std::string, size_t> m_ids;

View File

@ -90,6 +90,8 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
{
yul::YulStringRepository::instance().reset();
assembly::AsmPrinter printer{m_yul};
shared_ptr<Block> ast;
shared_ptr<assembly::AsmAnalysisInfo> analysisInfo;