Skip to content

Commit 8608bc3

Browse files
committed
[libsolidity] sourceIndices: selectable internal sources.
1 parent ef150b7 commit 8608bc3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

libsolidity/interface/CompilerStack.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,14 +978,14 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
978978

979979
vector<string> CompilerStack::sourceNames() const
980980
{
981-
map<string, unsigned> indices = sourceIndices();
981+
map<string, unsigned> indices = sourceIndices(false);
982982
vector<string> names(indices.size());
983983
for (auto const& s: indices)
984984
names[s.second] = s.first;
985985
return names;
986986
}
987987

988-
map<string, unsigned> CompilerStack::sourceIndices() const
988+
map<string, unsigned> CompilerStack::sourceIndices(bool _includeInternalSources /* = true */) const
989989
{
990990
map<string, unsigned> indices;
991991
unsigned index = 0;
@@ -994,7 +994,8 @@ map<string, unsigned> CompilerStack::sourceIndices() const
994994
for (auto const& s: m_sources)
995995
indices[s.first] = index++;
996996
solAssert(!indices.count(CompilerContext::yulUtilityFileName()), "");
997-
indices[CompilerContext::yulUtilityFileName()] = index++;
997+
if (_includeInternalSources)
998+
indices[CompilerContext::yulUtilityFileName()] = index++;
998999
}
9991000
else
10001001
for (auto const& s: m_sourceOrder)

libsolidity/interface/CompilerStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class CompilerStack: public langutil::CharStreamProvider
242242

243243
/// @returns a mapping assigning each source name its index inside the vector returned
244244
/// by sourceNames().
245-
std::map<std::string, unsigned> sourceIndices() const;
245+
std::map<std::string, unsigned> sourceIndices(bool _includeInternalSources = true) const;
246246

247247
/// @returns the previously used character stream, useful for counting lines during error reporting.
248248
langutil::CharStream const& charStream(std::string const& _sourceName) const override;

0 commit comments

Comments
 (0)