mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Finishes external call implementation.
This commit is contained in:
committed by
chriseth
parent
96709b3285
commit
c92fe69a60
@@ -0,0 +1,17 @@
|
||||
pragma solidity >= 0.6.0;
|
||||
|
||||
contract C {
|
||||
function h(uint[4] memory n) public pure returns (uint) {
|
||||
return n[0] + n[1] + n[2] + n[3];
|
||||
}
|
||||
|
||||
function i(uint[4] memory n) public view returns (uint) {
|
||||
return this.h(n) * 2;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// h(uint256[4]): 1, 2, 3, 4 -> 10
|
||||
// i(uint256[4]): 1, 2, 3, 4 -> 20
|
||||
@@ -0,0 +1,17 @@
|
||||
pragma solidity >= 0.6.0;
|
||||
|
||||
contract C {
|
||||
function g(uint n) external pure returns (uint) {
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
function f(uint n) public view returns (uint) {
|
||||
return this.g(2 * n);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// g(uint256): 4 -> 5
|
||||
// f(uint256): 2 -> 5
|
||||
@@ -0,0 +1,24 @@
|
||||
pragma solidity >= 0.6.0;
|
||||
|
||||
contract C {
|
||||
function d(uint n) external pure returns (uint[] memory) {
|
||||
uint[] memory data = new uint[](n);
|
||||
for (uint i = 0; i < data.length; ++i)
|
||||
data[i] = i;
|
||||
return data;
|
||||
}
|
||||
|
||||
function dt(uint n) public view returns (uint) {
|
||||
uint[] memory data = this.d(n);
|
||||
uint sum = 0;
|
||||
for (uint i = 0; i < data.length; ++i)
|
||||
sum += data[i];
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// dt(uint256): 4 -> 6
|
||||
Reference in New Issue
Block a user