mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Convert static SourceReferenceFormatter functions to member ones
This commit is contained in:
@@ -38,22 +38,23 @@ namespace solidity
|
||||
class Scanner; // forward
|
||||
class CompilerStack; // forward
|
||||
|
||||
struct SourceReferenceFormatter
|
||||
class SourceReferenceFormatter
|
||||
{
|
||||
public:
|
||||
using ScannerFromSourceNameFun = std::function<Scanner const&(std::string const&)>;
|
||||
|
||||
explicit SourceReferenceFormatter(
|
||||
std::ostream& _stream,
|
||||
ScannerFromSourceNameFun const& _scannerFromSourceName
|
||||
):
|
||||
m_stream(_stream),
|
||||
m_scannerFromSourceName(_scannerFromSourceName)
|
||||
{}
|
||||
|
||||
/// Prints source location if it is given.
|
||||
static void printSourceLocation(
|
||||
std::ostream& _stream,
|
||||
SourceLocation const* _location,
|
||||
ScannerFromSourceNameFun const& _scannerFromSourceName
|
||||
);
|
||||
static void printExceptionInformation(
|
||||
std::ostream& _stream,
|
||||
Exception const& _exception,
|
||||
std::string const& _name,
|
||||
ScannerFromSourceNameFun const& _scannerFromSourceName
|
||||
);
|
||||
void printSourceLocation(SourceLocation const* _location);
|
||||
void printExceptionInformation(Exception const& _exception, std::string const& _name);
|
||||
|
||||
static std::string formatExceptionInformation(
|
||||
Exception const& _exception,
|
||||
std::string const& _name,
|
||||
@@ -61,16 +62,17 @@ public:
|
||||
)
|
||||
{
|
||||
std::ostringstream errorOutput;
|
||||
printExceptionInformation(errorOutput, _exception, _name, _scannerFromSourceName);
|
||||
|
||||
SourceReferenceFormatter formatter(errorOutput, _scannerFromSourceName);
|
||||
formatter.printExceptionInformation(_exception, _name);
|
||||
return errorOutput.str();
|
||||
}
|
||||
private:
|
||||
/// Prints source name if location is given.
|
||||
static void printSourceName(
|
||||
std::ostream& _stream,
|
||||
SourceLocation const* _location,
|
||||
ScannerFromSourceNameFun const& _scannerFromSourceName
|
||||
);
|
||||
void printSourceName(SourceLocation const* _location);
|
||||
|
||||
std::ostream& m_stream;
|
||||
ScannerFromSourceNameFun const& m_scannerFromSourceName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user