From d60d4b3031001a188b2449c97e2d617d98c77f0e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 25 Aug 2017 15:37:10 +0100 Subject: Remove duplicate work from CompilerStack.analyze() --- libsolidity/interface/CompilerStack.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 363f45dd..5837c642 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -201,8 +201,6 @@ bool CompilerStack::analyze() for (ASTPointer const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - m_globalContext->setCurrentContract(*contract); - resolver.updateDeclaration(*m_globalContext->currentThis()); TypeChecker typeChecker(m_errorReporter); if (typeChecker.checkTypeRequirements(*contract)) { @@ -211,14 +209,6 @@ bool CompilerStack::analyze() } else noErrors = false; - - // Note that we now reference contracts by their fully qualified names, and - // thus contracts can only conflict if declared in the same source file. This - // already causes a double-declaration error elsewhere, so we do not report - // an error here and instead silently drop any additional contracts we find. - - if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end()) - m_contracts[contract->fullyQualifiedName()].contract = contract; } if (noErrors) -- cgit From 670df8e874662901fe16b6c1995c5eeadf1283a1 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 25 Aug 2017 15:39:20 +0100 Subject: Attach natspec before type checking --- libsolidity/interface/CompilerStack.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 5837c642..1f6fd12f 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -188,6 +188,9 @@ bool CompilerStack::analyze() if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false; if (!resolver.resolveNamesAndTypes(*contract)) return false; + contract->setDevDocumentation(Natspec::devDocumentation(*contract)); + contract->setUserDocumentation(Natspec::userDocumentation(*contract)); + // Note that we now reference contracts by their fully qualified names, and // thus contracts can only conflict if declared in the same source file. This // already causes a double-declaration error elsewhere, so we do not report @@ -202,12 +205,7 @@ bool CompilerStack::analyze() if (ContractDefinition* contract = dynamic_cast(node.get())) { TypeChecker typeChecker(m_errorReporter); - if (typeChecker.checkTypeRequirements(*contract)) - { - contract->setDevDocumentation(Natspec::devDocumentation(*contract)); - contract->setUserDocumentation(Natspec::userDocumentation(*contract)); - } - else + if (!typeChecker.checkTypeRequirements(*contract)) noErrors = false; } -- cgit From e6f55fb95e913a5167ebd1f43a0eebb8b6d17daf Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 25 Aug 2017 15:43:26 +0100 Subject: Do not create a new TypeChecker instance for every contract --- libsolidity/interface/CompilerStack.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 1f6fd12f..7e4518b9 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -200,14 +200,12 @@ bool CompilerStack::analyze() m_contracts[contract->fullyQualifiedName()].contract = contract; } + TypeChecker typeChecker(m_errorReporter); for (Source const* source: m_sourceOrder) for (ASTPointer const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) - { - TypeChecker typeChecker(m_errorReporter); if (!typeChecker.checkTypeRequirements(*contract)) noErrors = false; - } if (noErrors) { -- cgit From 8bc76ecf58b3e57ccfbc69da5e9633bae490ca92 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 25 Aug 2017 15:49:33 +0100 Subject: Update SolidityNameAndTypeResolution to match CompilerStack --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 380978e8..9333b62d 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -87,16 +87,15 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, success = false; } if (success) + { + TypeChecker typeChecker(errorReporter); for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - globalContext->setCurrentContract(*contract); - resolver.updateDeclaration(*globalContext->currentThis()); - - TypeChecker typeChecker(errorReporter); bool success = typeChecker.checkTypeRequirements(*contract); BOOST_CHECK(success || !errorReporter.errors().empty()); } + } if (success) if (!PostTypeChecker(errorReporter).check(*sourceUnit)) success = false; -- cgit