Merge pull request #8984 from ethereum/sol-yul-refactor-internal-dispatch-for-multislot-arguments

[Sol->Yul] Internal dispatch for multislot arguments
This commit is contained in:
chriseth 2020-05-19 19:23:25 +02:00 committed by GitHub
commit d1512223d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -153,7 +153,7 @@ string IRGenerationContext::internalDispatch(size_t _in, size_t _out)
for (auto const& contract: mostDerivedContract().annotation().linearizedBaseContracts)
for (FunctionDefinition const* function: contract->definedFunctions())
if (
FunctionType const* functionType = TypeProvider::function(*function)->asCallableFunction(false);
FunctionType const* functionType = TypeProvider::function(*function, FunctionType::Kind::Internal);
!function->isConstructor() &&
TupleType(functionType->parameterTypes()).sizeOnStack() == _in &&
TupleType(functionType->returnParameterTypes()).sizeOnStack() == _out

View File

@ -0,0 +1,31 @@
contract C {
function m(
function() external returns (uint) a,
function() external returns (uint) b
) internal returns (function() external returns (uint)) {
return a;
}
function s(uint a, uint b) internal returns (uint) {
return a + b;
}
function foo() external returns (uint) {
return 6;
}
function test() public returns (uint) {
function(uint, uint) internal returns (uint) single_slot_function = s;
function(
function() external returns (uint),
function() external returns (uint)
) internal returns (function() external returns (uint)) multi_slot_function = m;
return multi_slot_function(this.foo, this.foo)() + single_slot_function(5, 1);
}
}
// ====
// compileViaYul: also
// ----
// test() -> 12