2020-03-20 23:32:30 +00:00
|
|
|
contract Test {
|
|
|
|
struct S {
|
|
|
|
uint8 x;
|
|
|
|
uint16 y;
|
|
|
|
uint256 z;
|
|
|
|
}
|
|
|
|
struct X {
|
|
|
|
uint8 x;
|
|
|
|
S s;
|
|
|
|
uint8[2] a;
|
|
|
|
}
|
|
|
|
X m_x;
|
|
|
|
|
|
|
|
function load()
|
|
|
|
public
|
|
|
|
returns (
|
|
|
|
uint256 a,
|
|
|
|
uint256 x,
|
|
|
|
uint256 y,
|
|
|
|
uint256 z,
|
|
|
|
uint256 a1,
|
|
|
|
uint256 a2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_x.x = 1;
|
|
|
|
m_x.s.x = 2;
|
|
|
|
m_x.s.y = 3;
|
|
|
|
m_x.s.z = 4;
|
|
|
|
m_x.a[0] = 5;
|
|
|
|
m_x.a[1] = 6;
|
|
|
|
X memory d = m_x;
|
|
|
|
a = d.x;
|
|
|
|
x = d.s.x;
|
|
|
|
y = d.s.y;
|
|
|
|
z = d.s.z;
|
|
|
|
a1 = d.a[0];
|
|
|
|
a2 = d.a[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
function store()
|
|
|
|
public
|
|
|
|
returns (
|
|
|
|
uint256 a,
|
|
|
|
uint256 x,
|
|
|
|
uint256 y,
|
|
|
|
uint256 z,
|
|
|
|
uint256 a1,
|
|
|
|
uint256 a2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
X memory d;
|
|
|
|
d.x = 1;
|
|
|
|
d.s.x = 2;
|
|
|
|
d.s.y = 3;
|
|
|
|
d.s.z = 4;
|
|
|
|
d.a[0] = 5;
|
|
|
|
d.a[1] = 6;
|
|
|
|
m_x = d;
|
|
|
|
a = m_x.x;
|
|
|
|
x = m_x.s.x;
|
|
|
|
y = m_x.s.y;
|
|
|
|
z = m_x.s.z;
|
|
|
|
a1 = m_x.a[0];
|
|
|
|
a2 = m_x.a[1];
|
|
|
|
}
|
|
|
|
}
|
2020-12-09 17:38:17 +00:00
|
|
|
// ====
|
|
|
|
// compileViaYul: also
|
2020-03-20 23:32:30 +00:00
|
|
|
// ----
|
|
|
|
// load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
|
2021-04-13 10:13:45 +00:00
|
|
|
// gas irOptimized: 111580
|
2021-02-12 12:45:15 +00:00
|
|
|
// gas legacy: 113999
|
|
|
|
// gas legacyOptimized: 106281
|
2020-03-20 23:32:30 +00:00
|
|
|
// store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
|