diff options
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/Assembly.cpp | 14 | ||||
-rw-r--r-- | test/libsolidity/SolidityExpressionCompiler.cpp | 10 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 25 | ||||
-rw-r--r-- | test/libsolidity/SolidityParser.cpp | 5 |
4 files changed, 31 insertions, 23 deletions
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 <libsolidity/codegen/Compiler.h> #include <libsolidity/ast/AST.h> #include <libsolidity/analysis/TypeChecker.h> +#include <libsolidity/interface/ErrorReporter.h> 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> sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(CharStream(_sourceCode)))); BOOST_CHECK(!!sourceUnit); map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; - NameAndTypeResolver resolver({}, scopes, errors); - solAssert(Error::containsOnlyWarnings(errors), ""); + NameAndTypeResolver resolver({}, scopes, errorReporter); + solAssert(Error::containsOnlyWarnings(errorReporter.errors()), ""); resolver.registerDeclarations(*sourceUnit); for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) { BOOST_REQUIRE_NO_THROW(resolver.resolveNamesAndTypes(*contract)); - if (!Error::containsOnlyWarnings(errors)) + if (!Error::containsOnlyWarnings(errorReporter.errors())) return AssemblyItems(); } for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(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<ASTNode> const& node: sourceUnit->nodes()) diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 3116aea8..58efa0a2 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -29,6 +29,7 @@ #include <libsolidity/codegen/ExpressionCompiler.h> #include <libsolidity/ast/AST.h> #include <libsolidity/analysis/TypeChecker.h> +#include <libsolidity/interface/ErrorReporter.h> #include "../TestHelper.h" using namespace std; @@ -98,7 +99,8 @@ bytes compileFirstExpression( try { ErrorList errors; - sourceUnit = Parser(errors).parse(make_shared<Scanner>(CharStream(_sourceCode))); + ErrorReporter errorReporter(errors); + sourceUnit = Parser(errorReporter).parse(make_shared<Scanner>(CharStream(_sourceCode))); if (!sourceUnit) return bytes(); } @@ -114,8 +116,9 @@ bytes compileFirstExpression( declarations.push_back(variable.get()); ErrorList errors; + ErrorReporter errorReporter(errors); map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; - NameAndTypeResolver resolver(declarations, scopes, errors); + NameAndTypeResolver resolver(declarations, scopes, errorReporter); resolver.registerDeclarations(*sourceUnit); vector<ContractDefinition const*> inheritanceHierarchy; @@ -128,7 +131,8 @@ bytes compileFirstExpression( for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) { - TypeChecker typeChecker(errors); + ErrorReporter errorReporter(errors); + TypeChecker typeChecker(errorReporter); BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract)); } for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 97c4303f..0553c691 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -30,7 +30,7 @@ #include <libsolidity/analysis/StaticAnalyzer.h> #include <libsolidity/analysis/PostTypeChecker.h> #include <libsolidity/analysis/SyntaxChecker.h> -#include <libsolidity/interface/Exceptions.h> +#include <libsolidity/interface/ErrorReporter.h> #include <libsolidity/analysis/GlobalContext.h> #include <libsolidity/analysis/TypeChecker.h> @@ -56,7 +56,8 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, // Silence compiler version warning string source = _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source; ErrorList errors; - Parser parser(errors); + ErrorReporter errorReporter(errors); + Parser parser(errorReporter); ASTPointer<SourceUnit> sourceUnit; // catch exceptions for a transition period try @@ -65,14 +66,14 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, if(!sourceUnit) BOOST_FAIL("Parsing failed in type checker test."); - SyntaxChecker syntaxChecker(errors); + SyntaxChecker syntaxChecker(errorReporter); if (!syntaxChecker.checkSyntax(*sourceUnit)) - return make_pair(sourceUnit, errors.at(0)); + return make_pair(sourceUnit, errorReporter.errors().at(0)); std::shared_ptr<GlobalContext> globalContext = make_shared<GlobalContext>(); map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; - NameAndTypeResolver resolver(globalContext->declarations(), scopes, errors); - solAssert(Error::containsOnlyWarnings(errors), ""); + NameAndTypeResolver resolver(globalContext->declarations(), scopes, errorReporter); + solAssert(Error::containsOnlyWarnings(errorReporter.errors()), ""); resolver.registerDeclarations(*sourceUnit); bool success = true; @@ -92,19 +93,19 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, globalContext->setCurrentContract(*contract); resolver.updateDeclaration(*globalContext->currentThis()); - TypeChecker typeChecker(errors); + TypeChecker typeChecker(errorReporter); bool success = typeChecker.checkTypeRequirements(*contract); - BOOST_CHECK(success || !errors.empty()); + BOOST_CHECK(success || !errorReporter.errors().empty()); } if (success) - if (!PostTypeChecker(errors).check(*sourceUnit)) + if (!PostTypeChecker(errorReporter).check(*sourceUnit)) success = false; if (success) - if (!StaticAnalyzer(errors).analyze(*sourceUnit)) + if (!StaticAnalyzer(errorReporter).analyze(*sourceUnit)) success = false; - if (errors.size() > 1 && !_allowMultipleErrors) + if (errorReporter.errors().size() > 1 && !_allowMultipleErrors) BOOST_FAIL("Multiple errors found"); - for (auto const& currentError: errors) + for (auto const& currentError: errorReporter.errors()) { if ( (_reportWarnings && currentError->type() == Error::Type::Warning) || diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 6e33aba5..31dfada9 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -24,7 +24,7 @@ #include <memory> #include <libsolidity/parsing/Scanner.h> #include <libsolidity/parsing/Parser.h> -#include <libsolidity/interface/Exceptions.h> +#include <libsolidity/interface/ErrorReporter.h> #include "../TestHelper.h" #include "ErrorCheck.h" @@ -41,7 +41,8 @@ namespace { ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList& _errors) { - ASTPointer<SourceUnit> sourceUnit = Parser(_errors).parse(std::make_shared<Scanner>(CharStream(_source))); + ErrorReporter errorReporter(_errors); + ASTPointer<SourceUnit> sourceUnit = Parser(errorReporter).parse(std::make_shared<Scanner>(CharStream(_source))); if (!sourceUnit) return ASTPointer<ContractDefinition>(); for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) |