decode static method
- Object? encoded
Decodes a validated value; malformed or truncated values throw.
Implementation
static LogicValue decode(Object? encoded) {
if (encoded is! Map<String, Object?>) {
throw const FormatException('A memory value must be an object.');
}
final width = encoded['width'];
final bits = encoded['bits'];
if (width is! int ||
width <= 0 ||
bits is! String ||
bits.length != width ||
!RegExp(r'^[01xXzZ]+$').hasMatch(bits)) {
throw const FormatException('Expected width and exact four-state bits.');
}
return LogicValue.ofString(bits.toLowerCase());
}