inline_assembly_storage.sol 444 B

1234567891011121314151617181920
  1. contract foo {
  2. struct test_stru {
  3. uint256 a;
  4. uint256 b;
  5. }
  6. test_stru storage_struct;
  7. function bar() public view {
  8. test_stru storage tts = storage_struct;
  9. assembly {
  10. // The variables 'a' and 'b' contain zero
  11. let a := storage_struct.offset
  12. let b := tts.offset
  13. // This changes the reference slot of 'tts'
  14. tts.slot := 5
  15. }
  16. }
  17. }