emitCopy function
Implementation
List<int?> emitCopy(List<int?> opcodes, Uint8List source, int offset, int len) {
int code, codeIdx;
opcodes.add(null);
codeIdx = opcodes.length - 1;
code = 0x80; // set the MSB
// offset and length are written using a compact encoding
// where the state of 7 lower bits specify the meaning of
// the bytes that follow
if (offset & 0xff > 0) {
opcodes.add(offset & 0xff);
code |= 0x01;
}
if (offset & 0xff00 > 0) {
opcodes.add(_zeroFillRightShift((offset & 0xff00), 8));
code |= 0x02;
}
if (offset & 0xff0000 > 0) {
opcodes.add(_zeroFillRightShift((offset & 0xff0000), 16));
code |= 0x04;
}
if (offset & 0xff000000 > 0) {
opcodes.add(_zeroFillRightShift((offset & 0xff000000), 24));
code |= 0x08;
}
if (len & 0xff > 0) {
opcodes.add(len & 0xff);
code |= 0x10;
}
if (len & 0xff00 > 0) {
opcodes.add(_zeroFillRightShift((len & 0xff00), 8));
code |= 0x20;
}
if (len & 0xff0000 > 0) {
opcodes.add(_zeroFillRightShift((len & 0xff0000), 16));
code |= 0x40;
}
// place the code at its position
opcodes[codeIdx] = code;
return opcodes;
}