readPushByteOp static method

ByteConstBlock readPushByteOp(
  1. Uint8List program,
  2. int pc
)

Implementation

static ByteConstBlock readPushByteOp(Uint8List program, int pc) {
  var size = 1;
  var result = getUVarint(program, pc + size);
  if (result.length <= 0) {
    throw AlgorandException(
      message: 'could not decode push byte const at pc=$pc',
    );
  }

  size += result.length;
  if (pc + size + result.value > program.length) {
    throw AlgorandException(
      message: '"byte[] const block exceeds program length',
    );
  }

  final buffer = List.filled(result.value, 0);
  buffer.setRange(0, result.value, program, pc + size);
  size += result.value;

  return ByteConstBlock(size, [Uint8List.fromList(buffer)]);
}