From 89b60ffbd4c2dde26fa5e9f1d750729b5c89373e Mon Sep 17 00:00:00 2001 From: Rhett Aultman Date: Thu, 11 May 2017 06:26:35 -0700 Subject: 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 --- libjulia/backends/evm/EVMCodeTransform.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libjulia/backends/evm/EVMCodeTransform.cpp') 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::Type::TypeError, - "Variable inaccessible, too deep inside stack (" + boost::lexical_cast(heightDiff) + ")", - _location - )); + m_errorReporter.typeError( + _location, + "Variable inaccessible, too deep inside stack (" + boost::lexical_cast(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); } -- cgit