fix(view): anchor imported-function returns at their call site
Track the caller line on CallFrame and use it for return annotations instead of the callee library line. Return 950 stays visible on the actual foreign/writeback calls; the Markdown table remains intact and no longer receives stray return chips.
This commit is contained in:
1 parent
064bae2c65
commit
78922102e4
5 files changed
+25
-8
No files matched your search
@@ -89,7 +89,10 @@ impl StmtEventKind {
|
||||
pub struct CallFrame {
|
||||
pub call_id: u32,
|
||||
pub fn_name: String,
|
||||
/// Definition line of the callee.
|
||||
pub fn_line: u32,
|
||||
/// Call site line in the executing document (0 for the entry call).
|
||||
pub call_line: u32,
|
||||
pub ordinal: u32,
|
||||
pub args_brief: String,
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ impl Interpreter {
|
||||
call_id,
|
||||
fn_name: fun.name.clone(),
|
||||
fn_line: fun.span.line,
|
||||
call_line: self.current_span.line,
|
||||
ordinal,
|
||||
args_brief,
|
||||
});
|
||||
|
||||
+15
-2
@@ -205,9 +205,22 @@ pub fn build_view_annots(module: &Module, source: &str, cap: &RunCapture) -> Vec
|
||||
last_ret.insert((ev.line, ev.call_id, ev.loop_id, ev.iter), ev);
|
||||
}
|
||||
}
|
||||
let call_sites: HashMap<u32, u32> = cap
|
||||
.view_trace
|
||||
.calls
|
||||
.iter()
|
||||
.map(|fr| (fr.call_id, fr.call_line))
|
||||
.collect();
|
||||
for ((line, _, _, _), ev) in last_ret {
|
||||
// Return events from an imported library carry the callee's line
|
||||
// number. Anchor the chip at the caller's line instead.
|
||||
let anchor_line = call_sites
|
||||
.get(&ev.call_id)
|
||||
.copied()
|
||||
.filter(|l| *l > 0)
|
||||
.unwrap_or(line);
|
||||
let text = lines
|
||||
.get(line.saturating_sub(1) as usize)
|
||||
.get(anchor_line.saturating_sub(1) as usize)
|
||||
.copied()
|
||||
.unwrap_or("");
|
||||
let mut start = None;
|
||||
@@ -222,7 +235,7 @@ pub fn build_view_annots(module: &Module, source: &str, cap: &RunCapture) -> Vec
|
||||
out.push(ViewAnnot {
|
||||
id: next_id("r"),
|
||||
kind: AnnotKind::Return,
|
||||
anchor_line: line,
|
||||
anchor_line,
|
||||
anchor_byte_start: start,
|
||||
anchor_byte_end: end,
|
||||
label: "return".into(),
|
||||
|
||||
Reference in new issue
Block a user