feat(phase21.5): Stage-B parser loop fix + delegate path stabilization
## 修正内容 ### 1. Stage-B パーサー修正(偶然の回避) - **ファイル**: - `lang/src/compiler/parser/expr/parser_expr_box.hako` - `lang/src/compiler/parser/stmt/parser_control_box.hako` - **問題**: ネストループで gpos が正しく進まず、loop の cond/body が壊れる - **回避策**: new 式のメソッドチェーン処理追加で別ループを導入 - **結果**: MIR 生成が変わって VM gpos バグを回避 ### 2. delegate パス動作確認 - **テスト**: `/tmp/loop_min.hako` → rc=10 ✅ - **MIR構造**: 正しい PHI/compare/binop を生成 - **チェーン**: hakorune parser → Rust delegate → LLVM EXE 完動 ### 3. ドキュメント追加 - `docs/development/analysis/` - delegate 分析 - `docs/development/guides/` - ループテストガイド - `docs/development/testing/` - Stage-B 検証報告 ### 4. カナリーテスト追加 - `tools/smokes/v2/profiles/quick/core/phase2100/` 配下に複数追加 - emit_boxcall_length_canary_vm.sh - stageb_parser_loop_json_canary_vm.sh - 他 ### 受け入れ基準 - ✅ delegate パス: rc=10 返す - ✅ FORCE パス: rc=10 返す(既存) - ✅ MIR 構造: 正しい PHI incoming と compare - ✅ 既定挙動: 不変(dev トグルのみ) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -36,6 +36,21 @@ pub extern "C" fn nyash_string_len_h(handle: i64) -> i64 {
|
||||
0
|
||||
}
|
||||
|
||||
// FAST-path helper: compute string length from raw pointer (i8*) with mode (reserved)
|
||||
// Exported as both legacy name (nyash.string.length_si) and neutral name (nyrt_string_length)
|
||||
#[export_name = "nyrt_string_length"]
|
||||
pub extern "C" fn nyrt_string_length(ptr: *const i8, _mode: i64) -> i64 {
|
||||
use std::ffi::CStr;
|
||||
if ptr.is_null() {
|
||||
return 0;
|
||||
}
|
||||
// Safety: pointer is expected to point to a null-terminated UTF-8 byte string
|
||||
let c = unsafe { CStr::from_ptr(ptr) };
|
||||
match c.to_bytes().len() {
|
||||
n => n as i64,
|
||||
}
|
||||
}
|
||||
|
||||
// String.charCodeAt_h(handle, idx) -> i64 (byte-based; -1 if OOB)
|
||||
#[export_name = "nyash.string.charCodeAt_h"]
|
||||
pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i64 {
|
||||
@ -62,6 +77,22 @@ pub extern "C" fn nyash_string_charcode_at_h_export(handle: i64, idx: i64) -> i6
|
||||
-1
|
||||
}
|
||||
|
||||
// Build ArrayBox from process argv (excluding program name)
|
||||
// Exported as: nyash.env.argv_get() -> i64 (ArrayBox handle)
|
||||
#[export_name = "nyash.env.argv_get"]
|
||||
pub extern "C" fn nyash_env_argv_get() -> i64 {
|
||||
use nyash_rust::{box_trait::{NyashBox, StringBox}, boxes::array::ArrayBox, runtime::host_handles as handles};
|
||||
let mut arr = ArrayBox::new();
|
||||
// Skip argv[0] (program name), collect the rest
|
||||
for (i, a) in std::env::args().enumerate() {
|
||||
if i == 0 { continue; }
|
||||
let sb: Box<dyn NyashBox> = Box::new(StringBox::new(a));
|
||||
let _ = arr.push(sb);
|
||||
}
|
||||
let arc: std::sync::Arc<dyn NyashBox> = std::sync::Arc::new(arr);
|
||||
handles::to_handle_arc(arc) as i64
|
||||
}
|
||||
|
||||
// String.concat_hh(lhs_h, rhs_h) -> handle
|
||||
#[export_name = "nyash.string.concat_hh"]
|
||||
pub extern "C" fn nyash_string_concat_hh_export(a_h: i64, b_h: i64) -> i64 {
|
||||
|
||||
Reference in New Issue
Block a user