[libsolidity] sourceIndices: selectable internal sources.

This commit is contained in:
Alexander Arlt 2021-11-09 17:06:48 -05:00
parent ef150b7fa6
commit 8608bc3b8c
2 changed files with 5 additions and 4 deletions

View File

@ -978,14 +978,14 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
vector<string> CompilerStack::sourceNames() const
{
map<string, unsigned> indices = sourceIndices();
map<string, unsigned> indices = sourceIndices(false);
vector<string> names(indices.size());
for (auto const& s: indices)
names[s.second] = s.first;
return names;
}
map<string, unsigned> CompilerStack::sourceIndices() const
map<string, unsigned> CompilerStack::sourceIndices(bool _includeInternalSources /* = true */) const
{
map<string, unsigned> indices;
unsigned index = 0;
@ -994,7 +994,8 @@ map<string, unsigned> CompilerStack::sourceIndices() const
for (auto const& s: m_sources)
indices[s.first] = index++;
solAssert(!indices.count(CompilerContext::yulUtilityFileName()), "");
indices[CompilerContext::yulUtilityFileName()] = index++;
if (_includeInternalSources)
indices[CompilerContext::yulUtilityFileName()] = index++;
}
else
for (auto const& s: m_sourceOrder)

View File

@ -242,7 +242,7 @@ public:
/// @returns a mapping assigning each source name its index inside the vector returned
/// by sourceNames().
std::map<std::string, unsigned> sourceIndices() const;
std::map<std::string, unsigned> sourceIndices(bool _includeInternalSources = true) const;
/// @returns the previously used character stream, useful for counting lines during error reporting.
langutil::CharStream const& charStream(std::string const& _sourceName) const override;