UserDefinedValueType.storageBytes() is correctly set

Previously it returned 32 bytes for all types, which was wasteful. This commit changes it to return
the storage bytes of the underlying type.
This commit is contained in:
hrkrshnn
2021-09-29 11:41:47 +02:00
committed by chriseth
parent 7e7c68e5bf
commit 6109b5c3a1
8 changed files with 286 additions and 0 deletions
+21
View File
@@ -1108,6 +1108,8 @@ public:
bool leftAligned() const override { return underlyingType().leftAligned(); }
bool canBeStored() const override { return underlyingType().canBeStored(); }
u256 storageSize() const override { return underlyingType().storageSize(); }
unsigned storageBytes() const override { return underlyingType().storageBytes(); }
bool isValueType() const override
{
solAssert(underlyingType().isValueType(), "");
@@ -1119,6 +1121,25 @@ public:
return true;
}
bool containsNestedMapping() const override
{
solAssert(nameable(), "Called for a non nameable type.");
solAssert(!underlyingType().containsNestedMapping(), "");
return false;
}
bool hasSimpleZeroValueInMemory() const override
{
solAssert(underlyingType().hasSimpleZeroValueInMemory(), "");
return true;
}
bool dataStoredIn(DataLocation _loc) const override
{
solAssert(!underlyingType().dataStoredIn(_loc), "");
return false;
}
std::string toString(bool _short) const override;
std::string canonicalName() const override { solAssert(false, ""); }
std::string signatureInExternalFunction(bool) const override { solAssert(false, ""); }