mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
current debugging info
This commit is contained in:
parent
8efd6dd27a
commit
3ba308fb2e
@ -274,8 +274,18 @@ bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
|
|||||||
else if (_convertTo.category() == Category::FixedPoint)
|
else if (_convertTo.category() == Category::FixedPoint)
|
||||||
{
|
{
|
||||||
FixedPointType const& convertTo = dynamic_cast<FixedPointType const&>(_convertTo);
|
FixedPointType const& convertTo = dynamic_cast<FixedPointType const&>(_convertTo);
|
||||||
|
cout << endl;
|
||||||
|
cout << "Integer bits: " << m_bits << endl;
|
||||||
|
cout << "Fraction integer bits: " << convertTo.integerBits() << endl;
|
||||||
|
cout << "Integer signed: " << isSigned() << endl;
|
||||||
|
cout << "Fractional signed: " << convertTo.isSigned() << endl;
|
||||||
|
cout << "Unsigned convert?: " << bool(!convertTo.isSigned() || convertTo.integerBits() > m_bits) << endl;
|
||||||
|
cout << endl;
|
||||||
if (convertTo.integerBits() < m_bits || isAddress())
|
if (convertTo.integerBits() < m_bits || isAddress())
|
||||||
|
{
|
||||||
|
cout << "problem with the integer bits" << endl;
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
else if (isSigned())
|
else if (isSigned())
|
||||||
return convertTo.isSigned();
|
return convertTo.isSigned();
|
||||||
else
|
else
|
||||||
@ -328,13 +338,21 @@ string IntegerType::toString(bool) const
|
|||||||
|
|
||||||
TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const
|
TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const
|
||||||
{
|
{
|
||||||
if (_other->category() != Category::RationalNumber && _other->category() != category())
|
if (
|
||||||
|
_other->category() != Category::RationalNumber &&
|
||||||
|
_other->category() != Category::FixedPoint &&
|
||||||
|
_other->category() != category()
|
||||||
|
)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
auto commonType = dynamic_pointer_cast<IntegerType const>(Type::commonType(shared_from_this(), _other));
|
auto commonType = dynamic_pointer_cast<IntegerType const>(Type::commonType(shared_from_this(), _other));
|
||||||
|
|
||||||
if (!commonType)
|
if (!commonType)
|
||||||
|
{
|
||||||
|
cout << "Not common type" << endl;
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
|
}
|
||||||
|
cout << "Integer binary operator: " << commonType->toString(false) << endl;
|
||||||
|
cout << "Token: " << string(Token::toString(_operator)) << endl;
|
||||||
// All integer types can be compared
|
// All integer types can be compared
|
||||||
if (Token::isCompareOp(_operator))
|
if (Token::isCompareOp(_operator))
|
||||||
return commonType;
|
return commonType;
|
||||||
|
@ -3683,6 +3683,45 @@ BOOST_AUTO_TEST_CASE(zero_handling)
|
|||||||
BOOST_CHECK(success(text));
|
BOOST_CHECK(success(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() {
|
||||||
|
uint128 a = uint128(1) + ufixed(2);
|
||||||
|
ufixed b = .5 * uint128(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(success(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(signed_rational_modulus)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() {
|
||||||
|
fixed a = 0.42578125 % -0.4271087646484375;
|
||||||
|
fixed b = .5 % a;
|
||||||
|
fixed c = a % b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(success(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(one_divided_by_three_integer_conversion)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract test {
|
||||||
|
function f() {
|
||||||
|
uint a = 1/3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
BOOST_CHECK(!success(text));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user