serialize method
Implementation
@override
Uint8List serialize(BashExternalScannerState state) {
final output = BytesBuilder(copy: false)
..addByte(state.lastGlobParenDepth & 0xff)
..addByte(state.extWasInDoubleQuote ? 1 : 0)
..addByte(state.extSawOutsideQuote ? 1 : 0)
..addByte(state.heredocs.length & 0xff);
var size = 4;
for (final heredoc in state.heredocs) {
// Preserve the pinned source's check: it counts the three flags but
// omits the following uint32_t length field from this guard.
if (heredoc.delimiter.length + 3 + size >= _serializationBufferSize) {
return Uint8List(0);
}
output
..addByte(heredoc.isRaw ? 1 : 0)
..addByte(heredoc.started ? 1 : 0)
..addByte(heredoc.allowsIndent ? 1 : 0);
final length = ByteData(4)
..setUint32(0, heredoc.delimiter.length, Endian.host);
output
..add(length.buffer.asUint8List())
..add(heredoc.delimiter);
size += 7 + heredoc.delimiter.length;
}
return output.takeBytes();
}