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 /libjulia | |
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 'libjulia')
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.cpp | 15 | ||||
-rw-r--r-- | libjulia/backends/evm/EVMCodeTransform.h | 11 |
2 files changed, 12 insertions, 14 deletions
diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp index 18c3e63c..355a9595 100644 --- a/libjulia/backends/evm/EVMCodeTransform.cpp +++ b/libjulia/backends/evm/EVMCodeTransform.cpp @@ -32,14 +32,14 @@ using namespace dev::solidity; using namespace dev::solidity::assembly; CodeTransform::CodeTransform( - ErrorList& _errors, + ErrorReporter& _errorReporter, AbstractAssembly& _assembly, Block const& _block, AsmAnalysisInfo& _analysisInfo, ExternalIdentifierAccess const& _identifierAccess, int _initialStackHeight ): - m_errors(_errors), + m_errorReporter(_errorReporter), m_assembly(_assembly), m_info(_analysisInfo), m_scope(*_analysisInfo.scopes.at(&_block)), @@ -91,11 +91,10 @@ int CodeTransform::variableHeightDiff(solidity::assembly::Scope::Variable const& if (heightDiff <= (_forSwap ? 1 : 0) || heightDiff > (_forSwap ? 17 : 16)) { //@TODO move this to analysis phase. - m_errors.push_back(make_shared<Error>( - Error::Type::TypeError, - "Variable inaccessible, too deep inside stack (" + boost::lexical_cast<string>(heightDiff) + ")", - _location - )); + m_errorReporter.typeError( + _location, + "Variable inaccessible, too deep inside stack (" + boost::lexical_cast<string>(heightDiff) + ")" + ); return 0; } else @@ -124,7 +123,7 @@ void CodeTransform::assignLabelIdIfUnset(Scope::Label& _label) void CodeTransform::operator()(Block const& _block) { - CodeTransform(m_errors, m_assembly, _block, m_info, m_identifierAccess, m_initialStackHeight); + CodeTransform(m_errorReporter, m_assembly, _block, m_info, m_identifierAccess, m_initialStackHeight); checkStackHeight(&_block); } diff --git a/libjulia/backends/evm/EVMCodeTransform.h b/libjulia/backends/evm/EVMCodeTransform.h index 5408a3aa..64e76246 100644 --- a/libjulia/backends/evm/EVMCodeTransform.h +++ b/libjulia/backends/evm/EVMCodeTransform.h @@ -20,8 +20,6 @@ #include <libjulia/backends/evm/AbstractAssembly.h> -#include <libsolidity/interface/Exceptions.h> - #include <libsolidity/inlineasm/AsmStack.h> #include <libsolidity/inlineasm/AsmScope.h> @@ -31,6 +29,7 @@ namespace dev { namespace solidity { +class ErrorReporter; namespace assembly { struct Literal; @@ -59,18 +58,18 @@ public: /// of its creation. /// @param _identifierAccess used to resolve identifiers external to the inline assembly CodeTransform( - solidity::ErrorList& _errors, + solidity::ErrorReporter& _errorReporter, julia::AbstractAssembly& _assembly, solidity::assembly::Block const& _block, solidity::assembly::AsmAnalysisInfo& _analysisInfo, ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess() - ): CodeTransform(_errors, _assembly, _block, _analysisInfo, _identifierAccess, _assembly.stackHeight()) + ): CodeTransform(_errorReporter, _assembly, _block, _analysisInfo, _identifierAccess, _assembly.stackHeight()) { } private: CodeTransform( - solidity::ErrorList& _errors, + solidity::ErrorReporter& _errorReporter, julia::AbstractAssembly& _assembly, solidity::assembly::Block const& _block, solidity::assembly::AsmAnalysisInfo& _analysisInfo, @@ -107,7 +106,7 @@ private: /// Assigns the label's id to a value taken from eth::Assembly if it has not yet been set. void assignLabelIdIfUnset(solidity::assembly::Scope::Label& _label); - solidity::ErrorList& m_errors; + solidity::ErrorReporter& m_errorReporter; julia::AbstractAssembly& m_assembly; solidity::assembly::AsmAnalysisInfo& m_info; solidity::assembly::Scope& m_scope; |