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(-) (limited to 'libsolidity/interface/CompilerStack.cpp') 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 v1.2.3 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(-) (limited to 'libsolidity/interface/CompilerStack.cpp') 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 v1.2.3 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(-) (limited to 'libsolidity/interface/CompilerStack.cpp') 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 v1.2.3 From 8e5f9c59814f7e8b3b390965b17d9b867d36d544 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 25 Aug 2017 20:29:43 +0100 Subject: Removed unused natspec members of ContractDefinition --- libsolidity/interface/CompilerStack.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'libsolidity/interface/CompilerStack.cpp') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 7e4518b9..259694da 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -188,9 +188,6 @@ 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 -- cgit v1.2.3 From 5470da4d9adc8ef07aa1c2a758b7062be843cca4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 28 Aug 2017 19:48:34 +0200 Subject: View-pure checker. --- libsolidity/interface/CompilerStack.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libsolidity/interface/CompilerStack.cpp') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 259694da..99ad061c 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -220,6 +221,16 @@ bool CompilerStack::analyze() noErrors = false; } + if (noErrors) + { + vector> ast; + for (Source const* source: m_sourceOrder) + ast.push_back(source->ast); + + if (!ViewPureChecker(ast, m_errorReporter).check()) + noErrors = false; + } + if (noErrors) { SMTChecker smtChecker(m_errorReporter, m_smtQuery); -- cgit v1.2.3 From a535a8b06ed1b9c0c5fd41805a4fe39939755f05 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 15 Jun 2017 10:22:47 +0100 Subject: Split out the JSON functionality from assembly.stream() --- libsolidity/interface/CompilerStack.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'libsolidity/interface/CompilerStack.cpp') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 259694da..4002bac3 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -347,18 +347,28 @@ eth::LinkerObject const& CompilerStack::cloneObject(string const& _contractName) return contract(_contractName).cloneObject; } -Json::Value CompilerStack::streamAssembly(ostream& _outStream, string const& _contractName, StringMap _sourceCodes, bool _inJsonFormat) const +ostream& CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const { Contract const& currentContract = contract(_contractName); if (currentContract.compiler) - return currentContract.compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); + return currentContract.compiler->assemblyStream(_outStream, _sourceCodes); else { _outStream << "Contract not fully implemented" << endl; - return Json::Value(); + return _outStream; } } +/// FIXME: cache the JSON +Json::Value CompilerStack::assemblyJSON(string const& _contractName, StringMap _sourceCodes) const +{ + Contract const& currentContract = contract(_contractName); + if (currentContract.compiler) + return currentContract.compiler->assemblyJSON(_sourceCodes); + else + return Json::Value(); +} + vector CompilerStack::sourceNames() const { vector names; -- cgit v1.2.3 From 50570c6c794eee01af64751c884fb6cb68f8dffc Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 30 Aug 2017 01:58:19 +0100 Subject: Do not return the stream in asssemblyStream --- libsolidity/interface/CompilerStack.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libsolidity/interface/CompilerStack.cpp') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 4002bac3..5f62bb03 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -347,15 +347,14 @@ eth::LinkerObject const& CompilerStack::cloneObject(string const& _contractName) return contract(_contractName).cloneObject; } -ostream& CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const +void CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const { Contract const& currentContract = contract(_contractName); if (currentContract.compiler) - return currentContract.compiler->assemblyStream(_outStream, _sourceCodes); + currentContract.compiler->assemblyStream(_outStream, _sourceCodes); else { _outStream << "Contract not fully implemented" << endl; - return _outStream; } } -- cgit v1.2.3 From bbfb16cf5ce903150bc3a141ac50553d8bf6d346 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 30 Aug 2017 02:17:15 +0100 Subject: Introduce assemblyString --- libsolidity/interface/CompilerStack.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'libsolidity/interface/CompilerStack.cpp') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 5f62bb03..41bbf687 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -347,15 +347,14 @@ eth::LinkerObject const& CompilerStack::cloneObject(string const& _contractName) return contract(_contractName).cloneObject; } -void CompilerStack::assemblyStream(ostream& _outStream, string const& _contractName, StringMap _sourceCodes) const +/// FIXME: cache this string +string CompilerStack::assemblyString(string const& _contractName, StringMap _sourceCodes) const { Contract const& currentContract = contract(_contractName); if (currentContract.compiler) - currentContract.compiler->assemblyStream(_outStream, _sourceCodes); + return currentContract.compiler->assemblyString(_sourceCodes); else - { - _outStream << "Contract not fully implemented" << endl; - } + return string(); } /// FIXME: cache the JSON -- cgit v1.2.3