diff options
author | chriseth <chris@ethereum.org> | 2017-09-21 22:56:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-21 22:56:16 +0800 |
commit | bdeb9e52a2211510644fb53df93fb98258b40a65 (patch) | |
tree | d8fb917e7dc27b937cb4505029bbc3c8c1bc1a67 /libsolidity/interface/CompilerStack.cpp | |
parent | d7661dd97460250b4e1127b9e7ea91e116143780 (diff) | |
parent | a14fc5ffa1f03d5aa312396a39633d720b04c90a (diff) | |
download | dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.gz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.bz2 dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.lz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.xz dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.tar.zst dexon-solidity-bdeb9e52a2211510644fb53df93fb98258b40a65.zip |
Merge pull request #2947 from ethereum/develop
Merge develop into release for 0.4.17.
Diffstat (limited to 'libsolidity/interface/CompilerStack.cpp')
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 363f45dd..51544f8a 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -36,6 +36,7 @@ #include <libsolidity/analysis/StaticAnalyzer.h> #include <libsolidity/analysis/PostTypeChecker.h> #include <libsolidity/analysis/SyntaxChecker.h> +#include <libsolidity/analysis/ViewPureChecker.h> #include <libsolidity/codegen/Compiler.h> #include <libsolidity/formal/SMTChecker.h> #include <libsolidity/interface/ABI.h> @@ -197,30 +198,13 @@ bool CompilerStack::analyze() m_contracts[contract->fullyQualifiedName()].contract = contract; } + TypeChecker typeChecker(m_errorReporter); for (Source const* source: m_sourceOrder) for (ASTPointer<ASTNode> const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) - { - m_globalContext->setCurrentContract(*contract); - resolver.updateDeclaration(*m_globalContext->currentThis()); - 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; - // 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) { PostTypeChecker postTypeChecker(m_errorReporter); @@ -239,6 +223,16 @@ bool CompilerStack::analyze() if (noErrors) { + vector<ASTPointer<ASTNode>> 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); for (Source const* source: m_sourceOrder) smtChecker.analyze(*source->ast); @@ -364,16 +358,24 @@ 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 +/// FIXME: cache this string +string CompilerStack::assemblyString(string const& _contractName, StringMap _sourceCodes) const { Contract const& currentContract = contract(_contractName); if (currentContract.compiler) - return currentContract.compiler->streamAssembly(_outStream, _sourceCodes, _inJsonFormat); + return currentContract.compiler->assemblyString(_sourceCodes); + else + return string(); +} + +/// 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 - { - _outStream << "Contract not fully implemented" << endl; return Json::Value(); - } } vector<string> CompilerStack::sourceNames() const |