mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
IR codegen: Handle address() with library type argument and external library calls
This commit is contained in:
@@ -16,6 +16,8 @@ contract C {
|
||||
return fu();
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// f() -> 7, 8
|
||||
// f() -> 7, 8
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
library L {
|
||||
function run(
|
||||
function(uint256) external returns (uint256) _operation,
|
||||
uint256 _a
|
||||
)
|
||||
external
|
||||
returns (uint256)
|
||||
{
|
||||
return _operation(_a);
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
function double(uint256 _a) external returns (uint256) {
|
||||
return _a * _a;
|
||||
}
|
||||
|
||||
function g(uint256 _value) external returns (uint256) {
|
||||
return L.run(this.double, _value);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// g(uint256): 4 -> 16
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
library L {
|
||||
function f(uint256[2] storage _a) external returns (uint256) {
|
||||
return _a[0] * _a[1];
|
||||
}
|
||||
}
|
||||
|
||||
contract C {
|
||||
uint256[2] x;
|
||||
|
||||
function g(uint256 _value) external returns (uint256) {
|
||||
x[0] = x[1] = _value;
|
||||
return L.f(x);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// g(uint256): 4 -> 16
|
||||
@@ -12,6 +12,8 @@ contract C {
|
||||
return success;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// g(uint256,uint256): 1, 1 -> true
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
==== Source: a.sol ====
|
||||
|
||||
import "a.sol" as M;
|
||||
|
||||
library L {
|
||||
function f(uint256 v) external pure returns (uint) {
|
||||
return v * v;
|
||||
}
|
||||
function g(uint256 v) external returns (uint) {
|
||||
return v * v;
|
||||
}
|
||||
}
|
||||
contract C {
|
||||
function addr() public view returns (bool) {
|
||||
return address(M.L) == address(0);
|
||||
}
|
||||
function g(uint256 v) public view returns (uint256) {
|
||||
return M.L.f(v);
|
||||
}
|
||||
function h(uint256 v) public returns (uint256) {
|
||||
(bool success, bytes memory result) = address(M.L).delegatecall(abi.encodeWithSignature("f(uint256)", v));
|
||||
assert(success);
|
||||
return abi.decode(result, (uint256));
|
||||
}
|
||||
function i(uint256 v) public returns (uint256) {
|
||||
(bool success, bytes memory result) = address(M.L).call(abi.encodeWithSignature("f(uint256)", v));
|
||||
assert(success);
|
||||
return abi.decode(result, (uint256));
|
||||
}
|
||||
function j(uint256 v) public returns (uint256) {
|
||||
(bool success, bytes memory result) = address(M.L).delegatecall(abi.encodeWithSignature("g(uint256)", v));
|
||||
assert(success);
|
||||
return abi.decode(result, (uint256));
|
||||
}
|
||||
function k(uint256 v) public returns (uint256) {
|
||||
(bool success, bytes memory result) = address(M.L).call(abi.encodeWithSignature("g(uint256)", v));
|
||||
assert(success);
|
||||
return abi.decode(result, (uint256));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=byzantium
|
||||
// ----
|
||||
// library: L
|
||||
// addr() -> false
|
||||
// g(uint256): 1 -> 1
|
||||
// g(uint256): 2 -> 4
|
||||
// g(uint256): 4 -> 16
|
||||
// h(uint256): 1 -> 1
|
||||
// h(uint256): 2 -> 4
|
||||
// h(uint256): 4 -> 16
|
||||
// i(uint256): 1 -> 1
|
||||
// i(uint256): 2 -> 4
|
||||
// i(uint256): 4 -> 16
|
||||
// j(uint256): 1 -> 1
|
||||
// j(uint256): 2 -> 4
|
||||
// j(uint256): 4 -> 16
|
||||
// k(uint256): 1 -> FAILURE
|
||||
// k(uint256): 2 -> FAILURE
|
||||
// k(uint256): 4 -> FAILURE
|
||||
@@ -6,6 +6,8 @@ contract C {
|
||||
return L.f(v);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// g(uint256): 1 -> 1
|
||||
|
||||
Reference in New Issue
Block a user