mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename "compacted" to "fromStack".
This commit is contained in:
parent
acd70557cc
commit
80cefb9cc8
@ -87,7 +87,7 @@ string ABIFunctions::tupleEncoder(
|
|||||||
);
|
);
|
||||||
elementTempl("values", valueNames);
|
elementTempl("values", valueNames);
|
||||||
elementTempl("pos", to_string(headPos));
|
elementTempl("pos", to_string(headPos));
|
||||||
elementTempl("abiEncode", abiEncodingFunction(*_givenTypes[i], *_targetTypes[i], _encodeAsLibraryTypes, false));
|
elementTempl("abiEncode", abiEncodingFunction(*_givenTypes[i], *_targetTypes[i], _encodeAsLibraryTypes, true));
|
||||||
encodeElements += elementTempl.render();
|
encodeElements += elementTempl.render();
|
||||||
headPos += dynamic ? 0x20 : _targetTypes[i]->calldataEncodedSize();
|
headPos += dynamic ? 0x20 : _targetTypes[i]->calldataEncodedSize();
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ string ABIFunctions::abiEncodingFunction(
|
|||||||
Type const& _from,
|
Type const& _from,
|
||||||
Type const& _to,
|
Type const& _to,
|
||||||
bool _encodeAsLibraryTypes,
|
bool _encodeAsLibraryTypes,
|
||||||
bool _compacted
|
bool _fromStack
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solUnimplementedAssert(
|
solUnimplementedAssert(
|
||||||
@ -415,7 +415,7 @@ string ABIFunctions::abiEncodingFunction(
|
|||||||
dynamic_cast<FunctionType const&>(_from),
|
dynamic_cast<FunctionType const&>(_from),
|
||||||
to,
|
to,
|
||||||
_encodeAsLibraryTypes,
|
_encodeAsLibraryTypes,
|
||||||
_compacted
|
_fromStack
|
||||||
);
|
);
|
||||||
|
|
||||||
solAssert(_from.sizeOnStack() == 1, "");
|
solAssert(_from.sizeOnStack() == 1, "");
|
||||||
@ -573,7 +573,7 @@ string ABIFunctions::abiEncodingFunctionSimpleArray(
|
|||||||
*_from.baseType(),
|
*_from.baseType(),
|
||||||
*_to.baseType(),
|
*_to.baseType(),
|
||||||
_encodeAsLibraryTypes,
|
_encodeAsLibraryTypes,
|
||||||
true
|
false
|
||||||
));
|
));
|
||||||
templ("arrayElementAccess", inMemory ? "mload(srcPtr)" : _from.baseType()->isValueType() ? "sload(srcPtr)" : "srcPtr" );
|
templ("arrayElementAccess", inMemory ? "mload(srcPtr)" : _from.baseType()->isValueType() ? "sload(srcPtr)" : "srcPtr" );
|
||||||
templ("nextArrayElement", nextArrayElementFunction(_from));
|
templ("nextArrayElement", nextArrayElementFunction(_from));
|
||||||
@ -716,7 +716,7 @@ string ABIFunctions::abiEncodingFunctionCompactStorageArray(
|
|||||||
*_from.baseType(),
|
*_from.baseType(),
|
||||||
*_to.baseType(),
|
*_to.baseType(),
|
||||||
_encodeAsLibraryTypes,
|
_encodeAsLibraryTypes,
|
||||||
true
|
false
|
||||||
);
|
);
|
||||||
templ("encodeToMemoryFun", encodeToMemoryFun);
|
templ("encodeToMemoryFun", encodeToMemoryFun);
|
||||||
std::vector<std::map<std::string, std::string>> items(itemsPerSlot);
|
std::vector<std::map<std::string, std::string>> items(itemsPerSlot);
|
||||||
@ -832,7 +832,7 @@ string ABIFunctions::abiEncodingFunctionStruct(
|
|||||||
}
|
}
|
||||||
memberTempl("encodingOffset", toCompactHexWithPrefix(encodingOffset));
|
memberTempl("encodingOffset", toCompactHexWithPrefix(encodingOffset));
|
||||||
encodingOffset += dynamicMember ? 0x20 : memberTypeTo->calldataEncodedSize();
|
encodingOffset += dynamicMember ? 0x20 : memberTypeTo->calldataEncodedSize();
|
||||||
memberTempl("abiEncode", abiEncodingFunction(*memberTypeFrom, *memberTypeTo, _encodeAsLibraryTypes, true));
|
memberTempl("abiEncode", abiEncodingFunction(*memberTypeFrom, *memberTypeTo, _encodeAsLibraryTypes, false));
|
||||||
|
|
||||||
members.push_back({});
|
members.push_back({});
|
||||||
members.back()["encode"] = memberTempl.render();
|
members.back()["encode"] = memberTempl.render();
|
||||||
@ -909,7 +909,7 @@ string ABIFunctions::abiEncodingFunctionFunctionType(
|
|||||||
FunctionType const& _from,
|
FunctionType const& _from,
|
||||||
Type const& _to,
|
Type const& _to,
|
||||||
bool _encodeAsLibraryTypes,
|
bool _encodeAsLibraryTypes,
|
||||||
bool _compacted
|
bool _fromStack
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solAssert(_from.kind() == FunctionType::Kind::External, "");
|
solAssert(_from.kind() == FunctionType::Kind::External, "");
|
||||||
@ -920,24 +920,10 @@ string ABIFunctions::abiEncodingFunctionFunctionType(
|
|||||||
_from.identifier() +
|
_from.identifier() +
|
||||||
"_to_" +
|
"_to_" +
|
||||||
_to.identifier() +
|
_to.identifier() +
|
||||||
(_compacted ? "_compacted" : "") +
|
(_fromStack ? "_fromStack" : "") +
|
||||||
(_encodeAsLibraryTypes ? "_library" : "");
|
(_encodeAsLibraryTypes ? "_library" : "");
|
||||||
|
|
||||||
if (_compacted)
|
if (_fromStack)
|
||||||
{
|
|
||||||
return createFunction(functionName, [&]() {
|
|
||||||
return Whiskers(R"(
|
|
||||||
function <functionName>(addr_and_function_id, pos) {
|
|
||||||
mstore(pos, <cleanExtFun>(addr_and_function_id))
|
|
||||||
}
|
|
||||||
)")
|
|
||||||
("functionName", functionName)
|
|
||||||
("cleanExtFun", cleanupCombinedExternalFunctionIdFunction())
|
|
||||||
.render();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return createFunction(functionName, [&]() {
|
return createFunction(functionName, [&]() {
|
||||||
return Whiskers(R"(
|
return Whiskers(R"(
|
||||||
function <functionName>(addr, function_id, pos) {
|
function <functionName>(addr, function_id, pos) {
|
||||||
@ -948,7 +934,17 @@ string ABIFunctions::abiEncodingFunctionFunctionType(
|
|||||||
("combineExtFun", combineExternalFunctionIdFunction())
|
("combineExtFun", combineExternalFunctionIdFunction())
|
||||||
.render();
|
.render();
|
||||||
});
|
});
|
||||||
|
else
|
||||||
|
return createFunction(functionName, [&]() {
|
||||||
|
return Whiskers(R"(
|
||||||
|
function <functionName>(addr_and_function_id, pos) {
|
||||||
|
mstore(pos, <cleanExtFun>(addr_and_function_id))
|
||||||
}
|
}
|
||||||
|
)")
|
||||||
|
("functionName", functionName)
|
||||||
|
("cleanExtFun", cleanupCombinedExternalFunctionIdFunction())
|
||||||
|
.render();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
string ABIFunctions::copyToMemoryFunction(bool _fromCalldata)
|
string ABIFunctions::copyToMemoryFunction(bool _fromCalldata)
|
||||||
|
@ -89,13 +89,13 @@ private:
|
|||||||
|
|
||||||
/// @returns the name of the ABI encoding function with the given type
|
/// @returns the name of the ABI encoding function with the given type
|
||||||
/// and queues the generation of the function to the requested functions.
|
/// and queues the generation of the function to the requested functions.
|
||||||
/// @param _compacted if true, the input value was just loaded from storage
|
/// @param _fromStack if false, the input value was just loaded from storage
|
||||||
/// or memory and thus might be compacted into a single slot (depending on the type).
|
/// or memory and thus might be compacted into a single slot (depending on the type).
|
||||||
std::string abiEncodingFunction(
|
std::string abiEncodingFunction(
|
||||||
Type const& _givenType,
|
Type const& _givenType,
|
||||||
Type const& _targetType,
|
Type const& _targetType,
|
||||||
bool _encodeAsLibraryTypes,
|
bool _encodeAsLibraryTypes,
|
||||||
bool _compacted
|
bool _fromStack
|
||||||
);
|
);
|
||||||
/// Part of @a abiEncodingFunction for array target type and given calldata array.
|
/// Part of @a abiEncodingFunction for array target type and given calldata array.
|
||||||
std::string abiEncodingFunctionCalldataArray(
|
std::string abiEncodingFunctionCalldataArray(
|
||||||
@ -143,7 +143,7 @@ private:
|
|||||||
FunctionType const& _from,
|
FunctionType const& _from,
|
||||||
Type const& _to,
|
Type const& _to,
|
||||||
bool _encodeAsLibraryTypes,
|
bool _encodeAsLibraryTypes,
|
||||||
bool _compacted
|
bool _fromStack
|
||||||
);
|
);
|
||||||
|
|
||||||
/// @returns a function that copies raw bytes of dynamic length from calldata
|
/// @returns a function that copies raw bytes of dynamic length from calldata
|
||||||
|
Loading…
Reference in New Issue
Block a user