aboutsummaryrefslogtreecommitdiffstats
path: root/Types.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-30 17:54:51 +0800
committerchriseth <c@ethdev.com>2015-07-03 23:25:29 +0800
commitcad3379306cd4f32f51bc9f993498a830d134226 (patch)
tree06f9b50fbb7e796551acc68a334ecd091370f851 /Types.cpp
parentad459207a3c219d60918545de4a0f34040f3388f (diff)
downloaddexon-solidity-cad3379306cd4f32f51bc9f993498a830d134226.tar.gz
dexon-solidity-cad3379306cd4f32f51bc9f993498a830d134226.tar.zst
dexon-solidity-cad3379306cd4f32f51bc9f993498a830d134226.zip
Memory structs.
Diffstat (limited to 'Types.cpp')
-rw-r--r--Types.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Types.cpp b/Types.cpp
index c1769d00..ef70f0e0 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -999,6 +999,15 @@ unsigned StructType::getCalldataEncodedSize(bool _padded) const
return size;
}
+u256 StructType::memorySize() const
+{
+ u256 size;
+ for (auto const& member: getMembers())
+ if (member.type->canLiveOutsideStorage())
+ size += member.type->memoryHeadSize();
+ return size;
+}
+
u256 StructType::getStorageSize() const
{
return max<u256>(1, getMembers().getStorageSize());
@@ -1012,6 +1021,17 @@ bool StructType::canLiveOutsideStorage() const
return true;
}
+unsigned StructType::getSizeOnStack() const
+{
+ switch (location())
+ {
+ case DataLocation::Storage:
+ return 2; // slot and offset
+ default:
+ return 1;
+ }
+}
+
string StructType::toString(bool _short) const
{
string ret = "struct " + m_struct.getName();
@@ -1054,6 +1074,18 @@ pair<u256, unsigned> const& StructType::getStorageOffsetsOfMember(string const&
return *offsets;
}
+u256 StructType::memoryOffsetOfMember(string const& _name) const
+{
+ u256 offset;
+ for (auto const& member: getMembers())
+ if (member.name == _name)
+ return offset;
+ else
+ offset += member.type->memoryHeadSize();
+ solAssert(false, "Member not found in struct.");
+ return 0;
+}
+
TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const
{
return _operator == Token::Delete ? make_shared<VoidType>() : TypePointer();