Use .slot and .offest to access storage items.

This commit is contained in:
chriseth
2020-07-13 14:59:22 +02:00
parent 8eee3ed3a2
commit fc2e9ec2ff
60 changed files with 158 additions and 133 deletions
@@ -7,9 +7,9 @@ contract C {
uint256 off1;
uint256 off2;
assembly {
sstore(z_slot, 7)
off1 := z_offset
off2 := y_offset
sstore(z.slot, 7)
off1 := z.offset
off2 := y.offset
}
assert(off1 == 0);
assert(off2 == 2);
@@ -8,8 +8,8 @@ contract C {
uint256 off2;
assembly {
function f() -> o1 {
sstore(z_slot, 7)
o1 := y_offset
sstore(z.slot, 7)
o1 := y.offset
}
off2 := f()
}
@@ -10,8 +10,8 @@ contract C {
Data storage x = a;
uint256 off;
assembly {
sstore(x_slot, 7)
off := x_offset
sstore(x.slot, 7)
off := x.offset
}
assert(off == 0);
return true;
@@ -13,7 +13,7 @@ contract C {
bytes32 slot = keccak256(abi.encode(uint(1), uint(0)));
assembly {
_data_slot := slot
_data.slot := slot
}
}