readIntConstBlock static method

IntConstBlock readIntConstBlock(
  1. Uint8List program,
  2. int pc
)

Implementation

static IntConstBlock readIntConstBlock(Uint8List program, int pc) {
  final results = <int>[];
  var size = 1;
  var result = getUVarint(program, pc + size);
  if (result.length <= 0) {
    throw AlgorandException(
      message: 'could not decode int const block at pc=$pc',
    );
  }

  size += result.length;
  var numInts = result.value;
  for (var i = 0; i < numInts; i++) {
    if (pc + size >= program.length) {
      throw AlgorandException(
        message: 'int const block exceeds program length',
      );
    }
    result = getUVarint(program, pc + size);
    if (result.length <= 0) {
      throw AlgorandException(
        message: 'could not decode int const[$i] block at pc=${pc + size}',
      );
    }
    size += result.length;
    results.add(result.value);
  }

  return IntConstBlock(size, results);
}