diff options
author | Christian <c@ethdev.com> | 2014-10-25 00:32:15 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-25 01:40:47 +0800 |
commit | 58be273506bf30619952eedf4c469879050c05ed (patch) | |
tree | 4d9767dbe624d552f89a8cc1b8c48c54d21feb18 | |
parent | 9141725cf238c028dd00f4a7f814878031ef48a0 (diff) | |
download | dexon-solidity-58be273506bf30619952eedf4c469879050c05ed.tar.gz dexon-solidity-58be273506bf30619952eedf4c469879050c05ed.tar.zst dexon-solidity-58be273506bf30619952eedf4c469879050c05ed.zip |
Replace BOOST_ASSERT by assert.
-rw-r--r-- | AST.cpp | 16 | ||||
-rw-r--r-- | NameAndTypeResolver.cpp | 11 | ||||
-rw-r--r-- | Scanner.cpp | 16 | ||||
-rw-r--r-- | Scanner.h | 2 | ||||
-rw-r--r-- | Token.h | 19 | ||||
-rw-r--r-- | Types.cpp | 7 | ||||
-rw-r--r-- | Types.h | 1 |
7 files changed, 34 insertions, 38 deletions
@@ -291,7 +291,7 @@ void Break::checkTypeRequirements() void Return::checkTypeRequirements() { - BOOST_ASSERT(m_returnParameters); + assert(m_returnParameters); if (m_returnParameters->getParameters().size() != 1) BOOST_THROW_EXCEPTION(createTypeError("Different number of arguments in return statement " "than in returns declaration.")); @@ -357,7 +357,7 @@ void BinaryOperation::checkTypeRequirements() m_type = std::make_shared<BoolType>(); else { - BOOST_ASSERT(Token::isBinaryOp(m_operator)); + assert(Token::isBinaryOp(m_operator)); m_type = m_commonType; if (!m_commonType->acceptsBinaryOperator(m_operator)) BOOST_THROW_EXCEPTION(createTypeError("Operator not compatible with type.")); @@ -374,7 +374,7 @@ void FunctionCall::checkTypeRequirements() if (isTypeConversion()) { TypeType const* type = dynamic_cast<TypeType const*>(expressionType); - BOOST_ASSERT(type); + assert(type); //@todo for structs, we have to check the number of arguments to be equal to the // number of non-mapping members if (m_arguments.size() != 1) @@ -390,7 +390,7 @@ void FunctionCall::checkTypeRequirements() // and then ask if that is implicitly convertible to the struct represented by the // function parameters FunctionType const* function = dynamic_cast<FunctionType const*>(expressionType); - BOOST_ASSERT(function); + assert(function); FunctionDefinition const& fun = function->getFunction(); std::vector<ASTPointer<VariableDeclaration>> const& parameters = fun.getParameters(); if (parameters.size() != m_arguments.size()) @@ -414,19 +414,19 @@ bool FunctionCall::isTypeConversion() const void MemberAccess::checkTypeRequirements() { - BOOST_ASSERT(false); // not yet implemented + assert(false); // not yet implemented // m_type = ; } void IndexAccess::checkTypeRequirements() { - BOOST_ASSERT(false); // not yet implemented + assert(false); // not yet implemented // m_type = ; } void Identifier::checkTypeRequirements() { - BOOST_ASSERT(m_referencedDeclaration); + assert(m_referencedDeclaration); //@todo these dynamic casts here are not really nice... // is i useful to have an AST visitor here? // or can this already be done in NameAndTypeResolver? @@ -467,7 +467,7 @@ void Identifier::checkTypeRequirements() m_type = std::make_shared<TypeType>(std::make_shared<ContractType>(*contractDef)); return; } - BOOST_ASSERT(false); // declaration reference of unknown/forbidden type + assert(false); // declaration reference of unknown/forbidden type } void ElementaryTypeNameExpression::checkTypeRequirements() diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index 0f34eb4c..edd946df 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -20,11 +20,10 @@ * 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> -#include <boost/assert.hpp> namespace dev { @@ -123,19 +122,19 @@ void DeclarationRegistrationHelper::enterNewSubScope(ASTNode& _node) std::map<ASTNode*, Scope>::iterator iter; bool newlyAdded; std::tie(iter, newlyAdded) = m_scopes.emplace(&_node, Scope(m_currentScope)); - BOOST_ASSERT(newlyAdded); + assert(newlyAdded); m_currentScope = &iter->second; } void DeclarationRegistrationHelper::closeCurrentScope() { - BOOST_ASSERT(m_currentScope); + assert(m_currentScope); m_currentScope = m_currentScope->getEnclosingScope(); } void DeclarationRegistrationHelper::registerDeclaration(Declaration& _declaration, bool _opensScope) { - BOOST_ASSERT(m_currentScope); + assert(m_currentScope); if (!m_currentScope->registerDeclaration(_declaration)) BOOST_THROW_EXCEPTION(DeclarationError() << errinfo_sourceLocation(_declaration.getLocation()) << errinfo_comment("Identifier already declared.")); @@ -162,7 +161,7 @@ void ReferencesResolver::endVisit(VariableDeclaration& _variable) bool ReferencesResolver::visit(Return& _return) { - BOOST_ASSERT(m_returnParameters); + assert(m_returnParameters); _return.setFunctionReturnParameters(*m_returnParameters); return true; } diff --git a/Scanner.cpp b/Scanner.cpp index 35da248a..64905435 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -50,9 +50,9 @@ * Solidity scanner. */ +#include <cassert> #include <algorithm> #include <tuple> - #include <libsolidity/Scanner.h> namespace dev @@ -118,7 +118,7 @@ void Scanner::reset(CharStream const& _source) bool Scanner::scanHexNumber(char& o_scannedNumber, int _expectedLength) { - BOOST_ASSERT(_expectedLength <= 4); // prevent overflow + assert(_expectedLength <= 4); // prevent overflow char x = 0; for (int i = 0; i < _expectedLength; i++) { @@ -178,7 +178,7 @@ Token::Value Scanner::skipSingleLineComment() Token::Value Scanner::skipMultiLineComment() { - BOOST_ASSERT(m_char == '*'); + assert(m_char == '*'); advance(); while (!isSourcePastEndOfInput()) { @@ -471,7 +471,7 @@ void Scanner::scanDecimalDigits() Token::Value Scanner::scanNumber(bool _periodSeen) { - BOOST_ASSERT(IsDecimalDigit(m_char)); // the first digit of the number or the fraction + assert(IsDecimalDigit(m_char)); // the first digit of the number or the fraction enum { DECIMAL, HEX, OCTAL, IMPLICIT_OCTAL, BINARY } kind = DECIMAL; LiteralScope literal(this); if (_periodSeen) @@ -513,7 +513,7 @@ Token::Value Scanner::scanNumber(bool _periodSeen) // scan exponent, if any if (m_char == 'e' || m_char == 'E') { - BOOST_ASSERT(kind != HEX); // 'e'/'E' must be scanned as part of the hex number + assert(kind != HEX); // 'e'/'E' must be scanned as part of the hex number if (kind != DECIMAL) return Token::ILLEGAL; // scan exponent addLiteralCharAndAdvance(); @@ -609,7 +609,7 @@ Token::Value Scanner::scanNumber(bool _periodSeen) static Token::Value KeywordOrIdentifierToken(std::string const& input) { - BOOST_ASSERT(!input.empty()); + assert(!input.empty()); int const kMinLength = 2; int const kMaxLength = 10; if (input.size() < kMinLength || input.size() > kMaxLength) @@ -637,7 +637,7 @@ case ch: Token::Value Scanner::scanIdentifierOrKeyword() { - BOOST_ASSERT(IsIdentifierStart(m_char)); + assert(IsIdentifierStart(m_char)); LiteralScope literal(this); addLiteralCharAndAdvance(); // Scan the rest of the identifier characters. @@ -659,7 +659,7 @@ char CharStream::advanceAndGet() char CharStream::rollback(size_t _amount) { - BOOST_ASSERT(m_pos >= _amount); + assert(m_pos >= _amount); m_pos -= _amount; return get(); } @@ -52,8 +52,6 @@ #pragma once -#include <boost/assert.hpp> - #include <libdevcore/Common.h> #include <libdevcore/Log.h> #include <libdevcore/CommonData.h> @@ -42,8 +42,7 @@ #pragma once -#include <boost/assert.hpp> - +#include <cassert> #include <libdevcore/Common.h> #include <libdevcore/Log.h> @@ -225,7 +224,7 @@ public: // (e.g. "LT" for the token LT). static char const* getName(Value tok) { - BOOST_ASSERT(tok < NUM_TOKENS); // tok is unsigned + assert(tok < NUM_TOKENS); // tok is unsigned return m_name[tok]; } @@ -252,7 +251,7 @@ public: static Value negateCompareOp(Value op) { - BOOST_ASSERT(isArithmeticCompareOp(op)); + assert(isArithmeticCompareOp(op)); switch (op) { case EQ: @@ -268,14 +267,14 @@ public: case GTE: return LT; default: - BOOST_ASSERT(false); // should not get here + assert(false); // should not get here return op; } } static Value reverseCompareOp(Value op) { - BOOST_ASSERT(isArithmeticCompareOp(op)); + assert(isArithmeticCompareOp(op)); switch (op) { case EQ: @@ -291,14 +290,14 @@ public: case GTE: return LTE; default: - BOOST_ASSERT(false); // should not get here + assert(false); // should not get here return op; } } static Value AssignmentToBinaryOp(Value op) { - BOOST_ASSERT(isAssignmentOp(op) && op != ASSIGN); + assert(isAssignmentOp(op) && op != ASSIGN); return Token::Value(op + (BIT_OR - ASSIGN_BIT_OR)); } @@ -312,7 +311,7 @@ public: // have a (unique) string (e.g. an IDENTIFIER). static char const* toString(Value tok) { - BOOST_ASSERT(tok < NUM_TOKENS); // tok is unsigned. + assert(tok < NUM_TOKENS); // tok is unsigned. return m_string[tok]; } @@ -320,7 +319,7 @@ public: // operators; returns 0 otherwise. static int precedence(Value tok) { - BOOST_ASSERT(tok < NUM_TOKENS); // tok is unsigned. + assert(tok < NUM_TOKENS); // tok is unsigned. return m_precedence[tok]; } @@ -20,6 +20,7 @@ * Solidity data types */ +#include <cassert> #include <libdevcore/CommonIO.h> #include <libdevcore/CommonData.h> #include <libsolidity/Types.h> @@ -51,7 +52,7 @@ std::shared_ptr<Type> Type::fromElementaryTypeName(Token::Value _typeToken) else if (_typeToken == Token::BOOL) return std::make_shared<BoolType>(); else - BOOST_ASSERT(false); // @todo add other tyes + assert(false); // @todo add other tyes } std::shared_ptr<Type> Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName) @@ -61,7 +62,7 @@ std::shared_ptr<Type> Type::fromUserDefinedTypeName(UserDefinedTypeName const& _ std::shared_ptr<Type> Type::fromMapping(Mapping const&) { - BOOST_ASSERT(false); //@todo not yet implemented + assert(false); //@todo not yet implemented return std::shared_ptr<Type>(); } @@ -92,7 +93,7 @@ IntegerType::IntegerType(int _bits, IntegerType::Modifier _modifier): { if (isAddress()) _bits = 160; - BOOST_ASSERT(_bits > 0 && _bits <= 256 && _bits % 8 == 0); + assert(_bits > 0 && _bits <= 256 && _bits % 8 == 0); } bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const @@ -25,7 +25,6 @@ #include <memory> #include <string> #include <boost/noncopyable.hpp> -#include <boost/assert.hpp> #include <libdevcore/Common.h> #include <libsolidity/ASTForward.h> #include <libsolidity/Token.h> |