aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorliana <liana@ethdev.com>2015-01-14 20:52:03 +0800
committerliana <liana@ethdev.com>2015-01-15 18:59:58 +0800
commit00b0b0933de8f745451652e8838f0c09a741228e (patch)
tree793020607eeba7ede1ed0356a215385dd5bf13e0 /Types.cpp
parent6e16107870494878635da347146b076a7d75dea0 (diff)
downloaddexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar.gz
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar.bz2
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar.lz
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar.xz
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.tar.zst
dexon-solidity-00b0b0933de8f745451652e8838f0c09a741228e.zip
- added functionality to set values to 0 when deleting structure(not for mapping)
- added unit test Made some changes after Christian`s review on pull request - remove/edit comments - BoolType and ContractType return VoidType after delete - fixed constructor_arguments test - fixed set to 0 when deleting variable from stack - changed test case to test that
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/Types.cpp b/Types.cpp
index 7ca1dc6d..079e79b8 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -147,7 +147,7 @@ TypePointer IntegerType::unaryOperatorResult(Token::Value _operator) const
{
// "delete" is ok for all integer types
if (_operator == Token::DELETE)
- return shared_from_this();
+ return make_shared<VoidType>();
// no further unary operators for addresses
else if (isAddress())
return TypePointer();
@@ -408,6 +408,13 @@ u256 BoolType::literalValue(Literal const* _literal) const
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Bool type constructed from non-boolean literal."));
}
+TypePointer BoolType::unaryOperatorResult(Token::Value _operator) const
+{
+ if (_operator == Token::DELETE)
+ return make_shared<VoidType>();
+ return (_operator == Token::NOT) ? shared_from_this() : TypePointer();
+}
+
TypePointer BoolType::binaryOperatorResult(Token::Value _operator, TypePointer const& _other) const
{
if (getCategory() != _other->getCategory())
@@ -432,6 +439,11 @@ bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const
return isImplicitlyConvertibleTo(_convertTo) || _convertTo.getCategory() == Category::INTEGER;
}
+TypePointer ContractType::unaryOperatorResult(Token::Value _operator) const
+{
+ return _operator == Token::DELETE ? make_shared<VoidType>() : TypePointer();
+}
+
bool ContractType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())
@@ -440,14 +452,6 @@ bool ContractType::operator==(Type const& _other) const
return other.m_contract == m_contract;
}
-u256 ContractType::getStorageSize() const
-{
- u256 size = 0;
- for (ASTPointer<VariableDeclaration> const& variable: m_contract.getStateVariables())
- size += variable->getType()->getStorageSize();
- return max<u256>(1, size);
-}
-
string ContractType::toString() const
{
return "contract " + m_contract.getName();
@@ -491,6 +495,11 @@ u256 ContractType::getFunctionIdentifier(string const& _functionName) const
return Invalid256;
}
+TypePointer StructType::unaryOperatorResult(Token::Value _operator) const
+{
+ return _operator == Token::DELETE ? make_shared<VoidType>() : TypePointer();
+}
+
bool StructType::operator==(Type const& _other) const
{
if (_other.getCategory() != getCategory())