Skip to content

Commit 81e9225

Browse files
Eliminate some unnecessary header inclusions in headers.
1 parent c89b46c commit 81e9225

File tree

8 files changed

+49
-37
lines changed

8 files changed

+49
-37
lines changed

liblangutil/ParserBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace solidity::langutil
3333

3434
class ErrorReporter;
3535
class Scanner;
36+
struct SourceLocation;
3637
struct ErrorId;
3738

3839
class ParserBase

liblangutil/SemVerHandler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@
2323

2424
#include <liblangutil/SemVerHandler.h>
2525

26+
#include <liblangutil/Exceptions.h>
27+
2628
#include <functional>
2729

2830
using namespace std;
2931
using namespace solidity;
3032
using namespace solidity::langutil;
3133

34+
SemVerMatchExpressionParser::SemVerMatchExpressionParser(vector<Token> _tokens, vector<string> _literals):
35+
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
36+
{
37+
solAssert(m_tokens.size() == m_literals.size(), "");
38+
}
39+
3240
SemVerVersion::SemVerVersion(string const& _versionString)
3341
{
3442
auto i = _versionString.begin();

liblangutil/SemVerHandler.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ struct SemVerMatchExpression
8585
class SemVerMatchExpressionParser
8686
{
8787
public:
88-
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals):
89-
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
90-
{
91-
solAssert(m_tokens.size() == m_literals.size(), "");
92-
}
88+
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals);
9389

9490
/// Returns an expression if it was parseable, or nothing otherwise.
9591
std::optional<SemVerMatchExpression> parse();

liblangutil/Token.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,32 @@
4141
// along with solidity. If not, see <http://www.gnu.org/licenses/>.
4242

4343
#include <liblangutil/Token.h>
44+
#include <liblangutil/Exceptions.h>
4445
#include <map>
4546

4647
using namespace std;
4748

4849
namespace solidity::langutil
4950
{
5051

52+
Token TokenTraits::AssignmentToBinaryOp(Token op)
53+
{
54+
solAssert(isAssignmentOp(op) && op != Token::Assign, "");
55+
return static_cast<Token>(static_cast<int>(op) + (static_cast<int>(Token::BitOr) - static_cast<int>(Token::AssignBitOr)));
56+
}
57+
58+
std::string ElementaryTypeNameToken::toString(bool const& tokenValue) const
59+
{
60+
std::string name = TokenTraits::toString(m_token);
61+
if (tokenValue || (firstNumber() == 0 && secondNumber() == 0))
62+
return name;
63+
solAssert(name.size() >= 3, "Token name size should be greater than 3. Should not reach here.");
64+
if (m_token == Token::FixedMxN || m_token == Token::UFixedMxN)
65+
return name.substr(0, name.size() - 3) + std::to_string(m_firstNumber) + "x" + std::to_string(m_secondNumber);
66+
else
67+
return name.substr(0, name.size() - 1) + std::to_string(m_firstNumber);
68+
}
69+
5170
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
5271
{
5372
solAssert(TokenTraits::isElementaryTypeName(_baseType), "Expected elementary type name: " + string(TokenTraits::toString(_baseType)));

liblangutil/Token.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242

4343
#pragma once
4444

45-
#include <libsolutil/Common.h>
46-
#include <liblangutil/Exceptions.h>
4745
#include <liblangutil/UndefMacros.h>
4846

4947
#include <iosfwd>
@@ -329,11 +327,7 @@ namespace TokenTraits
329327

330328
bool isYulKeyword(std::string const& _literal);
331329

332-
inline Token AssignmentToBinaryOp(Token op)
333-
{
334-
solAssert(isAssignmentOp(op) && op != Token::Assign, "");
335-
return static_cast<Token>(static_cast<int>(op) + (static_cast<int>(Token::BitOr) - static_cast<int>(Token::AssignBitOr)));
336-
}
330+
Token AssignmentToBinaryOp(Token op);
337331

338332
// @returns the precedence > 0 for binary and compare
339333
// operators; returns 0 otherwise.
@@ -393,17 +387,7 @@ class ElementaryTypeNameToken
393387
Token token() const { return m_token; }
394388

395389
///if tokValue is set to true, then returns the actual token type name, otherwise, returns full type
396-
std::string toString(bool const& tokenValue = false) const
397-
{
398-
std::string name = TokenTraits::toString(m_token);
399-
if (tokenValue || (firstNumber() == 0 && secondNumber() == 0))
400-
return name;
401-
solAssert(name.size() >= 3, "Token name size should be greater than 3. Should not reach here.");
402-
if (m_token == Token::FixedMxN || m_token == Token::UFixedMxN)
403-
return name.substr(0, name.size() - 3) + std::to_string(m_firstNumber) + "x" + std::to_string(m_secondNumber);
404-
else
405-
return name.substr(0, name.size() - 1) + std::to_string(m_firstNumber);
406-
}
390+
std::string toString(bool const& tokenValue = false) const;
407391

408392
private:
409393
Token m_token;

libyul/AsmJsonImporter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <libyul/AST.h>
2727
#include <libyul/Exceptions.h>
2828

29+
#include <liblangutil/Exceptions.h>
2930
#include <liblangutil/Scanner.h>
3031

3132
#include <boost/algorithm/string/split.hpp>

libyul/AsmParser.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
#include <libyul/AST.h>
2525
#include <libyul/AsmParser.h>
2626
#include <libyul/Exceptions.h>
27-
#include <liblangutil/Scanner.h>
2827
#include <liblangutil/ErrorReporter.h>
28+
#include <liblangutil/Exceptions.h>
29+
#include <liblangutil/Scanner.h>
2930
#include <libsolutil/Common.h>
3031
#include <libsolutil/Visitor.h>
3132

@@ -70,6 +71,20 @@ optional<int> toInt(string const& _value)
7071

7172
}
7273

74+
std::shared_ptr<DebugData const> Parser::createDebugData() const
75+
{
76+
switch (m_useSourceLocationFrom)
77+
{
78+
case UseSourceLocationFrom::Scanner:
79+
return DebugData::create(ParserBase::currentLocation());
80+
case UseSourceLocationFrom::LocationOverride:
81+
return DebugData::create(m_locationOverride);
82+
case UseSourceLocationFrom::Comments:
83+
return m_debugDataOverride;
84+
}
85+
solAssert(false, "");
86+
}
87+
7388
unique_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
7489
{
7590
m_recursionDepth = 0;

libyul/AsmParser.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,7 @@ class Parser: public langutil::ParserBase
103103
void fetchSourceLocationFromComment();
104104

105105
/// Creates a DebugData object with the correct source location set.
106-
std::shared_ptr<DebugData const> createDebugData() const
107-
{
108-
switch (m_useSourceLocationFrom)
109-
{
110-
case UseSourceLocationFrom::Scanner:
111-
return DebugData::create(ParserBase::currentLocation());
112-
case UseSourceLocationFrom::LocationOverride:
113-
return DebugData::create(m_locationOverride);
114-
case UseSourceLocationFrom::Comments:
115-
return m_debugDataOverride;
116-
}
117-
solAssert(false, "");
118-
}
106+
std::shared_ptr<DebugData const> createDebugData() const;
119107

120108
/// Creates an inline assembly node with the current source location.
121109
template <class T> T createWithLocation() const

0 commit comments

Comments
 (0)