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
@@ -2,38 +2,38 @@ contract c {
bytes data;
function test_short() public returns (uint256 r) {
assembly {
sstore(data_slot, 0)
sstore(data.slot, 0)
}
for (uint8 i = 0; i < 15; i++) {
data.push(bytes1(i));
}
assembly {
r := sload(data_slot)
r := sload(data.slot)
}
}
function test_long() public returns (uint256 r) {
assembly {
sstore(data_slot, 0)
sstore(data.slot, 0)
}
for (uint8 i = 0; i < 33; i++) {
data.push(bytes1(i));
}
assembly {
r := sload(data_slot)
r := sload(data.slot)
}
}
function test_pop() public returns (uint256 r) {
assembly {
sstore(data_slot, 0)
sstore(data.slot, 0)
}
for (uint8 i = 0; i < 32; i++) {
data.push(bytes1(i));
}
data.pop();
assembly {
r := sload(data_slot)
r := sload(data.slot)
}
}
}
@@ -6,7 +6,7 @@ contract C {
data.push(123);
delete data;
assembly {
ret := sload(data_slot)
ret := sload(data.slot)
}
}