Phase 12.7完了 + ChatGPT5によるVMリファクタリング

## 📚 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>
This commit is contained in:
Moe Charm
2025-09-04 03:41:02 +09:00
parent 7455c9ec97
commit 6488b0542e
57 changed files with 3803 additions and 3871 deletions

View File

@ -71,6 +71,19 @@ pub enum MirInstruction {
args: Vec<ValueId>,
effects: EffectMask,
},
/// Create a function value (FunctionBox) from params/body and optional captures
/// `%dst = function_new [params] {body} [captures...]`
/// Minimal lowering support: captures may be empty; 'me' is optional.
FunctionNew {
dst: ValueId,
params: Vec<String>,
body: Vec<crate::ast::ASTNode>,
/// Pairs of (name, value) to capture by value
captures: Vec<(String, ValueId)>,
/// Optional 'me' value to capture weakly if it is a BoxRef at runtime
me: Option<ValueId>,
},
/// Box method invocation
/// `%dst = invoke %box.method(%args...)`
@ -454,6 +467,8 @@ impl MirInstruction {
// Phase 9.7: External Function Calls
MirInstruction::ExternCall { effects, .. } => *effects, // Use provided effect mask
// Function value construction: treat as pure with allocation
MirInstruction::FunctionNew { .. } => EffectMask::PURE.add(Effect::Alloc),
}
}
@ -479,6 +494,7 @@ impl MirInstruction {
MirInstruction::WeakRef { dst, .. } |
MirInstruction::FutureNew { dst, .. } |
MirInstruction::Await { dst, .. } => Some(*dst),
MirInstruction::FunctionNew { dst, .. } => Some(*dst),
MirInstruction::Call { dst, .. } |
MirInstruction::BoxCall { dst, .. } |
@ -540,6 +556,12 @@ impl MirInstruction {
used.extend(args);
used
},
MirInstruction::FunctionNew { captures, me, .. } => {
let mut used: Vec<ValueId> = Vec::new();
used.extend(captures.iter().map(|(_, v)| *v));
if let Some(m) = me { used.push(*m); }
used
}
MirInstruction::BoxCall { box_val, args, .. } | MirInstruction::PluginInvoke { box_val, args, .. } => {
let mut used = vec![*box_val];