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
|
|
|
// ====
|
2021-04-23 15:59:01 +00:00
|
|
|
// compileToEwasm: also
|
2021-04-29 14:26:21 +00:00
|
|
|
// compileViaYul: also
|
2020-03-20 23:32:30 +00:00
|
|
|
// ----
|
|
|
|
// load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
|
2021-09-15 15:01:40 +00:00
|
|
|
// gas irOptimized: 111179
|
2021-05-18 13:39:08 +00:00
|
|
|
// gas legacy: 112999
|
|
|
|
// gas legacyOptimized: 110881
|
2020-03-20 23:32:30 +00:00
|
|
|
// store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
|