selfhost: Integrate ChatGPT's using system parser fixes

- Fix using paths in mini_vm_prints.nyash and mini_vm_core.nyash
- Convert multi-line JSON literal to single-line in empty args smoke test
- Remove extra closing brace in mini_vm_core.nyash
- Add verbose logging for using system visited file tracking

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-23 01:23:16 +09:00
parent f1b2e4a7a0
commit 6e6dc9ebe3
5 changed files with 34 additions and 10 deletions

View File

@ -39,7 +39,18 @@ Principles (featurepause)
- `apps/selfhost-runtime/mir_loader.nyash`: FileBox で読込→JsonDocBox で parse→version/kind/body_len を要約 - `apps/selfhost-runtime/mir_loader.nyash`: FileBox で読込→JsonDocBox で parse→version/kind/body_len を要約
- `apps/selfhost-runtime/runner.nyash`: args[0] の JSON を読み、{version:0, kind:"Program"} を検証NGは非0exit - `apps/selfhost-runtime/runner.nyash`: args[0] の JSON を読み、{version:0, kind:"Program"} を検証NGは非0exit
- v0 とハーネスJSON{"functions":…})の両フォーマットを受理。`--trace` で v0 要約/stmt数、ハーネス要約functions数を出力 - v0 とハーネスJSON{"functions":…})の両フォーマットを受理。`--trace` で v0 要約/stmt数、ハーネス要約functions数を出力
- **P1 標準箱のlib化完了**既定OFF・段階導入
- 薄ラッパlib実装: `apps/lib/boxes/{console_std.nyash,string_std.nyash,array_std.nyash,map_std.nyash}`(恒等の薄ラッパ)
- 自己ホスト実行器の導線: `src/runner/modes/pyvm.rs``--box-pref=ny|plugin` 子引数伝達(既定=plugin
- BoxCall ディスパッチ骨格: `apps/selfhost-runtime/{runner.nyash,ops_calls.nyash}` でpref解析・初期化
- **ScopeBox/LoopForm 前処理完了**恒等・導線ON
- 前処理本体恒等apply: `apps/lib/{scopebox_inject.nyash,loopform_normalize.nyash}`
- Selfhost Compiler適用: `apps/selfhost/compiler/compiler.nyash``--scopebox/--loopform` 受理→apply後emit
- Runner env→子引数マップ: `src/runner/selfhost.rs``NYASH_SCOPEBOX_ENABLE=1``--scopebox` 変換
- Smoke 追加(任意実行): `tools/test/smoke/selfhost/selfhost_runner_smoke.sh` - Smoke 追加(任意実行): `tools/test/smoke/selfhost/selfhost_runner_smoke.sh`
- **恒等性確認スモーク追加**:
- ScopeBox恒等: `tools/test/smoke/selfhost/scopebox_identity_smoke.sh`
- LoopForm恒等: `tools/test/smoke/selfhost/loopform_identity_smoke.sh`
- Identity 確認スモークSelfhost Compiler 直呼び) - Identity 確認スモークSelfhost Compiler 直呼び)
- ScopeBox: `tools/test/smoke/selfhost/scopebox_identity_smoke.sh` - ScopeBox: `tools/test/smoke/selfhost/scopebox_identity_smoke.sh`
- LoopForm: `tools/test/smoke/selfhost/loopform_identity_smoke.sh` - LoopForm: `tools/test/smoke/selfhost/loopform_identity_smoke.sh`
@ -256,13 +267,24 @@ JSON / Plugin v2現状に追記
- 命名衝突は採用側の include/using に限定(既存ファイルの広域変更は行わない)。 - 命名衝突は採用側の include/using に限定(既存ファイルの広域変更は行わない)。
TODO段階タスク TODO段階タスク
- [ ] P1: console_std/string_std/array_std/map_std の雛形を追加apps/lib/boxes/ - [x] P1: console_std/string_std/array_std/map_std の雛形を追加apps/lib/boxes/
- [ ] P1: 自己ホスト実行器の BoxCall ディスパッチに `NYASH_SELFHOST_BOX_PREF` を導入(既定=plugin - [x] P1: 自己ホスト実行器の BoxCall ディスパッチに `NYASH_SELFHOST_BOX_PREF` を導入(既定=plugin
- [ ] P1: strings/array/map の最小スモークを selfhost 経路で追加 - [x] ScopeBox/LoopForm 前処理(恒等版)実装+スモーク
- [ ] **今すぐ推奨**: 恒等性スモーク実行(実装検証)
- `tools/test/smoke/selfhost/scopebox_identity_smoke.sh`
- `tools/test/smoke/selfhost/loopform_identity_smoke.sh`
- `tools/test/smoke/selfhost/selfhost_runner_smoke.sh`
- [ ] P1: strings/array/map の最小スモークを selfhost 経路で追加pref=ny
- [ ] P2: path_std/json_std の雛形とアダプタ(プラグイン優先のラップ) - [ ] P2: path_std/json_std の雛形とアダプタ(プラグイン優先のラップ)
- [ ] P2: path/json のスモークdirname/join、parse/root/get/size/at/str/int/bool - [ ] P2: path/json のスモークdirname/join、parse/root/get/size/at/str/int/bool
- [ ] P3: string_builder_std と tests の軽量追加(任意) - [ ] P3: string_builder_std と tests の軽量追加(任意)
**次フェーズ推奨順序**(小粒・安全):
1. ScopeBox 前処理実装安全包み込み。JSON v0互換維持、If/Loop に "ヒント用余剰キー" 付与)
2. LoopForm 前処理実装(キー順正規化→安全な末尾整列)
3. P1 箱スモークpref=ny での一致確認)
4. Stage2自己ホスト実行器: const/ret/branch 骨格exit code パリティ
Checklist更新済み Checklist更新済み
- [x] Selfhost 前展開の固定スモーク 1 本upper_string - [x] Selfhost 前展開の固定スモーク 1 本upper_string
- [x] MacroCtx ctx JSON スモーク 1 本CI 組み込み) - [x] MacroCtx ctx JSON スモーク 1 本CI 組み込み)

View File

@ -745,4 +745,3 @@ static box MiniVm {
return out return out
} }
} }
}

View File

@ -1,8 +1,8 @@
using selfhost.vm.scan as MiniVmScan using selfhost.common.mini_vm_scan as MiniVmScan
using selfhost.vm.binop as MiniVmBinOp using selfhost.common.mini_vm_binop as MiniVmBinOp
using selfhost.vm.compare as MiniVmCompare using selfhost.common.mini_vm_compare as MiniVmCompare
// Use the JSON adapter facade for cursor ops (next_non_ws, digits) // Use the JSON adapter facade for cursor ops (next_non_ws, digits)
using selfhost.vm.json as MiniJsonLoader using selfhost.vm.boxes.json_cur as MiniJsonLoader
static box MiniVmPrints { static box MiniVmPrints {
// dev trace flag (0=OFF) // dev trace flag (0=OFF)

View File

@ -690,7 +690,7 @@ fn nyash_plugin_invoke_name_common_i64(method: &str, argc: i64, a0: i64, a1: i64
} }
let box_type = box_type.unwrap_or_default(); let box_type = box_type.unwrap_or_default();
// Resolve method_id via PluginHost // Resolve method_id via PluginHost
let mh = if let Ok(host) = plugin_loader_unified::get_global_plugin_host().read() { let mh = if let Ok(host) = crate::runtime::plugin_loader_unified::get_global_plugin_host().read() {
host.resolve_method(&box_type, method) host.resolve_method(&box_type, method)
} else { } else {
events::emit_runtime( events::emit_runtime(

View File

@ -166,7 +166,10 @@ pub fn strip_using_and_register(
} }
if let Ok(abs) = std::fs::canonicalize(&p) { p = abs; } if let Ok(abs) = std::fs::canonicalize(&p) { p = abs; }
let key = p.to_string_lossy().to_string(); let key = p.to_string_lossy().to_string();
if visited.contains(&key) { continue; } if visited.contains(&key) {
if verbose { eprintln!("[using] skipping already visited: {}", key); }
continue;
}
visited.insert(key.clone()); visited.insert(key.clone());
if let Ok(text) = std::fs::read_to_string(&p) { if let Ok(text) = std::fs::read_to_string(&p) {
let inlined = strip_and_inline(runner, &text, &key, visited)?; let inlined = strip_and_inline(runner, &text, &key, visited)?;