diff options
author | chriseth <chris@ethereum.org> | 2018-08-14 22:32:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-14 22:32:57 +0800 |
commit | ec7ccbdf866c108e96e3e9adeab60c3b00195f91 (patch) | |
tree | 662734c7fa23295a50487acf1e032d7996e4d32b /libsolidity/ast | |
parent | 029e217ed24c2d7584d9bbebb18920a77713afc6 (diff) | |
parent | 499ec8b024dbfb13e5a0635fbe5af68339057494 (diff) | |
download | dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar.gz dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar.bz2 dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar.lz dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar.xz dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.tar.zst dexon-solidity-ec7ccbdf866c108e96e3e9adeab60c3b00195f91.zip |
Merge pull request #4782 from ethereum/encodePackedArrayOfStructs
Encode packed array of structs
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/Types.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 349e4a02..0d69ae1a 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -394,17 +394,17 @@ TypePointer Type::fullEncodingType(bool _inLibraryCall, bool _encoderV2, bool _p encodingType = encodingType->interfaceType(_inLibraryCall); if (encodingType) encodingType = encodingType->encodingType(); - if (auto structType = dynamic_cast<StructType const*>(encodingType.get())) - { - // Structs are fine in the following circumstances: - // - ABIv2 without packed encoding or, - // - storage struct for a library - if (!( - (_encoderV2 && !_packed) || - (structType->location() == DataLocation::Storage && _inLibraryCall) - )) + // Structs are fine in the following circumstances: + // - ABIv2 without packed encoding or, + // - storage struct for a library + if (_inLibraryCall && encodingType->dataStoredIn(DataLocation::Storage)) + return encodingType; + TypePointer baseType = encodingType; + while (auto const* arrayType = dynamic_cast<ArrayType const*>(baseType.get())) + baseType = arrayType->baseType(); + if (dynamic_cast<StructType const*>(baseType.get())) + if (!_encoderV2 || _packed) return TypePointer(); - } return encodingType; } |