FloatingPointValue.withMappedSubtype constructor

FloatingPointValue.withMappedSubtype({
  1. required LogicValue sign,
  2. required LogicValue exponent,
  3. required LogicValue mantissa,
})

Constructs a FloatingPointValue with a sign, exponent, and mantissa using one of the builders provided from subtypeConstructorMap if available, otherwise using the default constructor.

Implementation

factory FloatingPointValue.withMappedSubtype(
    {required LogicValue sign,
    required LogicValue exponent,
    required LogicValue mantissa}) {
  final key = (exponentWidth: exponent.width, mantissaWidth: mantissa.width);

  if (subtypeConstructorMap.containsKey(key)) {
    return subtypeConstructorMap[key]!(
        sign: sign, exponent: exponent, mantissa: mantissa);
  }

  return FloatingPointValue(
      sign: sign, exponent: exponent, mantissa: mantissa);
}