From 87821c53c3a73d3e35a0e50a7c159d9aa5d6b253 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 14 Nov 2018 14:59:30 +0100 Subject: Isolating files shared between Yul- and Solidity language frontend. --- libsolidity/interface/SourceReferenceFormatter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libsolidity/interface/SourceReferenceFormatter.h') diff --git a/libsolidity/interface/SourceReferenceFormatter.h b/libsolidity/interface/SourceReferenceFormatter.h index a32babdc..281a4bdc 100644 --- a/libsolidity/interface/SourceReferenceFormatter.h +++ b/libsolidity/interface/SourceReferenceFormatter.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace dev { -- cgit v1.2.3 From d67322a1861d60a88151f7c25d6c3478a9a39acf Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 14 Nov 2018 17:11:55 +0100 Subject: Introduce namespace `langutil` in liblangutil directory. Also: - Use {}-style list initialisation for SourceLocation construction - Introduce new system includes - Changes the API of the Scanner to take source as value (with move) as opposed to as a reference --- libsolidity/interface/SourceReferenceFormatter.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'libsolidity/interface/SourceReferenceFormatter.h') diff --git a/libsolidity/interface/SourceReferenceFormatter.h b/libsolidity/interface/SourceReferenceFormatter.h index 281a4bdc..7dea5254 100644 --- a/libsolidity/interface/SourceReferenceFormatter.h +++ b/libsolidity/interface/SourceReferenceFormatter.h @@ -25,7 +25,12 @@ #include #include #include -#include + +namespace langutil +{ +struct SourceLocation; +class Scanner; +} namespace dev { @@ -35,13 +40,12 @@ struct Exception; // forward namespace solidity { -class Scanner; // forward class CompilerStack; // forward class SourceReferenceFormatter { public: - using ScannerFromSourceNameFun = std::function; + using ScannerFromSourceNameFun = std::function; explicit SourceReferenceFormatter( std::ostream& _stream, @@ -52,7 +56,7 @@ public: {} /// Prints source location if it is given. - void printSourceLocation(SourceLocation const* _location); + void printSourceLocation(langutil::SourceLocation const* _location); void printExceptionInformation(Exception const& _exception, std::string const& _name); static std::string formatExceptionInformation( @@ -69,7 +73,7 @@ public: } private: /// Prints source name if location is given. - void printSourceName(SourceLocation const* _location); + void printSourceName(langutil::SourceLocation const* _location); std::ostream& m_stream; ScannerFromSourceNameFun m_scannerFromSourceName; -- cgit v1.2.3 From aeb66905de3f65ca7a63addb6c9d05108986dbeb Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Sat, 24 Nov 2018 12:33:36 +0100 Subject: Moving SourceReferenceFormatter into langutil namespace. --- libsolidity/interface/SourceReferenceFormatter.h | 83 ------------------------ 1 file changed, 83 deletions(-) delete mode 100644 libsolidity/interface/SourceReferenceFormatter.h (limited to 'libsolidity/interface/SourceReferenceFormatter.h') diff --git a/libsolidity/interface/SourceReferenceFormatter.h b/libsolidity/interface/SourceReferenceFormatter.h deleted file mode 100644 index 7dea5254..00000000 --- a/libsolidity/interface/SourceReferenceFormatter.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** - * @author Christian - * @date 2014 - * Formatting functions for errors referencing positions and locations in the source. - */ - -#pragma once - -#include -#include -#include - -namespace langutil -{ -struct SourceLocation; -class Scanner; -} - -namespace dev -{ - -struct Exception; // forward - -namespace solidity -{ - -class CompilerStack; // forward - -class SourceReferenceFormatter -{ -public: - using ScannerFromSourceNameFun = std::function; - - explicit SourceReferenceFormatter( - std::ostream& _stream, - ScannerFromSourceNameFun _scannerFromSourceName - ): - m_stream(_stream), - m_scannerFromSourceName(std::move(_scannerFromSourceName)) - {} - - /// Prints source location if it is given. - void printSourceLocation(langutil::SourceLocation const* _location); - void printExceptionInformation(Exception const& _exception, std::string const& _name); - - static std::string formatExceptionInformation( - Exception const& _exception, - std::string const& _name, - ScannerFromSourceNameFun const& _scannerFromSourceName - ) - { - std::ostringstream errorOutput; - - SourceReferenceFormatter formatter(errorOutput, _scannerFromSourceName); - formatter.printExceptionInformation(_exception, _name); - return errorOutput.str(); - } -private: - /// Prints source name if location is given. - void printSourceName(langutil::SourceLocation const* _location); - - std::ostream& m_stream; - ScannerFromSourceNameFun m_scannerFromSourceName; -}; - -} -} -- cgit v1.2.3