readByteConstBlock static method
Implementation
static ByteConstBlock readByteConstBlock(Uint8List program, int pc) {
final results = <Uint8List>[];
var size = 1;
var result = getUVarint(program, pc + size);
if (result.length <= 0) {
throw AlgorandException(
message: 'could not decode byte[] 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: 'byte[] 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;
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);
results.add(Uint8List.fromList(buffer));
size += result.value;
}
return ByteConstBlock(size, results);
}