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
@@ -25,9 +25,9 @@ For an exploratory or audit document, pair `foreign` with `lib/writeback`. `writ
|
||||
|
||||
| Step | What it does |
|
||||
|------|--------------|
|
||||
| `foreign.run` / `foreign.session` | Execute the foreign code and return a Marqdo value |
|
||||
| `writeback.record` | Persist that value in a named slot |
|
||||
| `git diff` | Review the changed result like any other document change |
|
||||
| foreign.run / foreign.session | Execute the foreign code and return a Marqdo value |
|
||||
| writeback.record | Persist that value in a named slot |
|
||||
| git diff | Review the changed result like any other document change |
|
||||
|
||||
A real writeback in this page.
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import writeback:lib/writeback.mq.md
|
||||
|
||||
| 步骤 | 作用 |
|
||||
|------|------|
|
||||
| `外联.运行` / `外联.会话` | 执行外联代码并返回 Marqdo 值 |
|
||||
| `writeback.record` | 把该值持久化到命名槽位 |
|
||||
| `git diff` | 像审阅普通文档改动一样审阅结果 |
|
||||
| 外联.运行 / 外联.会话 | 执行外联代码并返回 Marqdo 值 |
|
||||
| writeback.record | 把该值持久化到命名槽位 |
|
||||
| git diff | 像审阅普通文档改动一样审阅结果 |
|
||||
|
||||
这一页本身就是完整示例。
|
||||
|
||||
|
||||
@@ -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