From 58be273506bf30619952eedf4c469879050c05ed Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 24 Oct 2014 18:32:15 +0200 Subject: Replace BOOST_ASSERT by assert. --- AST.cpp | 16 ++++++++-------- NameAndTypeResolver.cpp | 11 +++++------ Scanner.cpp | 16 ++++++++-------- Scanner.h | 2 -- Token.h | 19 +++++++++---------- Types.cpp | 7 ++++--- Types.h | 1 - 7 files changed, 34 insertions(+), 38 deletions(-) diff --git a/AST.cpp b/AST.cpp index 414de9b2..49bb071a 100644 --- a/AST.cpp +++ b/AST.cpp @@ -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(); 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(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(expressionType); - BOOST_ASSERT(function); + assert(function); FunctionDefinition const& fun = function->getFunction(); std::vector> 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(std::make_shared(*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 #include - #include #include -#include namespace dev { @@ -123,19 +122,19 @@ void DeclarationRegistrationHelper::enterNewSubScope(ASTNode& _node) std::map::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 #include #include - #include 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(); } diff --git a/Scanner.h b/Scanner.h index 0cf87f6a..fbaba9ed 100644 --- a/Scanner.h +++ b/Scanner.h @@ -52,8 +52,6 @@ #pragma once -#include - #include #include #include diff --git a/Token.h b/Token.h index 7949d2c6..c54f387c 100644 --- a/Token.h +++ b/Token.h @@ -42,8 +42,7 @@ #pragma once -#include - +#include #include #include @@ -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]; } diff --git a/Types.cpp b/Types.cpp index f0307a7c..cf901e64 100644 --- a/Types.cpp +++ b/Types.cpp @@ -20,6 +20,7 @@ * Solidity data types */ +#include #include #include #include @@ -51,7 +52,7 @@ std::shared_ptr Type::fromElementaryTypeName(Token::Value _typeToken) else if (_typeToken == Token::BOOL) return std::make_shared(); else - BOOST_ASSERT(false); // @todo add other tyes + assert(false); // @todo add other tyes } std::shared_ptr Type::fromUserDefinedTypeName(UserDefinedTypeName const& _typeName) @@ -61,7 +62,7 @@ std::shared_ptr Type::fromUserDefinedTypeName(UserDefinedTypeName const& _ std::shared_ptr Type::fromMapping(Mapping const&) { - BOOST_ASSERT(false); //@todo not yet implemented + assert(false); //@todo not yet implemented return std::shared_ptr(); } @@ -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 diff --git a/Types.h b/Types.h index 40bc4487..4d56b5ab 100644 --- a/Types.h +++ b/Types.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include -- cgit