aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-01-19 18:32:11 +0800
committerchriseth <c@ethdev.com>2015-01-19 18:32:11 +0800
commit325b052b164992b6c19cb5c4550680d7f2a8e380 (patch)
tree36fa6cea3f87dd66ea61f7823c2329027e2dcf4b /Types.cpp
parent930532165cdc0404120a5f0c76ff6d7673ff2222 (diff)
parentc3d36d1fe197156427cd8adb4edbf955bba0531a (diff)
downloaddexon-solidity-325b052b164992b6c19cb5c4550680d7f2a8e380.tar.gz
dexon-solidity-325b052b164992b6c19cb5c4550680d7f2a8e380.tar.zst
dexon-solidity-325b052b164992b6c19cb5c4550680d7f2a8e380.zip
Merge pull request #805 from LianaHus/deleteStruct
delete for structs -added functionality to set values to 0 when deleting structure(not for ...
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 ae87a088..a99e4853 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())