diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-27 20:04:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 20:04:37 +0800 |
commit | 3f783c8dad7a143d364f75ddac839aac2eeece1a (patch) | |
tree | 9df24003560a05a73f1cdb1f2c6a2c28105fb669 /libsolidity/codegen/CompilerUtils.h | |
parent | a27b23bacb60a6902547fb99b9f7a2df8bb014cd (diff) | |
parent | 204214f0700179e3d8fa97c77d4f92acd349f015 (diff) | |
download | dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar.gz dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar.bz2 dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar.lz dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar.xz dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.tar.zst dexon-solidity-3f783c8dad7a143d364f75ddac839aac2eeece1a.zip |
Merge pull request #2975 from ethereum/encode-memory
Split encodeToMemory into packedEncode and abiEncode
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.h')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index 5e45699b..ad3989ad 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -102,13 +102,26 @@ public: /// @note the locations of target reference types are ignored, because it will always be /// memory. void encodeToMemory( - TypePointers const& _givenTypes = {}, - TypePointers const& _targetTypes = {}, - bool _padToWords = true, - bool _copyDynamicDataInPlace = false, + TypePointers const& _givenTypes, + TypePointers const& _targetTypes, + bool _padToWords, + bool _copyDynamicDataInPlace, bool _encodeAsLibraryTypes = false ); + /// Special case of @a encodeToMemory which assumes tight packing, e.g. no zero padding + /// and dynamic data is encoded in-place. + /// Stack pre: <value0> <value1> ... <valueN-1> <head_start> + /// Stack post: <mem_ptr> + void packedEncode( + TypePointers const& _givenTypes, + TypePointers const& _targetTypes, + bool _encodeAsLibraryTypes = false + ) + { + encodeToMemory(_givenTypes, _targetTypes, false, true, _encodeAsLibraryTypes); + } + /// Special case of @a encodeToMemory which assumes that everything is padded to words /// and dynamic data is not copied in place (i.e. a proper ABI encoding). /// Stack pre: <value0> <value1> ... <valueN-1> <head_start> @@ -117,6 +130,20 @@ public: TypePointers const& _givenTypes, TypePointers const& _targetTypes, bool _encodeAsLibraryTypes = false + ) + { + encodeToMemory(_givenTypes, _targetTypes, true, false, _encodeAsLibraryTypes); + } + + /// Special case of @a encodeToMemory which assumes that everything is padded to words + /// and dynamic data is not copied in place (i.e. a proper ABI encoding). + /// Uses a new, less tested encoder implementation. + /// Stack pre: <value0> <value1> ... <valueN-1> <head_start> + /// Stack post: <mem_ptr> + void abiEncodeV2( + TypePointers const& _givenTypes, + TypePointers const& _targetTypes, + bool _encodeAsLibraryTypes = false ); /// Zero-initialises (the data part of) an already allocated memory array. |