mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
44da8507b1
Co-authored-by: Rodrigo Q. Saramago <rodrigoqsaramago@gmail.com>
33 lines
929 B
Solidity
33 lines
929 B
Solidity
contract receiver {
|
|
uint public received;
|
|
function recv(uint x) public { received += x + 1; }
|
|
fallback() external { received = 0x80; }
|
|
}
|
|
contract sender {
|
|
constructor() { rec = new receiver(); }
|
|
fallback() external { savedData1 = savedData2 = msg.data; }
|
|
function forward(bool selector) public returns (bool) {
|
|
if (selector) { address(rec).call(savedData1); delete savedData1; }
|
|
else { address(rec).call(savedData2); delete savedData2; }
|
|
return true;
|
|
}
|
|
function val() public returns (uint) { return rec.received(); }
|
|
receiver rec;
|
|
bytes savedData1;
|
|
bytes savedData2;
|
|
}
|
|
// ====
|
|
// compileToEwasm: false
|
|
// ----
|
|
// (): 7 ->
|
|
// gas irOptimized: 110820
|
|
// gas legacy: 111388
|
|
// gas legacyOptimized: 111071
|
|
// val() -> 0
|
|
// forward(bool): true -> true
|
|
// val() -> 0x80
|
|
// forward(bool): false -> true
|
|
// val() -> 0x80
|
|
// forward(bool): true -> true
|
|
// val() -> 0x80
|