diff options
author | Rhett Aultman <roadriverrail@gmail.com> | 2017-05-11 21:26:35 +0800 |
---|---|---|
committer | Rhett Aultman <roadriverrail@gmail.com> | 2017-05-30 22:28:31 +0800 |
commit | 89b60ffbd4c2dde26fa5e9f1d750729b5c89373e (patch) | |
tree | a4c464d4d40baaa260f071c1028f347bd287e44d /libsolidity/interface/CompilerStack.h | |
parent | 0066a08aa8f6c469cde7947ec50ca662a32123a0 (diff) | |
download | dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.tar.gz dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.tar.zst dexon-solidity-89b60ffbd4c2dde26fa5e9f1d750729b5c89373e.zip |
Refactor error reporting
This commit introduces ErrorReporter, a utility class which consolidates
all of the error logging functionality into a common set of functions.
It also replaces all direct interactions with an ErrorList with calls to
an ErrorReporter.
This commit resolves issue #2209
Diffstat (limited to 'libsolidity/interface/CompilerStack.h')
-rw-r--r-- | libsolidity/interface/CompilerStack.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index 84d15d70..76d36c7b 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -35,7 +35,7 @@ #include <libdevcore/FixedHash.h> #include <libevmasm/SourceLocation.h> #include <libevmasm/LinkerObject.h> -#include <libsolidity/interface/Exceptions.h> +#include <libsolidity/interface/ErrorReporter.h> #include <libsolidity/interface/ReadFile.h> namespace dev @@ -80,7 +80,10 @@ public: /// Creates a new compiler stack. /// @param _readFile callback to used to read files for import statements. Must return /// and must not emit exceptions. - explicit CompilerStack(ReadFile::Callback const& _readFile = ReadFile::Callback()); + explicit CompilerStack(ReadFile::Callback const& _readFile = ReadFile::Callback()): + m_readFile(_readFile), + m_errorList(), + m_errorReporter(m_errorList) {} /// Sets path remappings in the format "context:prefix=target" void setRemappings(std::vector<std::string> const& _remappings); @@ -130,7 +133,7 @@ public: /// Tries to translate all source files into a language suitable for formal analysis. /// @param _errors list to store errors - defaults to the internal error list. /// @returns false on error. - bool prepareFormalAnalysis(ErrorList* _errors = nullptr); + bool prepareFormalAnalysis(ErrorReporter* _errorReporter = nullptr); std::string const& formalTranslation() const { return m_formalTranslation; } /// @returns the assembled object for a contract. @@ -207,7 +210,7 @@ public: std::tuple<int, int, int, int> positionFromSourceLocation(SourceLocation const& _sourceLocation) const; /// @returns the list of errors that occured during parsing and type checking. - ErrorList const& errors() const { return m_errors; } + ErrorList const& errors() { return m_errorReporter.errors(); } private: /** @@ -289,7 +292,8 @@ private: std::vector<Source const*> m_sourceOrder; std::map<std::string const, Contract> m_contracts; std::string m_formalTranslation; - ErrorList m_errors; + ErrorList m_errorList; + ErrorReporter m_errorReporter; bool m_metadataLiteralSources = false; State m_stackState = Empty; }; |