diff options
author | Christian <c@ethdev.com> | 2014-11-05 21:20:56 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-05 22:01:24 +0800 |
commit | c1f7a1665f17c5f9865534c7a26827cfbf6f3dd5 (patch) | |
tree | 758fd6ffa201c101c272e8d671697c65acf294b8 /NameAndTypeResolver.cpp | |
parent | 1de66d6e9ea5ad04f96247895a867be53e42da7c (diff) | |
download | dexon-solidity-c1f7a1665f17c5f9865534c7a26827cfbf6f3dd5.tar.gz dexon-solidity-c1f7a1665f17c5f9865534c7a26827cfbf6f3dd5.tar.zst dexon-solidity-c1f7a1665f17c5f9865534c7a26827cfbf6f3dd5.zip |
Converted all asserts to exceptions.
Diffstat (limited to 'NameAndTypeResolver.cpp')
-rw-r--r-- | NameAndTypeResolver.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index 4b77ed13..0578e599 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -20,7 +20,6 @@ * Parser part that determines the declarations corresponding to names and the types of expressions. */ -#include <cassert> #include <libsolidity/NameAndTypeResolver.h> #include <libsolidity/AST.h> #include <libsolidity/Exceptions.h> @@ -123,7 +122,8 @@ void DeclarationRegistrationHelper::endVisit(VariableDefinition& _variableDefini { // Register the local variables with the function // This does not fit here perfectly, but it saves us another AST visit. - assert(m_currentFunction); + if (asserts(m_currentFunction)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Variable definition without function.")); m_currentFunction->addLocalVariable(_variableDefinition.getDeclaration()); } @@ -138,19 +138,22 @@ void DeclarationRegistrationHelper::enterNewSubScope(ASTNode& _node) map<ASTNode const*, Scope>::iterator iter; bool newlyAdded; tie(iter, newlyAdded) = m_scopes.emplace(&_node, Scope(m_currentScope)); - assert(newlyAdded); + if (asserts(newlyAdded)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unable to add new scope.")); m_currentScope = &iter->second; } void DeclarationRegistrationHelper::closeCurrentScope() { - assert(m_currentScope); + if (asserts(m_currentScope)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Closed non-existing scope.")); m_currentScope = m_currentScope->getEnclosingScope(); } void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaration, bool _opensScope) { - assert(m_currentScope); + if (asserts(m_currentScope)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Declaration registered without scope.")); if (!m_currentScope->registerDeclaration(_declaration)) BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_sourceLocation(_declaration.getLocation()) << errinfo_comment("Identifier already declared.")); @@ -177,7 +180,8 @@ void ReferencesResolver::endVisit(VariableDeclaration& _variable) bool ReferencesResolver::visit(Return& _return) { - assert(m_returnParameters); + if (asserts(m_returnParameters)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Return parameters not set.")); _return.setFunctionReturnParameters(*m_returnParameters); return true; } |