aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-03-05 00:43:40 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-03-12 19:53:00 +0800
commitbede2f2ad7eb023018ab2faac17286fdee82b03c (patch)
treeed1b2a2f62a01bc61c29e7adab2a5131da5aa218
parent36fe571576a7e5af91d9f95ff0a2252394720a34 (diff)
downloaddexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar.gz
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar.bz2
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar.lz
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar.xz
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.tar.zst
dexon-solidity-bede2f2ad7eb023018ab2faac17286fdee82b03c.zip
More changes towards getting rid of HashXX
-rw-r--r--ExpressionCompiler.cpp4
-rw-r--r--Token.h4
-rw-r--r--Types.cpp29
-rw-r--r--Types.h4
4 files changed, 16 insertions, 25 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 12926112..91a59b2d 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -131,7 +131,7 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con
// conversion from string to hash. no need to clean the high bit
// only to shift right because of opposite alignment
IntegerType const& targetIntegerType = dynamic_cast<IntegerType const&>(_targetType);
- solAssert(targetIntegerType.isHash(), "Only conversion between String and Hash is allowed.");
+ solAssert(targetIntegerType.isBytes(), "Only conversion between String and Bytes is allowed.");
solAssert(targetIntegerType.getNumBits() == typeOnStack.getNumBytes() * 8, "The size should be the same.");
m_context << (u256(1) << (256 - typeOnStack.getNumBytes() * 8)) << eth::Instruction::SWAP1 << eth::Instruction::DIV;
}
@@ -164,7 +164,7 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con
// only to shift left because of opposite alignment
StaticStringType const& targetStringType = dynamic_cast<StaticStringType const&>(_targetType);
IntegerType const& typeOnStack = dynamic_cast<IntegerType const&>(_typeOnStack);
- solAssert(typeOnStack.isHash(), "Only conversion between String and Hash is allowed.");
+ solAssert(typeOnStack.isBytes(), "Only conversion between String and Bytes is allowed.");
solAssert(typeOnStack.getNumBits() == targetStringType.getNumBytes() * 8, "The size should be the same.");
m_context << (u256(1) << (256 - typeOnStack.getNumBits())) << eth::Instruction::MUL;
}
diff --git a/Token.h b/Token.h
index 7c1de60b..d7f56aa4 100644
--- a/Token.h
+++ b/Token.h
@@ -252,8 +252,6 @@ namespace solidity
K(UInt240, "uint240", 0) \
K(UInt248, "uint248", 0) \
K(UInt256, "uint256", 0) \
- K(Hash, "hash", 0) \
- K(Bytes, "bytes", 0) \
K(Bytes8, "bytes8", 0) \
K(Bytes16, "bytes16", 0) \
K(Bytes24, "bytes24", 0) \
@@ -286,10 +284,10 @@ namespace solidity
K(Bytes240, "bytes240", 0) \
K(Bytes248, "bytes248", 0) \
K(Bytes256, "bytes256", 0) \
+ K(Bytes, "bytes", 0) \
K(Address, "address", 0) \
K(Bool, "bool", 0) \
K(StringType, "string", 0) \
- K(Text, "text", 0) \
K(Real, "real", 0) \
K(UReal, "ureal", 0) \
T(TypesEnd, NULL, 0) /* used as type enum end marker */ \
diff --git a/Types.cpp b/Types.cpp
index 73cd09d6..daf7c03e 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -49,14 +49,12 @@ TypePointer Type::fromElementaryTypeName(Token::Value _typeToken)
return make_shared<IntegerType>(bytes * 8,
modifier == 0 ? IntegerType::Modifier::Signed :
modifier == 1 ? IntegerType::Modifier::Unsigned :
- IntegerType::Modifier::Hash);
+ IntegerType::Modifier::Bytes);
}
else if (_typeToken == Token::Address)
return make_shared<IntegerType>(0, IntegerType::Modifier::Address);
else if (_typeToken == Token::Bool)
return make_shared<BoolType>();
- else if (Token::String0 <= _typeToken && _typeToken <= Token::String32)
- return make_shared<StaticStringType>(int(_typeToken) - int(Token::String0));
else if (_typeToken == Token::Bytes)
return make_shared<ArrayType>(ArrayType::Location::Storage);
else
@@ -159,8 +157,8 @@ bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
return false;
if (isAddress())
return convertTo.isAddress();
- else if (isHash())
- return convertTo.isHash();
+ else if (isBytes())
+ return convertTo.isBytes();
else if (isSigned())
return convertTo.isSigned();
else
@@ -169,14 +167,9 @@ bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
bool IntegerType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{
- if (_convertTo.getCategory() == Category::String)
- {
- StaticStringType const& convertTo = dynamic_cast<StaticStringType const&>(_convertTo);
- return isHash() && (m_bits == convertTo.getNumBytes() * 8);
- }
return _convertTo.getCategory() == getCategory() ||
- _convertTo.getCategory() == Category::Contract ||
- _convertTo.getCategory() == Category::Enum;
+ _convertTo.getCategory() == Category::Contract ||
+ _convertTo.getCategory() == Category::Enum;
}
TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const
@@ -190,8 +183,8 @@ TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const
// "~" is ok for all other types
else if (_operator == Token::BitNot)
return shared_from_this();
- // nothing else for hashes
- else if (isHash())
+ // nothing else for bytes
+ else if (isBytes())
return TypePointer();
// for non-hash integers, we allow +, -, ++ and --
else if (_operator == Token::Add || _operator == Token::Sub ||
@@ -214,7 +207,7 @@ string IntegerType::toString() const
{
if (isAddress())
return "address";
- string prefix = isHash() ? "hash" : (isSigned() ? "int" : "uint");
+ string prefix = isBytes() ? "bytes" : (isSigned() ? "int" : "uint");
return prefix + dev::toString(m_bits);
}
@@ -231,10 +224,10 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe
if (Token::isCompareOp(_operator))
return commonType;
- // Nothing else can be done with addresses, but hashes can receive bit operators
+ // Nothing else can be done with addresses, but bytes can receive bit operators
if (commonType->isAddress())
return TypePointer();
- else if (commonType->isHash() && !Token::isBitOp(_operator))
+ else if (commonType->isBytes() && !Token::isBitOp(_operator))
return TypePointer();
else
return commonType;
@@ -461,7 +454,7 @@ bool StaticStringType::isExplicitlyConvertibleTo(Type const& _convertTo) const
if (_convertTo.getCategory() == Category::Integer)
{
IntegerType const& convertTo = dynamic_cast<IntegerType const&>(_convertTo);
- if (convertTo.isHash() && (m_bytes * 8 == convertTo.getNumBits()))
+ if (convertTo.isBytes() && (m_bytes * 8 == convertTo.getNumBits()))
return true;
}
diff --git a/Types.h b/Types.h
index 6cef8d64..3d67720c 100644
--- a/Types.h
+++ b/Types.h
@@ -165,7 +165,7 @@ class IntegerType: public Type
public:
enum class Modifier
{
- Unsigned, Signed, Hash, Address
+ Unsigned, Signed, Bytes, Address
};
virtual Category getCategory() const override { return Category::Integer; }
@@ -186,7 +186,7 @@ public:
virtual std::string toString() const override;
int getNumBits() const { return m_bits; }
- bool isHash() const { return m_modifier == Modifier::Hash || m_modifier == Modifier::Address; }
+ bool isBytes() const { return m_modifier == Modifier::Bytes || m_modifier == Modifier::Address; }
bool isAddress() const { return m_modifier == Modifier::Address; }
bool isSigned() const { return m_modifier == Modifier::Signed; }