diff options
author | chriseth <chris@ethereum.org> | 2017-08-25 02:50:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-25 02:50:37 +0800 |
commit | d7661dd97460250b4e1127b9e7ea91e116143780 (patch) | |
tree | 0d909e7aeec373b0559b9d80f8ae9a9e03bdd92b /libsolidity/codegen/CompilerUtils.cpp | |
parent | bbb8e64fbee632d1594f6c132b1174591b961207 (diff) | |
parent | dd67e5966f41be0b2ef52041ea726930af74f7e9 (diff) | |
download | dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.gz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.bz2 dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.lz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.xz dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.tar.zst dexon-solidity-d7661dd97460250b4e1127b9e7ea91e116143780.zip |
Merge pull request #2802 from ethereum/develop
Merge develop into release for 0.4.16
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 782aad9d..a0fc5d55 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -25,6 +25,7 @@ #include <libevmasm/Instruction.h> #include <libsolidity/codegen/ArrayUtils.h> #include <libsolidity/codegen/LValue.h> +#include <libsolidity/codegen/ABIFunctions.h> using namespace std; @@ -182,6 +183,18 @@ void CompilerUtils::encodeToMemory( if (_givenTypes.empty()) return; + else if ( + _padToWordBoundaries && + !_copyDynamicDataInPlace && + m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) + ) + { + // Use the new JULIA-based encoding function + auto stackHeightBefore = m_context.stackHeight(); + abiEncode(_givenTypes, targetTypes, _encodeAsLibraryTypes); + solAssert(stackHeightBefore - m_context.stackHeight() == sizeOnStack(_givenTypes), ""); + return; + } // Stack during operation: // <v1> <v2> ... <vn> <mem_start> <dyn_head_1> ... <dyn_head_r> <end_of_mem> @@ -289,6 +302,28 @@ void CompilerUtils::encodeToMemory( popStackSlots(argSize + dynPointers + 1); } +void CompilerUtils::abiEncode( + TypePointers const& _givenTypes, + TypePointers const& _targetTypes, + bool _encodeAsLibraryTypes +) +{ + // stack: <$value0> <$value1> ... <$value(n-1)> <$headStart> + + vector<string> variables; + size_t numValues = sizeOnStack(_givenTypes); + for (size_t i = 0; i < numValues; ++i) + variables.push_back("$value" + to_string(i)); + variables.push_back("$headStart"); + + ABIFunctions funs; + string routine = funs.tupleEncoder(_givenTypes, _targetTypes, _encodeAsLibraryTypes); + routine += funs.requestedFunctions(); + m_context.appendInlineAssembly("{" + routine + "}", variables); + // Remove everyhing except for "value0" / the final memory pointer. + popStackSlots(numValues); +} + void CompilerUtils::zeroInitialiseMemoryArray(ArrayType const& _type) { auto repeat = m_context.newTag(); |