+ else {
+ if (column > 255)
+ column = 255;
+ int target = -1;
+ int delta = 0;
+ int max = checkpoint_index < 10 ?
+ checkpoint_index : 10;
+ for (int i = 0; i < max; i++) {
+ int offset = checkpoints [checkpoint_index - i].LineOffset;
+ delta = row - offset;
+ if (delta >= 0 &&
+ delta < (1 << line_delta_bits) &&
+ checkpoints [checkpoint_index - i].File == current_source) {
+ target = checkpoint_index - i;
+ break;
+ }
+ }
+ if (target == -1) {
+ AddCheckpoint (current_source, row);
+ target = checkpoint_index;
+ delta = row % (1 << line_delta_bits);
+ }
+ long l = column +
+ (long) (delta << column_bits) +
+ (long) (target << (line_delta_bits + column_bits));
+ token = l > 0xFFFFFFFF ? 0 : (int) l;
+ }
+ }
+
+ static void AddCheckpoint (int file, int row)
+ {
+ if (checkpoints.Length == ++checkpoint_index) {
+ Checkpoint [] tmp = new Checkpoint [checkpoint_index * 2];
+ Array.Copy (checkpoints, tmp, checkpoints.Length);
+ checkpoints = tmp;
+ }
+ checkpoints [checkpoint_index] = new Checkpoint (file, row);