mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Copying of arrays from storage to memory.
This commit is contained in:
@@ -16,5 +16,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 0x20, 0x8, -1, -1, 8, -16, -2, 6, 8, -1
|
||||
|
||||
@@ -6,5 +6,7 @@ contract C {
|
||||
return (b[0], b.length);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 3
|
||||
|
||||
@@ -8,5 +8,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000
|
||||
|
||||
@@ -8,5 +8,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
uint72[5][] a;
|
||||
|
||||
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
|
||||
for (uint i = 0; i < 4; i++)
|
||||
a.push();
|
||||
a[0][0] = 1;
|
||||
a[0][3] = 2;
|
||||
a[1][1] = 3;
|
||||
a[1][4] = 4;
|
||||
a[2][0] = 5;
|
||||
a[3][2] = 6;
|
||||
a[3][3] = 7;
|
||||
uint72[5][] memory m = a;
|
||||
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 2, 3, 4, 5, 6, 7
|
||||
@@ -0,0 +1,13 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
contract C {
|
||||
bytes[] a;
|
||||
|
||||
function f() public returns (bytes[] memory) {
|
||||
a.push("abc");
|
||||
a.push("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ");
|
||||
bytes[] memory m = a;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
|
||||
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
uint72[5][] a;
|
||||
|
||||
function f() public returns (uint72, uint72, uint72, uint72, uint72, uint72, uint72) {
|
||||
for (uint i = 0; i < 4; i++)
|
||||
a.push();
|
||||
a[0][0] = 1;
|
||||
a[0][3] = 2;
|
||||
a[1][1] = 3;
|
||||
a[1][4] = 4;
|
||||
a[2][0] = 5;
|
||||
a[3][2] = 6;
|
||||
a[3][3] = 7;
|
||||
uint72[5][] storage a_ = a;
|
||||
uint72[5][] memory m = a_;
|
||||
return (m[0][0], m[0][3], m[1][1], m[1][4], m[2][0], m[3][2], m[3][3]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 1, 2, 3, 4, 5, 6, 7
|
||||
@@ -0,0 +1,26 @@
|
||||
contract C {
|
||||
struct T { uint8 x; uint8 y; uint[] z; }
|
||||
T[3][] a;
|
||||
|
||||
function f() public returns (uint8, uint8, uint, uint, uint, uint8, uint8, uint, uint, uint) {
|
||||
a.push();
|
||||
a.push();
|
||||
a[0][1].x = 11;
|
||||
a[0][1].y = 12;
|
||||
a[0][1].z.push(1);
|
||||
a[0][1].z.push(2);
|
||||
a[0][1].z.push(3);
|
||||
a[1][2].x = 21;
|
||||
a[1][2].y = 22;
|
||||
a[1][2].z.push(4);
|
||||
a[1][2].z.push(5);
|
||||
a[1][2].z.push(6);
|
||||
T[3][] memory m = a;
|
||||
return (
|
||||
m[0][1].x, m[0][1].y, m[0][1].z[0], m[0][1].z[1], m[0][1].z[2],
|
||||
m[1][2].x, m[1][2].y, m[1][2].z[0], m[1][2].z[1], m[1][2].z[2]
|
||||
);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// f() -> 11, 0x0c, 1, 2, 3, 0x15, 22, 4, 5, 6
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
uint8[33] a;
|
||||
|
||||
function f() public returns (uint8, uint8, uint8) {
|
||||
a[0] = 2;
|
||||
a[16] = 3;
|
||||
a[32] = 4;
|
||||
uint8[33] memory m = a;
|
||||
return (m[0], m[16], m[32]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 2, 3, 4
|
||||
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
uint8[] a;
|
||||
|
||||
function f() public returns (uint8, uint8, uint8) {
|
||||
for (uint i = 0; i < 33; i++)
|
||||
a.push(7);
|
||||
a[0] = 2;
|
||||
a[16] = 3;
|
||||
a[32] = 4;
|
||||
uint8[] memory m = a;
|
||||
return (m[0], m[16], m[32]);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 2, 3, 4
|
||||
@@ -15,5 +15,7 @@ contract Test {
|
||||
return set(data)[1];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07
|
||||
|
||||
@@ -8,5 +8,7 @@ contract c {
|
||||
return keccak256(abi.encodePacked("b", keccak256(data), "a"));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// foo() -> 0xb338eefce206f9f57b83aa738deecd5326dc4b72dd81ee6a7c621a6facb7acdc
|
||||
|
||||
@@ -9,5 +9,7 @@ contract c {
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// foo() -> true
|
||||
|
||||
@@ -23,6 +23,8 @@ contract test {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bool): true -> 1
|
||||
// f(bool): false -> 2
|
||||
|
||||
Reference in New Issue
Block a user