## 📚 Phase 12.7 ドキュメント整理 - ChatGPT5作成のANCP Token仕様書v1を整備 - フォルダ構造を機能別に再編成: - ancp-specs/ : ANCP圧縮技法仕様 - grammar-specs/ : 文法改革仕様 - implementation/ : 実装計画 - ai-feedback/ : AIアドバイザーフィードバック - 各フォルダにREADME.md作成で導線改善 ## 🔧 ChatGPT5によるVMリファクタリング - vm_instructions.rs (1927行) をモジュール分割: - boxcall.rs : Box呼び出し処理 - call.rs : 関数呼び出し処理 - extern_call.rs : 外部関数処理 - function_new.rs : FunctionBox生成 - newbox.rs : Box生成処理 - plugin_invoke.rs : プラグイン呼び出し - VM実行をファイル分割で整理: - vm_state.rs : 状態管理 - vm_exec.rs : 実行エンジン - vm_control_flow.rs : 制御フロー - vm_gc.rs : GC処理 - plugin_loader_v2もモジュール化 ## ✨ 新機能実装 - FunctionBox呼び出しのVM/MIR統一進捗 - ラムダ式のFunctionBox変換テスト追加 - 関数値の直接呼び出し基盤整備 次ステップ: ANCPプロトタイプ実装開始(Week 1) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2.0 KiB
2.0 KiB
Function Values, Captures, and Events
Summary of current behavior and guidelines.
- Function values: created via
function(...) { ... }produce aFunctionBoxwith captured environment (by-ref for locals viaRefCellBox, by-value for globals/statics) and optional weakme. - Assignment cell reflection: assigning to a variable or field bound to
RefCellBoxupdates the inner value instead of replacing the cell. this → me: inside methods,thisis bound asmefor field/method access. External code should preferme.- Parent:: syntax: parser groundwork exists for
Parent::methodreferences; calling from child uses from-call lowering. ?(propagate):expr ?lowers toisOk/getValuebranching and returns early with the Result on error.peek: tokenized and parsed; desugars to if-else chain in VM.
Event APIs
- P2PBox.on/onOnce/off: handlers now accept both
MethodBoxandFunctionBox.MethodBoxhandlers invoke the bound method on receive with arguments(intent, from).FunctionBoxhandlers execute the function body with params bound from(intent, from)(excess args ignored).
Notes
- RefCell-backed locals captured by closures will reflect assignments (
x = ...) in the outer scope. - For plugin-backed boxes, assignment and argument passing uses share semantics to preserve identity.
MIR/VM call unification (Phase 12)
- MIR
Call: accepts either a function name (String) or aFunctionBoxvalue.- If the callee is a String, VM performs a named-function dispatch (existing path).
- If the callee is a
FunctionBox(BoxRef), VM runs it via the interpreter helper with captures/meinjected and proper return propagation.
- Lambda immediate calls are still directly lowered inline for P1 compatibility.
- Lambda→FunctionBox: Lambda expressions now lower to a
FunctionNewMIR instruction that constructs aFunctionBoxvalue (minimal: captures currently omitted). This enables MIR-only pipelines to construct and call function values.