mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Eliminate some unnecessary header inclusions in headers.
This commit is contained in:
parent
c89b46c55e
commit
81e9225304
@ -33,6 +33,7 @@ namespace solidity::langutil
|
|||||||
|
|
||||||
class ErrorReporter;
|
class ErrorReporter;
|
||||||
class Scanner;
|
class Scanner;
|
||||||
|
struct SourceLocation;
|
||||||
struct ErrorId;
|
struct ErrorId;
|
||||||
|
|
||||||
class ParserBase
|
class ParserBase
|
||||||
|
@ -23,12 +23,20 @@
|
|||||||
|
|
||||||
#include <liblangutil/SemVerHandler.h>
|
#include <liblangutil/SemVerHandler.h>
|
||||||
|
|
||||||
|
#include <liblangutil/Exceptions.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
using namespace solidity::langutil;
|
using namespace solidity::langutil;
|
||||||
|
|
||||||
|
SemVerMatchExpressionParser::SemVerMatchExpressionParser(vector<Token> _tokens, vector<string> _literals):
|
||||||
|
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
|
||||||
|
{
|
||||||
|
solAssert(m_tokens.size() == m_literals.size(), "");
|
||||||
|
}
|
||||||
|
|
||||||
SemVerVersion::SemVerVersion(string const& _versionString)
|
SemVerVersion::SemVerVersion(string const& _versionString)
|
||||||
{
|
{
|
||||||
auto i = _versionString.begin();
|
auto i = _versionString.begin();
|
||||||
|
@ -85,11 +85,7 @@ struct SemVerMatchExpression
|
|||||||
class SemVerMatchExpressionParser
|
class SemVerMatchExpressionParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals):
|
SemVerMatchExpressionParser(std::vector<Token> _tokens, std::vector<std::string> _literals);
|
||||||
m_tokens(std::move(_tokens)), m_literals(std::move(_literals))
|
|
||||||
{
|
|
||||||
solAssert(m_tokens.size() == m_literals.size(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an expression if it was parseable, or nothing otherwise.
|
/// Returns an expression if it was parseable, or nothing otherwise.
|
||||||
std::optional<SemVerMatchExpression> parse();
|
std::optional<SemVerMatchExpression> parse();
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
// along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
// along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <liblangutil/Token.h>
|
#include <liblangutil/Token.h>
|
||||||
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -48,6 +49,24 @@ using namespace std;
|
|||||||
namespace solidity::langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Token TokenTraits::AssignmentToBinaryOp(Token op)
|
||||||
|
{
|
||||||
|
solAssert(isAssignmentOp(op) && op != Token::Assign, "");
|
||||||
|
return static_cast<Token>(static_cast<int>(op) + (static_cast<int>(Token::BitOr) - static_cast<int>(Token::AssignBitOr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ElementaryTypeNameToken::toString(bool const& tokenValue) const
|
||||||
|
{
|
||||||
|
std::string name = TokenTraits::toString(m_token);
|
||||||
|
if (tokenValue || (firstNumber() == 0 && secondNumber() == 0))
|
||||||
|
return name;
|
||||||
|
solAssert(name.size() >= 3, "Token name size should be greater than 3. Should not reach here.");
|
||||||
|
if (m_token == Token::FixedMxN || m_token == Token::UFixedMxN)
|
||||||
|
return name.substr(0, name.size() - 3) + std::to_string(m_firstNumber) + "x" + std::to_string(m_secondNumber);
|
||||||
|
else
|
||||||
|
return name.substr(0, name.size() - 1) + std::to_string(m_firstNumber);
|
||||||
|
}
|
||||||
|
|
||||||
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
|
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
|
||||||
{
|
{
|
||||||
solAssert(TokenTraits::isElementaryTypeName(_baseType), "Expected elementary type name: " + string(TokenTraits::toString(_baseType)));
|
solAssert(TokenTraits::isElementaryTypeName(_baseType), "Expected elementary type name: " + string(TokenTraits::toString(_baseType)));
|
||||||
|
@ -42,8 +42,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <libsolutil/Common.h>
|
|
||||||
#include <liblangutil/Exceptions.h>
|
|
||||||
#include <liblangutil/UndefMacros.h>
|
#include <liblangutil/UndefMacros.h>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@ -329,11 +327,7 @@ namespace TokenTraits
|
|||||||
|
|
||||||
bool isYulKeyword(std::string const& _literal);
|
bool isYulKeyword(std::string const& _literal);
|
||||||
|
|
||||||
inline Token AssignmentToBinaryOp(Token op)
|
Token AssignmentToBinaryOp(Token op);
|
||||||
{
|
|
||||||
solAssert(isAssignmentOp(op) && op != Token::Assign, "");
|
|
||||||
return static_cast<Token>(static_cast<int>(op) + (static_cast<int>(Token::BitOr) - static_cast<int>(Token::AssignBitOr)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// @returns the precedence > 0 for binary and compare
|
// @returns the precedence > 0 for binary and compare
|
||||||
// operators; returns 0 otherwise.
|
// operators; returns 0 otherwise.
|
||||||
@ -393,17 +387,7 @@ public:
|
|||||||
Token token() const { return m_token; }
|
Token token() const { return m_token; }
|
||||||
|
|
||||||
///if tokValue is set to true, then returns the actual token type name, otherwise, returns full type
|
///if tokValue is set to true, then returns the actual token type name, otherwise, returns full type
|
||||||
std::string toString(bool const& tokenValue = false) const
|
std::string toString(bool const& tokenValue = false) const;
|
||||||
{
|
|
||||||
std::string name = TokenTraits::toString(m_token);
|
|
||||||
if (tokenValue || (firstNumber() == 0 && secondNumber() == 0))
|
|
||||||
return name;
|
|
||||||
solAssert(name.size() >= 3, "Token name size should be greater than 3. Should not reach here.");
|
|
||||||
if (m_token == Token::FixedMxN || m_token == Token::UFixedMxN)
|
|
||||||
return name.substr(0, name.size() - 3) + std::to_string(m_firstNumber) + "x" + std::to_string(m_secondNumber);
|
|
||||||
else
|
|
||||||
return name.substr(0, name.size() - 1) + std::to_string(m_firstNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Token m_token;
|
Token m_token;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
|
|
||||||
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/Scanner.h>
|
#include <liblangutil/Scanner.h>
|
||||||
|
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/AsmParser.h>
|
#include <libyul/AsmParser.h>
|
||||||
#include <libyul/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
#include <liblangutil/Scanner.h>
|
|
||||||
#include <liblangutil/ErrorReporter.h>
|
#include <liblangutil/ErrorReporter.h>
|
||||||
|
#include <liblangutil/Exceptions.h>
|
||||||
|
#include <liblangutil/Scanner.h>
|
||||||
#include <libsolutil/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libsolutil/Visitor.h>
|
#include <libsolutil/Visitor.h>
|
||||||
|
|
||||||
@ -70,6 +71,20 @@ optional<int> toInt(string const& _value)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DebugData const> Parser::createDebugData() const
|
||||||
|
{
|
||||||
|
switch (m_useSourceLocationFrom)
|
||||||
|
{
|
||||||
|
case UseSourceLocationFrom::Scanner:
|
||||||
|
return DebugData::create(ParserBase::currentLocation());
|
||||||
|
case UseSourceLocationFrom::LocationOverride:
|
||||||
|
return DebugData::create(m_locationOverride);
|
||||||
|
case UseSourceLocationFrom::Comments:
|
||||||
|
return m_debugDataOverride;
|
||||||
|
}
|
||||||
|
solAssert(false, "");
|
||||||
|
}
|
||||||
|
|
||||||
unique_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
|
unique_ptr<Block> Parser::parse(std::shared_ptr<Scanner> const& _scanner, bool _reuseScanner)
|
||||||
{
|
{
|
||||||
m_recursionDepth = 0;
|
m_recursionDepth = 0;
|
||||||
|
@ -103,19 +103,7 @@ protected:
|
|||||||
void fetchSourceLocationFromComment();
|
void fetchSourceLocationFromComment();
|
||||||
|
|
||||||
/// Creates a DebugData object with the correct source location set.
|
/// Creates a DebugData object with the correct source location set.
|
||||||
std::shared_ptr<DebugData const> createDebugData() const
|
std::shared_ptr<DebugData const> createDebugData() const;
|
||||||
{
|
|
||||||
switch (m_useSourceLocationFrom)
|
|
||||||
{
|
|
||||||
case UseSourceLocationFrom::Scanner:
|
|
||||||
return DebugData::create(ParserBase::currentLocation());
|
|
||||||
case UseSourceLocationFrom::LocationOverride:
|
|
||||||
return DebugData::create(m_locationOverride);
|
|
||||||
case UseSourceLocationFrom::Comments:
|
|
||||||
return m_debugDataOverride;
|
|
||||||
}
|
|
||||||
solAssert(false, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates an inline assembly node with the current source location.
|
/// Creates an inline assembly node with the current source location.
|
||||||
template <class T> T createWithLocation() const
|
template <class T> T createWithLocation() const
|
||||||
|
Loading…
Reference in New Issue
Block a user