mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user