Use IRVariable's in IR code generation and implement tuples.

This commit is contained in:
Daniel Kirchner
2020-02-12 12:36:14 +01:00
parent 6abe0a50b1
commit 3c9f18b749
20 changed files with 855 additions and 649 deletions
@@ -34,8 +34,8 @@ object \"C_10\" {
}
function fun_f_9() -> vloc__4 {
vloc__4 := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
function fun_f_9() -> vloc__4_mpos {
vloc__4_mpos := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
leave
}
@@ -130,8 +130,8 @@ object \"C_10\" {
}
}
function fun_f_9() -> vloc__4 {
vloc__4 := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
function fun_f_9() -> vloc__4_mpos {
vloc__4_mpos := convert_t_stringliteral_9f0adad0a59b05d2e04a1373342b10b9eb16c57c164c8a3bfcbf46dccee39a21_to_t_string_memory_ptr()
leave
}
@@ -38,8 +38,8 @@ object \"C_10\" {
}
function fun_f_9() -> vloc__4 {
vloc__4 := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
function fun_f_9() -> vloc__4_mpos {
vloc__4_mpos := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
leave
}
@@ -138,8 +138,8 @@ object \"C_10\" {
}
}
function fun_f_9() -> vloc__4 {
vloc__4 := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
function fun_f_9() -> vloc__4_mpos {
vloc__4_mpos := convert_t_stringliteral_d6604f85ac07e2b33103a620b3d3d75b0473c7214912beded67b9b624d41c571_to_t_string_memory_ptr()
leave
}
@@ -0,0 +1,16 @@
contract C {
function f() public pure returns (uint, uint, uint) {
return (1, 2, 3);
}
function g() public pure returns (uint a, uint b, uint c) {
(c, b, a) = f();
}
function h() public pure returns (uint a) {
(,,a) = f();
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 2, 1
// h() -> 3
@@ -0,0 +1,18 @@
contract C {
function f() public pure returns (uint, uint, uint) {
return (1, 2, 3);
}
function g() public pure returns (uint x, uint y, uint z) {
(uint c, uint b, uint a) = f();
(x, y, z) = (a, b, c);
}
function h() public pure returns (uint) {
(,,uint a) = f();
return a;
}
}
// ====
// compileViaYul: also
// ----
// g() -> 3, 2, 1
// h() -> 3
@@ -0,0 +1,32 @@
contract C {
uint public x = 17;
function f(uint a1, uint a2) public returns (uint r1, uint r2) {
(uint b1, uint b2) = (a1, a2);
(r1, x, r2) = (b1, b2, b2);
}
function g() public returns (uint a, uint b, uint c) {
uint256[3] memory m;
(m[0], m[1], m[2]) = (1, x, 3);
return (m[2], m[1], m[0]);
}
function h() public returns (uint a, uint b, uint c) {
uint256[3] memory m;
(m[0], m[1], , m[2], m[0]) = (1, x, 3, 4, 42);
return (m[2], m[1], m[0]);
}
function i() public returns (uint a, uint b, uint c, uint d) {
(a) = 42;
(((((b))))) = 23;
c = (((17)));
(((d))) = (13);
}
}
// ====
// compileViaYul: also
// ----
// x() -> 17
// f(uint256,uint256): 23, 42 -> 23, 42
// x() -> 42
// g() -> 3, 42, 1
// h() -> 4, 42, 1
// i() -> 42, 23, 17, 13
@@ -0,0 +1,10 @@
contract C {
function f() public pure returns (uint) {
uint x;
return x;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0
@@ -0,0 +1,14 @@
contract C {
uint256 x;
uint256 y;
function set(uint256 v) public returns (uint256) { x = v; return v; }
function f() public returns (uint256, uint256) {
(y, y, y) = (set(1), set(2), set(3));
assert(y == 1 && x == 3);
return (x, y);
}
}
// ====
// compileViaYul: also
// ----
// f() -> 3, 1