mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace BOOST_ASSERT by assert.
This commit is contained in:
parent
9141725cf2
commit
58be273506
16
AST.cpp
16
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<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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
16
Scanner.cpp
16
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>
|
||||
|
19
Token.h
19
Token.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
|
||||
|
Loading…
Reference in New Issue
Block a user