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 --- test/libsolidity/Assembly.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'test/libsolidity/Assembly.cpp') diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index c4ec0d20..e52f4d50 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -31,6 +31,7 @@ #include #include #include +#include using namespace std; using namespace dev::eth; @@ -48,28 +49,29 @@ namespace eth::AssemblyItems compileContract(const string& _sourceCode) { ErrorList errors; - Parser parser(errors); + ErrorReporter errorReporter(errors); + Parser parser(errorReporter); ASTPointer sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); BOOST_CHECK(!!sourceUnit); map> scopes; - NameAndTypeResolver resolver({}, scopes, errors); - solAssert(Error::containsOnlyWarnings(errors), ""); + NameAndTypeResolver resolver({}, scopes, errorReporter); + solAssert(Error::containsOnlyWarnings(errorReporter.errors()), ""); resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract)); - if (!Error::containsOnlyWarnings(errors)) + if (!Error::containsOnlyWarnings(errorReporter.errors())) return AssemblyItems(); } for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - TypeChecker checker(errors); + TypeChecker checker(errorReporter); BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract)); - if (!Error::containsOnlyWarnings(errors)) + if (!Error::containsOnlyWarnings(errorReporter.errors())) return AssemblyItems(); } for (ASTPointer const& node: sourceUnit->nodes()) -- cgit