feat(joinir): Phase 65-2-A StringBox メソッド型ヒント実装
Phase 65-2-A 完了:P3-A(StringBox メソッド)型ヒント実装 ## 実装内容 ### 1. type_inference.rs 新規作成 - `infer_method_return_type()`: StringBox/ArrayBox/MapBox メソッド型推論 - `infer_box_type()`: Box コンストラクタ型推論(Phase 65-2-B 用) - 8 テスト全て PASS ### 2. JoinInst::MethodCall に type_hint 追加 - `src/mir/join_ir/mod.rs`: `type_hint: Option<MirType>` フィールド追加 - 段階的拡大のため Optional 設計(既存コード破壊なし) ### 3. read_quoted.rs で型ヒント設定 - substring() → String(4箇所) - length() → Integer(1箇所) - read_quoted 系関数で完全な型ヒント供給 ### 4. 汎用経路は None で後方互換性維持 - expr.rs: 汎用 MethodCall は `type_hint: None` - convert.rs: 型ヒント追加(Phase 65-3 で活用予定) - json.rs: JSON シリアライズ対応 ## テスト結果 - ✅ type_inference モジュール: 8/8 PASS - ✅ ビルド: 0 エラー ## 次のステップ - Phase 65-2-B: Box コンストラクタ型ヒント実装 --- 🌟 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -99,6 +99,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: receiver_var,
|
||||
method: method_name.to_string(),
|
||||
args: arg_vars,
|
||||
type_hint: None, // Phase 65-2-A: 汎用経路では None(Phase 65-3 で型推論追加予定)
|
||||
};
|
||||
|
||||
// すべての命令を結合(receiver → args → MethodCall の順)
|
||||
@ -312,6 +313,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: func_var,
|
||||
method: "__call__".to_string(),
|
||||
args: arg_vars,
|
||||
type_hint: None, // Phase 65-2-A: __call__ は汎用的なため型推論不可
|
||||
};
|
||||
|
||||
let mut insts = arg_insts;
|
||||
|
||||
@ -149,6 +149,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: s_param,
|
||||
method: "substring".to_string(),
|
||||
args: vec![i_var, i_plus_1],
|
||||
type_hint: Some(crate::mir::MirType::String), // Phase 65-2-A: substring → String
|
||||
});
|
||||
|
||||
// Guard 条件: first_char != '"'
|
||||
@ -194,6 +195,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: s_param,
|
||||
method: "length".to_string(),
|
||||
args: vec![],
|
||||
type_hint: Some(crate::mir::MirType::Integer), // Phase 65-2-A: length → Integer
|
||||
});
|
||||
ctx.register_param("n".to_string(), n_var);
|
||||
|
||||
@ -315,6 +317,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: step_s,
|
||||
method: "substring".to_string(),
|
||||
args: vec![step_i, step_i_plus_1],
|
||||
type_hint: Some(crate::mir::MirType::String), // Phase 65-2-A: substring → String
|
||||
});
|
||||
|
||||
// 3. Break 条件: ch == '"'
|
||||
@ -389,6 +392,7 @@ impl AstToJoinIrLowerer {
|
||||
receiver: step_s,
|
||||
method: "substring".to_string(),
|
||||
args: vec![i_esc, i_esc_plus_1],
|
||||
type_hint: Some(crate::mir::MirType::String), // Phase 65-2-A: substring → String
|
||||
});
|
||||
|
||||
// IfMerge: if-body 後の i と ch をマージ
|
||||
|
||||
Reference in New Issue
Block a user