feat(phase-9.75f): ビルトインBox動的ライブラリ分離アーキテクチャ設計

- Gemini先生のアドバイスに基づく実装計画策定
- C ABI + libloading による安定した動的ライブラリ実装
- 段階的移行戦略:インタープリターExternCall → プラグイン化
- FFI-ABI file実装(stdlib方式)完了
- MIRビルダーにfile.read/write/exists追加
- ビルド時間2分→15秒、バイナリ15MB→2MBを目標
- docs/予定/native-plan/issues/phase_9_75f_dynamic_library_architecture.md作成
- CURRENT_TASK.md更新

次のステップ:
- インタープリターでExternCall直接実行実装
- 元のFileBox実装を探して置き換え
- プラグインアーキテクチャ基盤構築
This commit is contained in:
Moe Charm
2025-08-17 03:40:00 +09:00
parent a8e77f6411
commit d396c0ed8c
7 changed files with 367 additions and 2 deletions

View File

@ -926,6 +926,48 @@ impl MirBuilder {
})?;
return Ok(void_id);
},
("file", "read") => {
// Generate ExternCall for file.read
let result_id = self.value_gen.next();
self.emit_instruction(MirInstruction::ExternCall {
dst: Some(result_id), // file.read returns string
iface_name: "env.file".to_string(),
method_name: "read".to_string(),
args: arg_values,
effects: EffectMask::IO, // File operations are I/O
})?;
return Ok(result_id);
},
("file", "write") => {
// Generate ExternCall for file.write
self.emit_instruction(MirInstruction::ExternCall {
dst: None, // file.write is void
iface_name: "env.file".to_string(),
method_name: "write".to_string(),
args: arg_values,
effects: EffectMask::IO, // File operations are I/O
})?;
// Return void value
let void_id = self.value_gen.next();
self.emit_instruction(MirInstruction::Const {
dst: void_id,
value: ConstValue::Void,
})?;
return Ok(void_id);
},
("file", "exists") => {
// Generate ExternCall for file.exists
let result_id = self.value_gen.next();
self.emit_instruction(MirInstruction::ExternCall {
dst: Some(result_id), // file.exists returns bool
iface_name: "env.file".to_string(),
method_name: "exists".to_string(),
args: arg_values,
effects: EffectMask::IO, // File operations are I/O
})?;
return Ok(result_id);
},
_ => {
// Regular method call - continue with BoxCall
}