Corrected coding style.

This commit is contained in:
Christian
2014-10-16 14:08:54 +02:00
parent 4ece1ba1d3
commit 8a506b505f
20 changed files with 1146 additions and 1050 deletions
+35 -31
View File
@@ -1,18 +1,18 @@
/*
This file is part of cpp-ethereum.
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @author Christian <c@ethdev.com>
@@ -23,12 +23,15 @@
#include <libsolidity/Types.h>
#include <libsolidity/AST.h>
namespace dev {
namespace solidity {
namespace dev
{
namespace solidity
{
ptr<Type> Type::fromElementaryTypeName(Token::Value _typeToken)
{
if (Token::INT <= _typeToken && _typeToken <= Token::HASH256) {
if (Token::INT <= _typeToken && _typeToken <= Token::HASH256)
{
int offset = _typeToken - Token::INT;
int bits = offset % 5;
if (bits == 0)
@@ -39,15 +42,14 @@ ptr<Type> Type::fromElementaryTypeName(Token::Value _typeToken)
return std::make_shared<IntegerType>(bits,
modifier == 0 ? IntegerType::Modifier::SIGNED :
modifier == 1 ? IntegerType::Modifier::UNSIGNED :
IntegerType::Modifier::HASH);
} else if (_typeToken == Token::ADDRESS) {
return std::make_shared<IntegerType>(0, IntegerType::Modifier::ADDRESS);
} else if (_typeToken == Token::BOOL) {
return std::make_shared<BoolType>();
} else {
BOOST_ASSERT(false);
// @todo add other tyes
IntegerType::Modifier::HASH);
}
else if (_typeToken == Token::ADDRESS)
return std::make_shared<IntegerType>(0, IntegerType::Modifier::ADDRESS);
else if (_typeToken == Token::BOOL)
return std::make_shared<BoolType>();
else
BOOST_ASSERT(false); // @todo add other tyes
}
ptr<Type> Type::fromUserDefinedTypeName(const UserDefinedTypeName& _typeName)
@@ -63,7 +65,8 @@ ptr<Type> Type::fromMapping(const Mapping&)
ptr<Type> Type::forLiteral(const Literal& _literal)
{
switch (_literal.getToken()) {
switch (_literal.getToken())
{
case Token::TRUE_LITERAL:
case Token::FALSE_LITERAL:
return std::make_shared<BoolType>();
@@ -114,13 +117,12 @@ bool IntegerType::isExplicitlyConvertibleTo(const Type& _convertTo) const
bool IntegerType::acceptsBinaryOperator(Token::Value _operator) const
{
if (isAddress()) {
return Token::IsCompareOp(_operator);
} else if (isHash()) {
return Token::IsCompareOp(_operator) || Token::IsBitOp(_operator);
} else {
if (isAddress())
return Token::isCompareOp(_operator);
else if (isHash())
return Token::isCompareOp(_operator) || Token::isBitOp(_operator);
else
return true;
}
}
bool IntegerType::acceptsUnaryOperator(Token::Value _operator) const
@@ -132,7 +134,8 @@ bool BoolType::isExplicitlyConvertibleTo(const Type& _convertTo) const
{
// conversion to integer is fine, but not to address
// this is an example of explicit conversions being not transitive (though implicit should be)
if (_convertTo.getCategory() == Category::INTEGER) {
if (_convertTo.getCategory() == Category::INTEGER)
{
IntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo);
if (!convertTo.isAddress())
return true;
@@ -157,4 +160,5 @@ bool StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const
}
} }
}
}