Skip to content

Commit d203c80

Browse files
Eliminate unnecessary m_source from Parser
1 parent 6294aa8 commit d203c80

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

liblangutil/Scanner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class Scanner
119119
rescan();
120120
}
121121

122+
CharStream const& charStream() const noexcept { return m_source; }
123+
122124
/// @returns the next token and advances input
123125
Token next();
124126

libsolidity/parsing/Parser.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ ASTPointer<SourceUnit> Parser::parse(CharStream& _charStream)
8787
try
8888
{
8989
m_recursionDepth = 0;
90-
m_source = &_charStream;
9190
m_scanner = make_shared<Scanner>(_charStream);
9291
ASTNodeFactory nodeFactory(*this);
9392

@@ -2057,16 +2056,14 @@ bool Parser::variableDeclarationStart()
20572056

20582057
optional<string> Parser::findLicenseString(std::vector<ASTPointer<ASTNode>> const& _nodes)
20592058
{
2060-
solAssert(!!m_source, "");
2061-
20622059
// We circumvent the scanner here, because it skips non-docstring comments.
20632060
static regex const licenseRegex("SPDX-License-Identifier:\\s*([a-zA-Z0-9 ()+.-]+)");
20642061

20652062
// Search inside all parts of the source not covered by parsed nodes.
20662063
// This will leave e.g. "global comments".
20672064
using iter = std::string::const_iterator;
20682065
vector<pair<iter, iter>> sequencesToSearch;
2069-
string const& source = m_source->source();
2066+
string const& source = m_scanner->charStream().source();
20702067
sequencesToSearch.emplace_back(source.begin(), source.end());
20712068
for (ASTPointer<ASTNode> const& node: _nodes)
20722069
if (node->location().hasText())

libsolidity/parsing/Parser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ class Parser: public langutil::ParserBase
211211
/// Creates an empty ParameterList at the current location (used if parameters can be omitted).
212212
ASTPointer<ParameterList> createEmptyParameterList();
213213

214-
langutil::CharStream* m_source = nullptr;
215214
/// Flag that signifies whether '_' is parsed as a PlaceholderStatement or a regular identifier.
216215
bool m_insideModifier = false;
217216
langutil::EVMVersion m_evmVersion;

0 commit comments

Comments
 (0)