load method
- MemoryStorageImage image, {
- bool replace = false,
override
Validates the complete image before changing state.
Overlay retains unspecified entries. Replace uses the family's initial state for unspecified entries (CSR reset values; empty sparse storage).
Implementation
@override
void load(MemoryStorageImage image, {bool replace = false}) {
for (final entry in image.entries.entries) {
_validate(entry.key, entry.value);
}
if (image.uncertainWrites.isNotEmpty) {
final target = storage;
if (target is! SymbolicMemoryStorage) {
throw UnsupportedError(
'This storage cannot restore symbolic uncertain writes.');
}
final symbolic = target as SymbolicMemoryStorage;
if (symbolic.symbolicAddressMappingId != image.symbolicAddressMappingId) {
throw ArgumentError('Symbolic address mappings do not match.');
}
symbolic.loadSymbolicState(
{
for (final entry in image.entries.entries)
_address(entry.key): entry.value
},
image.uncertainWrites,
replace: replace,
);
return;
}
if (replace) {
storage.reset();
}
for (final entry in image.entries.entries) {
storage.setData(_address(entry.key), _storedValue(entry.value));
}
}