2019-11-14 14:43:02 +00:00
|
|
|
library L {
|
|
|
|
function f(uint256[] storage x) public pure returns (uint256) {
|
|
|
|
return 23;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
contract C {
|
|
|
|
uint256[] y;
|
|
|
|
string x;
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() { y.push(42); }
|
2019-11-14 14:43:02 +00:00
|
|
|
function f() public view returns (uint256) {
|
|
|
|
return L.f(y);
|
|
|
|
}
|
|
|
|
function g() public returns (bool, uint256) {
|
|
|
|
uint256 ys;
|
|
|
|
assembly { ys := y_slot }
|
|
|
|
(bool success, bytes memory data) = address(L).delegatecall(abi.encodeWithSelector(L.f.selector, ys));
|
|
|
|
return (success, success ? abi.decode(data,(uint256)) : 0);
|
|
|
|
}
|
|
|
|
function h() public returns (bool, uint256) {
|
|
|
|
uint256 ys;
|
|
|
|
assembly { ys := y_slot }
|
|
|
|
(bool success, bytes memory data) = address(L).call(abi.encodeWithSelector(L.f.selector, ys));
|
|
|
|
return (success, success ? abi.decode(data,(uint256)) : 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ====
|
|
|
|
// EVMVersion: >homestead
|
|
|
|
// ----
|
|
|
|
// library: L
|
|
|
|
// f() -> 23
|
|
|
|
// g() -> true, 23
|
|
|
|
// h() -> true, 23
|