fix(tvix/eval): ensure disassembler prints continous lines correctly

There can be different spans on the same line, so the previous
implementation would duplicate line numbers unnecessarily.

Change-Id: I8d8db77177aee0d834a6ec3584641e1bd5f31c3e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6434
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-09-03 14:50:50 +03:00 committed by tazjin
parent fc1c50498e
commit d3421c1cb9
2 changed files with 12 additions and 4 deletions

View file

@ -77,4 +77,13 @@ impl Chunk {
panic!("compiler error: chunk missing span for offset {}", offset.0);
}
/// Retrieve the line from which the instruction at `offset` was
/// compiled. Only available when the chunk carries a codemap,
/// i.e. when the disassembler is enabled.
#[cfg(feature = "disassembler")]
pub fn get_line(&self, offset: CodeIdx) -> usize {
let span = self.get_span(offset);
self.codemap.look_up_span(span).begin.line + 1
}
}