aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ABIFunctions.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2019-01-22 06:53:21 +0800
committerGitHub <noreply@github.com>2019-01-22 06:53:21 +0800
commit7b66eb273d6e1c17882471f24333afd7e53de44e (patch)
tree168bd8a0d99b76b626a074594e37f81a6f9f7e45 /libsolidity/codegen/ABIFunctions.h
parentf33b81676f9d97b6dc0fa30804cb06f850bccd34 (diff)
parent7a69455c1351e1acd3f9a30bcc621f3f4719eedd (diff)
downloaddexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar.gz
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar.bz2
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar.lz
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar.xz
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.tar.zst
dexon-solidity-7b66eb273d6e1c17882471f24333afd7e53de44e.zip
Merge pull request #5832 from ethereum/introduceEncodingOptions
[REF] Provide ABI encoding options as single struct parameter.
Diffstat (limited to 'libsolidity/codegen/ABIFunctions.h')
-rw-r--r--libsolidity/codegen/ABIFunctions.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/libsolidity/codegen/ABIFunctions.h b/libsolidity/codegen/ABIFunctions.h
index 1e0cf7fa..c5443236 100644
--- a/libsolidity/codegen/ABIFunctions.h
+++ b/libsolidity/codegen/ABIFunctions.h
@@ -87,6 +87,23 @@ public:
std::pair<std::string, std::set<std::string>> requestedFunctions();
private:
+ struct EncodingOptions
+ {
+ /// Pad/signextend value types and bytes/string to multiples of 32 bytes.
+ bool padded = true;
+ /// Store arrays and structs in place without "data pointer" and do not store the length.
+ bool dynamicInplace = false;
+ /// Only for external function types: The value is a pair of address / function id instead
+ /// of a memory pointer to the compression representation.
+ bool encodeFunctionFromStack = false;
+ /// Encode storage pointers as storage pointers (we are targeting a library call).
+ bool encodeAsLibraryTypes = false;
+
+ /// @returns a string to uniquely identify the encoding options for the encoding
+ /// function name. Skips everything that has its default value.
+ std::string toFunctionNameSuffix() const;
+ };
+
/// @returns the name of the cleanup function for the given type and
/// adds its implementation to the requested functions.
/// @param _revertOnFailure if true, causes revert on invalid data,
@@ -115,40 +132,39 @@ private:
std::string abiEncodingFunction(
Type const& _givenType,
Type const& _targetType,
- bool _encodeAsLibraryTypes,
- bool _fromStack
+ EncodingOptions const& _options
);
/// Part of @a abiEncodingFunction for array target type and given calldata array.
std::string abiEncodingFunctionCalldataArray(
Type const& _givenType,
Type const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
/// Part of @a abiEncodingFunction for array target type and given memory array or
/// a given storage array with one item per slot.
std::string abiEncodingFunctionSimpleArray(
ArrayType const& _givenType,
ArrayType const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
std::string abiEncodingFunctionMemoryByteArray(
ArrayType const& _givenType,
ArrayType const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
/// Part of @a abiEncodingFunction for array target type and given storage array
/// where multiple items are packed into the same storage slot.
std::string abiEncodingFunctionCompactStorageArray(
ArrayType const& _givenType,
ArrayType const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
/// Part of @a abiEncodingFunction for struct types.
std::string abiEncodingFunctionStruct(
StructType const& _givenType,
StructType const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
// @returns the name of the ABI encoding function with the given type
@@ -157,14 +173,13 @@ private:
std::string abiEncodingFunctionStringLiteral(
Type const& _givenType,
Type const& _targetType,
- bool _encodeAsLibraryTypes
+ EncodingOptions const& _options
);
std::string abiEncodingFunctionFunctionType(
FunctionType const& _from,
Type const& _to,
- bool _encodeAsLibraryTypes,
- bool _fromStack
+ EncodingOptions const& _options
);
/// @returns the name of the ABI decoding function for the given type