layout/runtime-rs: kvlang·dump 改名 kvlang·printlib,新增 kvlang·printstack - #348
Merged
Merged
Conversation
dump 这名字没表达它在做什么:它做的是把 layout 结果反出来看——签名读参数定义 键、函数体读线性指令槽,不读 .src 源码副本。改名 printlib,并把「禁读 .src」从 实现细节升格为写进名字与测试的保证:02-printlib.kv 先 printlib 一次,删掉该函数 的 .src 后再 printlib,两次输出须逐字相同。 新增 kvlang·printstack(vid) -> text:printlib 覆盖 /lib(静态代码),printstack 覆盖 /vthread(动态执行态)——把活动栈渲染成文本(帧链 + 每帧实参/命名局部 + 当前指令),供 agent 在同一任务内做「tool → LLM」交替时拿事实(byteseek #69/#72)。 只读,不碰 ‥pc/‥status;vid 空串 = 当前 vthread,从本 rwir 自己的 PC 前缀取。 - C ABI:kvlangLayoutDump → kvlangLayoutPrintlib;新增 kvlangLayoutPrintstack - CLI:kvlang dump / kvlanglayout dump → printlib - rwir 注册表:kvlang·printlib / kvlang·printstack - spec 04-layout语义/08-layout-abi.kv、README(_CN)、kvlangbrief、01-reflect 同步 Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #347
1.
kvlang·dump→kvlang·printlib(改名 + 收紧语义)dump没表达它在做什么:它做的是把 layout 结果反出来看——签名读参数定义键、函数体读线性指令槽,不读
.src源码副本。改名后把这条约束从实现细节升格为写进名字与测试的保证。
验收(
tutorial/13-stdlib/kvlang/02-printlib.kv已锁):printlib 一次 → 删掉该函数的
.src→ 再 printlib,两次输出逐字相同。kvlang·dump(lib)→kvlang·printlib(lib)kvlangLayoutDump→kvlangLayoutPrintlibkvlang dump/kvlanglayout dump→printlib2. 新增
kvlang·printstack(vid) -> textprintlib覆盖/lib(静态代码),printstack覆盖/vthread(动态执行态)。渲染内容:
status/frames计数 /error(若有)/pc,逐帧frame[i] <‥lib>+‥callpc/‥returnpc+ 实参槽[0,±j]与命名局部(text/total/sz这类,需expand_ext才列得出)+ 顶帧cur =当前指令。只读,不碰‥pc/‥status——暂停/恢复是调用方(harness)的事。
vid空串 = 当前 vthread:从本 rwir 自己的 PC 前缀/vthread/<vid>/…取。上游动机是 byteseek(#72 / #69):agent 要在同一任务内做多轮「tool → LLM」交替,
就得把当前活动栈作为事实交给 LLM 决定下一步。
验证
make layout/make runtime-rs/make runtime三者均编译通过nm -D libkvlanglayout.so→kvlangLayoutPrintlib/kvlangLayoutPrintstack(旧kvlangLayoutDump已消失),08-layout-abi.kv同步13-stdlib/kvlang/01-reflect、02-printlib、15-vthread/05-printstack三条 PASS注:shm 后端的
01-reflect仍红,属既有的 shm/fs 列举语义分歧(空目录init/目录尾
/),与本 PR 无关。🤖 Generated with Claude Code