@@ -52,6 +52,8 @@ using namespace solidity::evmasm;
52
52
using namespace solidity ::langutil;
53
53
using namespace solidity ::util;
54
54
55
+ std::map<std::string, std::shared_ptr<std::string const >> Assembly::s_sharedSourceNames;
56
+
55
57
AssemblyItem const & Assembly::append (AssemblyItem _i)
56
58
{
57
59
assertThrow (m_deposit >= 0 , AssemblyException, " Stack underflow." );
@@ -171,12 +173,7 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std:
171
173
172
174
solRequire (srcIndex >= -1 && srcIndex < static_cast <int >(_sourceList.size ()), AssemblyImportException, " Source index out of bounds." );
173
175
if (srcIndex != -1 )
174
- {
175
- static std::map<std::string, std::shared_ptr<std::string const >> sharedSourceNames;
176
- if (sharedSourceNames.find (_sourceList[static_cast <size_t >(srcIndex)]) == sharedSourceNames.end ())
177
- sharedSourceNames[_sourceList[static_cast <size_t >(srcIndex)]] = std::make_shared<std::string>(_sourceList[static_cast <size_t >(srcIndex)]);
178
- location.sourceName = sharedSourceNames[_sourceList[static_cast <size_t >(srcIndex)]];
179
- }
176
+ location.sourceName = sharedSourceName (_sourceList[static_cast <size_t >(srcIndex)]);
180
177
181
178
AssemblyItem result (0 );
182
179
@@ -637,6 +634,14 @@ void Assembly::encodeAllPossibleSubPathsInAssemblyTree(std::vector<size_t> _path
637
634
}
638
635
}
639
636
637
+ std::shared_ptr<std::string const > Assembly::sharedSourceName (std::string const & _name) const
638
+ {
639
+ if (s_sharedSourceNames.find (_name) == s_sharedSourceNames.end ())
640
+ s_sharedSourceNames[_name] = std::make_shared<std::string>(_name);
641
+
642
+ return s_sharedSourceNames[_name];
643
+ }
644
+
640
645
AssemblyItem Assembly::namedTag (std::string const & _name, size_t _params, size_t _returns, std::optional<uint64_t > _sourceID)
641
646
{
642
647
assertThrow (!_name.empty (), AssemblyException, " Empty named tag." );
0 commit comments