mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[FIXUP] Clean up and fix syntax errors
This commit is contained in:
parent
e4ac0fcd96
commit
2b7488f2cd
@ -7,6 +7,7 @@ Language Features:
|
|||||||
Compiler Features:
|
Compiler Features:
|
||||||
* Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``.
|
* Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``.
|
||||||
* Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
|
* Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
|
||||||
|
* Commandline Interface: Use different colors when printing errors, warnings and infos.
|
||||||
* SMTChecker: Output values for ``block.*``, ``msg.*`` and ``tx.*`` variables that are present in the called functions.
|
* SMTChecker: Output values for ``block.*``, ``msg.*`` and ``tx.*`` variables that are present in the called functions.
|
||||||
* Standard JSON: Accept nested brackets in step sequences passed to ``settings.optimizer.details.yulDetails.optimizerSteps``.
|
* Standard JSON: Accept nested brackets in step sequences passed to ``settings.optimizer.details.yulDetails.optimizerSteps``.
|
||||||
* Standard JSON: Add ``settings.debug.debugInfo`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
|
* Standard JSON: Add ``settings.debug.debugInfo`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code.
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <liblangutil/Exceptions.h>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
using namespace solidity::langutil;
|
using namespace solidity::langutil;
|
||||||
@ -72,17 +75,14 @@ Error::Error(
|
|||||||
*this << util::errinfo_comment(_description);
|
*this << util::errinfo_comment(_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static optional<Severity> severityFromString(string _severity)
|
optional<Error::Severity> Error::severityFromString(string _input)
|
||||||
{
|
{
|
||||||
boost::algorithm::to_lower(_severity);
|
boost::algorithm::to_lower(_input);
|
||||||
|
boost::algorithm::trim(_input);
|
||||||
|
|
||||||
_severity = boost::algorithm::trim_copy(_severity);
|
for (Severity severity: {Severity::Error, Severity::Warning, Severity::Info})
|
||||||
|
if (_input == formatErrorSeverityLowercase(severity))
|
||||||
|
return severity;
|
||||||
|
|
||||||
if (_severity == formatErrorSeverityLowercase(Severity::Error)) { return Severity::Error; }
|
return nullopt;
|
||||||
|
|
||||||
else if (_severity == formatErrorSeverityLowercase(Severity::Warning)) { return Severity::Warning; }
|
|
||||||
|
|
||||||
else if (_severity == formatErrorSeverityLowercase(Severity::Info)) { return Severity::Info; }
|
|
||||||
|
|
||||||
else return std::make_optional<Severity>(_severity).has_value() ? std::optional<Severity>(_severity) : std::nullopt;
|
|
||||||
}
|
}
|
@ -111,6 +111,7 @@ struct InvalidAstError: virtual util::Exception {};
|
|||||||
"AST assertion failed" \
|
"AST assertion failed" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;
|
using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;
|
||||||
|
|
||||||
class SecondarySourceLocation
|
class SecondarySourceLocation
|
||||||
@ -205,8 +206,6 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<Severity> severityFromString(std::string _severity);
|
|
||||||
|
|
||||||
static Severity errorSeverity(Type _type)
|
static Severity errorSeverity(Type _type)
|
||||||
{
|
{
|
||||||
if (_type == Type::Info)
|
if (_type == Type::Info)
|
||||||
@ -259,6 +258,8 @@ public:
|
|||||||
solAssert(false, "");
|
solAssert(false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::optional<Severity> severityFromString(std::string _input);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ErrorId m_errorId;
|
ErrorId m_errorId;
|
||||||
Type m_type;
|
Type m_type;
|
||||||
|
@ -65,24 +65,21 @@ AnsiColorized SourceReferenceFormatter::frameColored() const
|
|||||||
return AnsiColorized(m_stream, m_colored, {BOLD, BLUE});
|
return AnsiColorized(m_stream, m_colored, {BOLD, BLUE});
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::errorColored() const
|
AnsiColorized SourceReferenceFormatter::errorColored(optional<Error::Severity> _severity) const
|
||||||
{
|
{
|
||||||
return AnsiColorized(m_stream, m_colored, {BOLD, RED});
|
// We used to color messages of any severity as errors so this seems like a good default
|
||||||
}
|
// for cases where severity cannot be determined.
|
||||||
|
char const* textColor = RED;
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::infoColored() const
|
if (_severity.has_value())
|
||||||
{
|
switch (_severity.value())
|
||||||
return AnsiColorized(m_stream, m_colored, {BOLD, WHITE});
|
{
|
||||||
}
|
case Error::Severity::Error: textColor = RED; break;
|
||||||
|
case Error::Severity::Warning: textColor = YELLOW; break;
|
||||||
|
case Error::Severity::Info: textColor = WHITE; break;
|
||||||
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::warningColored() const
|
return AnsiColorized(m_stream, m_colored, {BOLD, textColor});
|
||||||
{
|
|
||||||
return AnsiColorized(m_stream, m_colored, {BOLD, YELLOW});
|
|
||||||
}
|
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::unknownColored() const
|
|
||||||
{
|
|
||||||
return AnsiColorized(m_stream, m_colored, {BOLD, WHITE});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::messageColored() const
|
AnsiColorized SourceReferenceFormatter::messageColored() const
|
||||||
@ -179,22 +176,11 @@ void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref)
|
|||||||
void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)
|
void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)
|
||||||
{
|
{
|
||||||
// exception header line
|
// exception header line
|
||||||
if (_msg.errorId.has_value())
|
optional<Error::Severity> severity = Error::severityFromString(_msg.severity);
|
||||||
{
|
errorColored(severity) << _msg.severity;
|
||||||
switch(severityFromString(_msg.severity))
|
if (m_withErrorIds && _msg.errorId.has_value())
|
||||||
{
|
errorColored(severity) << " (" << _msg.errorId.value().error << ")";
|
||||||
case Severity::Error : errorColored() << " (" << _msg.errorId.value().error << ")";
|
messageColored() << ": " << _msg.primary.message << '\n';
|
||||||
break;
|
|
||||||
|
|
||||||
case Severity::Warning : warningColored() << " (" << _msg.errorId.value().error << ")";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Severity::Info : infoColored() << " (" << _msg.errorId.value().error << ")";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default : unknownColored() << " (" << _msg.errorId.value().error << ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printSourceLocation(_msg.primary);
|
printSourceLocation(_msg.primary);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
util::AnsiColorized normalColored() const;
|
util::AnsiColorized normalColored() const;
|
||||||
util::AnsiColorized frameColored() const;
|
util::AnsiColorized frameColored() const;
|
||||||
util::AnsiColorized errorColored() const;
|
util::AnsiColorized errorColored(std::optional<langutil::Error::Severity> _severity) const;
|
||||||
util::AnsiColorized messageColored() const;
|
util::AnsiColorized messageColored() const;
|
||||||
util::AnsiColorized secondaryColored() const;
|
util::AnsiColorized secondaryColored() const;
|
||||||
util::AnsiColorized highlightColored() const;
|
util::AnsiColorized highlightColored() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user