2020-02-10 10:58:36 +00:00
|
|
|
/*
|
|
|
|
This file is part of solidity.
|
|
|
|
|
|
|
|
solidity is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
solidity is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-07-17 14:54:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0
|
2020-02-10 10:58:36 +00:00
|
|
|
|
|
|
|
#include <libsolidity/codegen/ReturnInfo.h>
|
|
|
|
|
|
|
|
#include <libsolidity/ast/Types.h>
|
|
|
|
#include <libsolidity/ast/AST.h>
|
|
|
|
|
|
|
|
using namespace solidity::frontend;
|
|
|
|
using namespace solidity::langutil;
|
|
|
|
|
|
|
|
ReturnInfo::ReturnInfo(EVMVersion const& _evmVersion, FunctionType const& _functionType)
|
|
|
|
{
|
|
|
|
FunctionType::Kind const funKind = _functionType.kind();
|
|
|
|
bool const haveReturndatacopy = _evmVersion.supportsReturndata();
|
|
|
|
bool const returnSuccessConditionAndReturndata =
|
|
|
|
funKind == FunctionType::Kind::BareCall ||
|
|
|
|
funKind == FunctionType::Kind::BareDelegateCall ||
|
|
|
|
funKind == FunctionType::Kind::BareStaticCall;
|
|
|
|
|
|
|
|
if (!returnSuccessConditionAndReturndata)
|
|
|
|
{
|
|
|
|
if (haveReturndatacopy)
|
|
|
|
returnTypes = _functionType.returnParameterTypes();
|
|
|
|
else
|
|
|
|
returnTypes = _functionType.returnParameterTypesWithoutDynamicTypes();
|
|
|
|
|
|
|
|
for (auto const& retType: returnTypes)
|
|
|
|
if (retType->isDynamicallyEncoded())
|
|
|
|
{
|
|
|
|
solAssert(haveReturndatacopy, "");
|
|
|
|
dynamicReturnSize = true;
|
|
|
|
estimatedReturnSize = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (retType->decodingType())
|
|
|
|
estimatedReturnSize += retType->decodingType()->calldataEncodedSize();
|
|
|
|
else
|
|
|
|
estimatedReturnSize += retType->calldataEncodedSize();
|
|
|
|
}
|
|
|
|
}
|