Skip to content

Commit

Permalink
read/line: handle tombstone addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Feb 13, 2023
1 parent 7bd8760 commit cd102e8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/read/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ where
Ok(None) => return Ok(None),
Ok(Some(instruction)) => {
if self.row.execute(instruction, &mut self.program) {
return Ok(Some((self.header(), &self.row)));
if self.row.tombstone {
// Perform any reset that was required for the tombstone row.
// Normally this is done when `next_row` is called again, but for
// tombstones we loop immediately.
self.row.reset(self.program.header());
} else {
return Ok(Some((self.header(), &self.row)));
}
}
// Fall through, parse the next instruction, and see if that
// yields a row.
Expand Down Expand Up @@ -633,6 +640,7 @@ pub type LineNumberRow = LineRow;
/// Each row is a copy of the registers of the state machine, as defined in section 6.2.2.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct LineRow {
tombstone: bool,
address: Wrapping<u64>,
op_index: Wrapping<u64>,
file: u64,
Expand All @@ -653,6 +661,7 @@ impl LineRow {
LineRow {
// "At the beginning of each sequence within a line number program, the
// state of the registers is:" -- Section 6.2.2
tombstone: false,
address: Wrapping(0),
op_index: Wrapping(0),
file: 1,
Expand Down Expand Up @@ -878,6 +887,8 @@ impl LineRow {
}

LineInstruction::SetAddress(address) => {
let tombstone_address = !0 >> (64 - program.header().encoding.address_size * 8);
self.tombstone = address == tombstone_address;
self.address.0 = address;
self.op_index.0 = 0;
false
Expand Down

0 comments on commit cd102e8

Please sign in to comment.