aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2016-05-20 22:48:50 +0800
committerchriseth <c@ethdev.com>2016-05-20 22:48:50 +0800
commit2f37356c589a912a2f1bc414faf8c5274b734673 (patch)
tree79506f5feda11bd0835f8c01cd4da58357269322 /libsolidity
parent0d7ef65f6815df8eb5535bc9e9d81c6450d65623 (diff)
parent919235745263b36bdd7a88374b79f34214b14a5f (diff)
downloaddexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar.gz
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar.bz2
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar.lz
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar.xz
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.tar.zst
dexon-solidity-2f37356c589a912a2f1bc414faf8c5274b734673.zip
Merge pull request #565 from VoR0220/fixedDataType
Fixed data typename fixes and documentation
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/ast/Types.cpp42
1 files changed, 28 insertions, 14 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 0df68d3d..d989cb06 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -290,7 +290,8 @@ bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return _convertTo.category() == category() ||
_convertTo.category() == Category::Contract ||
_convertTo.category() == Category::Enum ||
- _convertTo.category() == Category::FixedBytes;
+ _convertTo.category() == Category::FixedBytes ||
+ _convertTo.category() == Category::FixedPoint;
}
TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const
@@ -328,10 +329,13 @@ string IntegerType::toString(bool) 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();
- auto commonType = dynamic_pointer_cast<IntegerType const>(Type::commonType(shared_from_this(), _other));
-
+ auto commonType = Type::commonType(shared_from_this(), _other); //might be a integer or fixed point
if (!commonType)
return TypePointer();
@@ -341,9 +345,14 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe
if (Token::isBooleanOp(_operator))
return TypePointer();
// Nothing else can be done with addresses
- if (commonType->isAddress())
- return TypePointer();
-
+ if (auto intType = dynamic_pointer_cast<IntegerType const>(commonType))
+ {
+ if (intType->isAddress())
+ return TypePointer();
+ }
+ else if (auto fixType = dynamic_pointer_cast<FixedPointType const>(commonType))
+ if (Token::Exp == _operator)
+ return TypePointer();
return commonType;
}
@@ -386,7 +395,6 @@ bool FixedPointType::isImplicitlyConvertibleTo(Type const& _convertTo) const
else
return !convertTo.isSigned() || (convertTo.m_integerBits > m_integerBits);
}
-
return false;
}
@@ -432,12 +440,12 @@ string FixedPointType::toString(bool) const
TypePointer FixedPointType::binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const
{
if (
- _other->category() != Category::RationalNumber
- && _other->category() != category()
- && _other->category() != Category::Integer
+ _other->category() != Category::RationalNumber &&
+ _other->category() != category() &&
+ _other->category() != Category::Integer
)
return TypePointer();
- auto commonType = dynamic_pointer_cast<FixedPointType const>(Type::commonType(shared_from_this(), _other));
+ auto commonType = Type::commonType(shared_from_this(), _other); //might be fixed point or integer
if (!commonType)
return TypePointer();
@@ -447,8 +455,14 @@ TypePointer FixedPointType::binaryOperatorResult(Token::Value _operator, TypePoi
return commonType;
if (Token::isBitOp(_operator) || Token::isBooleanOp(_operator))
return TypePointer();
- if (Token::Exp == _operator)
- return TypePointer();
+ if (auto fixType = dynamic_pointer_cast<FixedPointType const>(commonType))
+ {
+ if (Token::Exp == _operator)
+ return TypePointer();
+ }
+ else if (auto intType = dynamic_pointer_cast<IntegerType const>(commonType))
+ if (intType->isAddress())
+ return TypePointer();
return commonType;
}