From 70d70e78160069d28a6b4931c995d0b24c2b09d5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 24 Aug 2017 15:20:49 +0200 Subject: Implement struct encoder. --- libsolidity/ast/Types.cpp | 10 +++++++++- libsolidity/ast/Types.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'libsolidity/ast') diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 14b30df8..c7843b90 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1735,7 +1735,15 @@ unsigned StructType::calldataEncodedSize(bool _padded) const bool StructType::isDynamicallyEncoded() const { - solAssert(false, "Structs are not yet supported in the ABI."); + solAssert(!recursive(), ""); + for (auto t: memoryMemberTypes()) + { + solAssert(t, "Parameter should have external type."); + t = t->interfaceType(false); + if (t->isDynamicallyEncoded()) + return true; + } + return false; } u256 StructType::memorySize() const diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index dd50c573..cb439693 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -745,7 +745,7 @@ public: virtual MemberList::MemberMap nativeMembers(ContractDefinition const* _currentScope) const override; virtual TypePointer encodingType() const override { - return location() == DataLocation::Storage ? std::make_shared(256) : TypePointer(); + return location() == DataLocation::Storage ? std::make_shared(256) : shared_from_this(); } virtual TypePointer interfaceType(bool _inLibrary) const override; -- cgit v1.2.3