permute method

  1. @override
int permute(
  1. int instance
)
override

Generates another instance with some deterministic function.

The only exception is Kind.forNull (because it has no other instances).

Implementation

@override
int permute(int instance) {
  if (isRunningInJs) {
    var next = instance + 1;
    if (next > instance) {
      return next;
    }
    if (instance.isNegative) {
      next = instance ~/ 2;
      if (next > instance) {
        return next;
      }
    } else {
      next = 2 * instance;
      if (next > instance) {
        return next;
      }
    }
    return IntKind.minWhenBits(IntKind.bitsWhenJsCompatible);
  } else {
    return instance + 1;
  }
}