library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
}
汇编里slot变量都没有在struct中定义, 这样使用是什么意思?
.slot
不是表示变量,就是表现指针对应的插槽位置。
比如类似的还有: .offset
表示偏移: