phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0
This commit is contained in:
@ -38,17 +38,17 @@ Wiring(Rust 側)
|
||||
3) 成功後は通常のリンク手順(NyRT とリンク)
|
||||
|
||||
Tools / CLI(統合フロー)
|
||||
- crate 直結の EXE 出力: `NYASH_LLVM_COMPILER=crate NYASH_LLVM_EMIT=exe tools/build_llvm.sh apps/tests/ternary_basic.nyash -o app`
|
||||
- crate 直結の EXE 出力: `NYASH_LLVM_COMPILER=crate NYASH_LLVM_EMIT=exe tools/build_llvm.sh apps/tests/ternary_basic.hako -o app`
|
||||
- 環境変数 `NYASH_LLVM_NYRT` で NyRT の場所を、`NYASH_LLVM_LIBS` で追加フラグを指定できる。
|
||||
- CLI から直接 EXE 出力(新規):
|
||||
- `./target/release/nyash --emit-exe tmp/app --backend mir apps/tests/ternary_basic.nyash`
|
||||
- `./target/release/nyash --emit-exe tmp/app --backend mir apps/tests/ternary_basic.hako`
|
||||
- 追加オプション: `--emit-exe-nyrt <dir>` / `--emit-exe-libs "<flags>"`
|
||||
|
||||
Scope(Phase 15)
|
||||
- 最小命令: Const/BinOp/Compare/Branch/Jump/Return(PHI は LLVM 側で合成)
|
||||
- 文字列: NyRT Shim(`nyash.string.len_h`, `charCodeAt_h`, `concat_hh`, `eq_hh`)を declare → call
|
||||
- NewBox/ExternCall/BoxCall: まずは固定シンボル/by-id を優先(段階導入)
|
||||
- 目標: `apps/selfhost/tools/dep_tree_min_string.nyash` の `.ll verify green → .o` 安定化
|
||||
- 目標: `apps/selfhost/tools/dep_tree_min_string.hako` の `.ll verify green → .o` 安定化
|
||||
|
||||
Acceptance
|
||||
- Harness ON/OFF で機能同値(戻り値/検証)。代表ケースで `.ll verify green` と `.o` 生成成功。
|
||||
|
||||
@ -123,7 +123,7 @@ Verifier(検証)に関する追加事項(方針)
|
||||
---
|
||||
|
||||
## 実測結果サマリー(初回プローブ)
|
||||
出所: `local_tests/vm_stats_hello.json`, `local_tests/vm_stats_loop.json`, `simple_math.nyash`
|
||||
出所: `local_tests/vm_stats_hello.json`, `local_tests/vm_stats_loop.json`, `simple_math.hako`
|
||||
|
||||
- ループ系(139命令 / 0.158ms)トップ:
|
||||
- Const: 25, BoxCall: 23, NewBox: 23, BinOp: 11, Branch: 11, Compare: 11, Jump: 11, Phi: 11, Safepoint: 11
|
||||
|
||||
@ -204,9 +204,9 @@ FutureSet %future = %result // 結果設定
|
||||
### **バックエンド互換性テスト**
|
||||
```bash
|
||||
# 全バックエンドMIR一致テスト
|
||||
./target/release/nyash --dump-mir program.nyash > interpreter.mir
|
||||
./target/release/nyash --backend vm --dump-mir program.nyash > vm.mir
|
||||
./target/release/nyash --backend wasm --dump-mir program.nyash > wasm.mir
|
||||
./target/release/nyash --dump-mir program.hako > interpreter.mir
|
||||
./target/release/nyash --backend vm --dump-mir program.hako > vm.mir
|
||||
./target/release/nyash --backend wasm --dump-mir program.hako > wasm.mir
|
||||
diff interpreter.mir vm.mir && diff vm.mir wasm.mir
|
||||
```
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ Policy & Invariants
|
||||
|
||||
Acceptance
|
||||
- Parity on:
|
||||
- `apps/tests/min_str_cat_loop/main.nyash`
|
||||
- `apps/tests/esc_dirname_smoke.nyash`
|
||||
- `apps/tests/min_str_cat_loop/main.hako`
|
||||
- `apps/tests/esc_dirname_smoke.hako`
|
||||
- Stage-2 new smokes (ternary nested, peek return)
|
||||
- `tools/parity.sh --lhs pyvm --rhs llvmlite --show-diff <app>` → green
|
||||
|
||||
|
||||
@ -226,7 +226,7 @@ cd ../../tools/plugin-tester
|
||||
|
||||
### 3. Nyashで実行
|
||||
```nyash
|
||||
// test_http.nyash
|
||||
// test_http.hako
|
||||
local http = new HttpClientBox()
|
||||
local response = http.get("https://api.example.com/data")
|
||||
print(response)
|
||||
|
||||
@ -144,7 +144,7 @@ cd ../../tools/plugin-tester
|
||||
./target/release/plugin-tester ../../plugins/nyash-xxx-plugin/target/release/libnyash_xxx_plugin.so
|
||||
|
||||
# Nyashで実行テスト
|
||||
./target/release/nyash test_xxx.nyash
|
||||
./target/release/nyash test_xxx.hako
|
||||
```
|
||||
|
||||
## 📝 特記事項
|
||||
@ -346,7 +346,7 @@ cd ../../tools/plugin-tester
|
||||
|
||||
### 3. Nyashで実行
|
||||
```nyash
|
||||
// test_http.nyash
|
||||
// test_http.hako
|
||||
local http = new HttpClientBox()
|
||||
local response = http.get("https://api.example.com/data")
|
||||
print(response)
|
||||
|
||||
@ -20,16 +20,16 @@ VMは命令カウントと実行時間を出力できます。
|
||||
使い方(CLIフラグ):
|
||||
```bash
|
||||
# 人間向け表示
|
||||
nyash --backend vm --vm-stats program.nyash
|
||||
nyash --backend vm --vm-stats program.hako
|
||||
|
||||
# JSON出力
|
||||
nyash --backend vm --vm-stats --vm-stats-json program.nyash
|
||||
nyash --backend vm --vm-stats --vm-stats-json program.hako
|
||||
```
|
||||
|
||||
環境変数(直接指定):
|
||||
```bash
|
||||
NYASH_VM_STATS=1 ./target/debug/nyash --backend vm program.nyash
|
||||
NYASH_VM_STATS=1 NYASH_VM_STATS_JSON=1 ./target/debug/nyash --backend vm program.nyash
|
||||
NYASH_VM_STATS=1 ./target/debug/nyash --backend vm program.hako
|
||||
NYASH_VM_STATS=1 NYASH_VM_STATS_JSON=1 ./target/debug/nyash --backend vm program.hako
|
||||
# 代替: NYASH_VM_STATS_FORMAT=json
|
||||
```
|
||||
|
||||
@ -47,9 +47,9 @@ NYASH_VM_STATS=1 NYASH_VM_STATS_JSON=1 ./target/debug/nyash --backend vm program
|
||||
- `scope_tracker` がスコープ終了時に `fini()` を呼ぶ(メモリ安全)。
|
||||
- 大きいボディ/多ヘッダー/タイムアウト
|
||||
- 逐次拡張中。異常時の挙動は上記Result規約に従う。実行ログと `--vm-stats` を併用して診断。
|
||||
- 反復タイムアウト: `local_tests/socket_repeated_timeouts.nyash` で `acceptTimeout/recvTimeout` の連続ケース確認
|
||||
- 反復タイムアウト: `local_tests/socket_repeated_timeouts.hako` で `acceptTimeout/recvTimeout` の連続ケース確認
|
||||
- BoxCallデバッグ: `NYASH_VM_DEBUG_BOXCALL=1` でBoxCallの受け手型・引数型・処理経路(enter/fastpath/unified)・結果型をstderr出力
|
||||
- 例: `NYASH_VM_DEBUG_BOXCALL=1 ./target/release/nyash --backend vm local_tests/test_vm_array_getset.nyash`
|
||||
- 例: `NYASH_VM_DEBUG_BOXCALL=1 ./target/release/nyash --backend vm local_tests/test_vm_array_getset.hako`
|
||||
|
||||
## 🔧 BoxCallの統一経路(Phase 9.79b)
|
||||
|
||||
@ -78,7 +78,7 @@ NYASH_VM_PIC_DEBUG=1 # PICヒットのしきい値通過時にログ
|
||||
- SocketBox(VM)
|
||||
- 基本API: `bind/listen/accept/connect/read/write/close/isServer/isConnected`
|
||||
- タイムアウト: `acceptTimeout(ms)` は接続なしで `void`、`recvTimeout(ms)` は空文字を返す
|
||||
- 簡易E2E: `local_tests/socket_timeout_server.nyash` と `socket_timeout_client.nyash`
|
||||
- 簡易E2E: `local_tests/socket_timeout_server.hako` と `socket_timeout_client.hako`
|
||||
- Void 比較の扱い(VM)
|
||||
- `Void` は値を持たないため、`Eq/Ne` のみ有効。`Void == Void` は真、それ以外の型との `==` は偽(`!=` は真)。
|
||||
- 順序比較(`<, <=, >, >=`)は `TypeError`。
|
||||
@ -89,15 +89,15 @@ NYASH_VM_PIC_DEBUG=1 # PICヒットのしきい値通過時にログ
|
||||
|
||||
```bash
|
||||
# 別ターミナルでサーバ起動
|
||||
./target/release/nyash local_tests/http_server_statuses.nyash
|
||||
./target/release/nyash local_tests/http_server_statuses.hako
|
||||
|
||||
# クライアント(別ターミナル)
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_ok.nyash vm_stats_ok.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_404.nyash vm_stats_404.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_500.nyash vm_stats_500.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_ok.hako vm_stats_ok.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_404.hako vm_stats_404.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_500.hako vm_stats_500.json
|
||||
|
||||
# 到達不能(サーバ不要)
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_err.nyash vm_stats_err.json
|
||||
tools/run_vm_stats.sh local_tests/vm_stats_http_err.hako vm_stats_err.json
|
||||
```
|
||||
|
||||
期待されるResultモデル
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
2. **動作テスト作成**
|
||||
```nyash
|
||||
// local_tests/test_http_builtin.nyash
|
||||
// local_tests/test_http_builtin.hako
|
||||
static box Main {
|
||||
main() {
|
||||
local server = new HTTPServerBox()
|
||||
|
||||
@ -54,7 +54,7 @@ Destruction order (no strong-cycle):
|
||||
## Quick Smoke
|
||||
```bash
|
||||
cargo build -j32
|
||||
./target/debug/nyash local_tests/p2p_self_ping.nyash
|
||||
./target/debug/nyash local_tests/p2p_self_ping.hako
|
||||
# Expect:
|
||||
# last intent: ping
|
||||
# last from: alice
|
||||
|
||||
@ -44,11 +44,11 @@ Implementation note (Phase‑0): no busy loop. Use cooperative queues; later rep
|
||||
- Causality: producers must emit before consumers observe; timestamps monotonic per process.
|
||||
|
||||
### Test Plan (smokes)
|
||||
- ping_pong.nyash: two routines exchange N messages; assert order and count.
|
||||
- bounded_pc.nyash: producer/consumer with capacity=1..N; ensure no busy-wait and correct totals.
|
||||
- select_two.nyash: two channels; verify first-ready choice and distribution.
|
||||
- close_semantics.nyash: send after close -> error; drain -> End; double close -> error.
|
||||
- scope_cancel.nyash: RoutineScopeBox cancels children; parked receivers unblocked.
|
||||
- ping_pong.hako: two routines exchange N messages; assert order and count.
|
||||
- bounded_pc.hako: producer/consumer with capacity=1..N; ensure no busy-wait and correct totals.
|
||||
- select_two.hako: two channels; verify first-ready choice and distribution.
|
||||
- close_semantics.hako: send after close -> error; drain -> End; double close -> error.
|
||||
- scope_cancel.hako: RoutineScopeBox cancels children; parked receivers unblocked.
|
||||
|
||||
### Migration Path
|
||||
- Phase‑0 userland boxes are kept while Phase‑2 runtime grows; API stable.
|
||||
|
||||
@ -21,10 +21,10 @@ paths = ["apps", "lib", "."]
|
||||
|
||||
[using.json_native]
|
||||
path = "apps/lib/json_native/"
|
||||
main = "parser/parser.nyash"
|
||||
main = "parser/parser.hako"
|
||||
|
||||
[using.string_utils]
|
||||
path = "apps/lib/json_native/utils/string.nyash"
|
||||
path = "apps/lib/json_native/utils/string.hako"
|
||||
|
||||
[using.aliases]
|
||||
json = "json_native"
|
||||
|
||||
@ -163,7 +163,7 @@ box ConflictNode from ParentA, ParentB {
|
||||
#### 重複定義エラー
|
||||
```
|
||||
Error: Method 'send' is already defined in this box at line 15.
|
||||
--> box.nyash:20:5
|
||||
--> box.hako:20:5
|
||||
|
|
||||
20 | send(msg) {
|
||||
| ^^^^ duplicate method definition
|
||||
@ -174,7 +174,7 @@ Help: Remove duplicate definition or rename method.
|
||||
#### Missing Override エラー
|
||||
```
|
||||
Error: Method 'send' overrides a parent method. Add 'override' keyword.
|
||||
--> box.nyash:18:5
|
||||
--> box.hako:18:5
|
||||
|
|
||||
18 | send(intent, data, target) {
|
||||
| ^^^^ missing 'override' keyword
|
||||
@ -185,7 +185,7 @@ Help: Change to 'override send(intent, data, target) {'
|
||||
#### Wrong Override エラー
|
||||
```
|
||||
Error: Method 'newMethod' does not exist in any parent. Remove 'override' keyword.
|
||||
--> box.nyash:22:5
|
||||
--> box.hako:22:5
|
||||
|
|
||||
22 | override newMethod() {
|
||||
| ^^^^^^^^ unnecessary 'override'
|
||||
@ -196,7 +196,7 @@ Help: Remove 'override' or verify parent method name.
|
||||
#### 曖昧Override エラー
|
||||
```
|
||||
Error: Method 'process' exists in multiple parents. Specify which parent to override.
|
||||
--> box.nyash:25:5
|
||||
--> box.hako:25:5
|
||||
|
|
||||
25 | override process(data) {
|
||||
| ^^^^^^^^ ambiguous override
|
||||
|
||||
@ -123,10 +123,10 @@ send %bus, %message effects=[BUS]
|
||||
#### **elision ON/OFF同一結果保証**
|
||||
```bash
|
||||
# 最適化ON→高速実行
|
||||
nyash --elide-bus --target wasm program.nyash
|
||||
nyash --elide-bus --target wasm program.hako
|
||||
|
||||
# 最適化OFF→完全分散実行
|
||||
nyash --no-elide-bus --target vm program.nyash
|
||||
nyash --no-elide-bus --target vm program.hako
|
||||
|
||||
# 結果は必ず同一(契約保証)
|
||||
```
|
||||
@ -203,8 +203,8 @@ fn test_bus_elision_equivalence() {
|
||||
echo "🧪 Portability Contract v0 検証中..."
|
||||
|
||||
# 1. MIR出力一致検証
|
||||
nyash --dump-mir test.nyash > golden.mir
|
||||
nyash --dump-mir test.nyash > current.mir
|
||||
nyash --dump-mir test.hako > golden.mir
|
||||
nyash --dump-mir test.hako > current.mir
|
||||
if ! diff golden.mir current.mir; then
|
||||
echo "❌ MIR回帰エラー検出"
|
||||
exit 1
|
||||
@ -213,7 +213,7 @@ fi
|
||||
# 2. 全バックエンド同一出力
|
||||
declare -a backends=("interp" "vm" "wasm")
|
||||
for backend in "${backends[@]}"; do
|
||||
nyash --target $backend test.nyash > ${backend}.out
|
||||
nyash --target $backend test.hako > ${backend}.out
|
||||
done
|
||||
|
||||
# 出力一致確認
|
||||
@ -225,8 +225,8 @@ else
|
||||
fi
|
||||
|
||||
# 3. Bus-elision検証
|
||||
nyash --elide-bus test.nyash > elision_on.out
|
||||
nyash --no-elide-bus test.nyash > elision_off.out
|
||||
nyash --elide-bus test.hako > elision_on.out
|
||||
nyash --no-elide-bus test.hako > elision_off.out
|
||||
if diff elision_on.out elision_off.out; then
|
||||
echo "✅ Bus-elision同一結果"
|
||||
else
|
||||
|
||||
@ -59,7 +59,7 @@ pub type IntentBox = Arc<Mutex<IntentBoxData>>;
|
||||
|
||||
**テストコード**:
|
||||
```nyash
|
||||
// tests/phase2/intent_box_test.nyash
|
||||
// tests/phase2/intent_box_test.hako
|
||||
local msg = new IntentBox("chat.message", { text: "Hello P2P!" })
|
||||
local console = new ConsoleBox()
|
||||
console.log("Name: " + msg.name) // "chat.message"
|
||||
@ -134,7 +134,7 @@ impl P2PBoxData {
|
||||
## 🧪 包括的テスト要件
|
||||
|
||||
### **基本動作テスト**
|
||||
**ファイル**: `test_p2p_basic_new.nyash`
|
||||
**ファイル**: `test_p2p_basic_new.hako`
|
||||
|
||||
```nyash
|
||||
// 2つのノード作成
|
||||
|
||||
@ -42,7 +42,7 @@ Rust製インタープリターによる高性能実行と、直感的な構文
|
||||
| `throw` | 例外発生 | `throw error` |
|
||||
| `nowait` | 非同期実行 | `nowait future = task()` |
|
||||
| `await` | 待機・結果取得 | `result = await future` |
|
||||
| `include` | ファイル取り込み | `include "math.nyash"` |
|
||||
| `include` | ファイル取り込み | `include "math.hako"` |
|
||||
| `print` | 出力(デバッグ用) | `print("Hello")` |
|
||||
| `function`/`fn` | 関数定義 | `fn add(a,b) { }` |
|
||||
| `init` | 初期化ブロック | `init { field1, field2 }` |
|
||||
|
||||
@ -108,14 +108,14 @@ Using resolution is centralized under the `[using]` table. Three forms are suppo
|
||||
- `[using.paths]` — additional search roots for path lookups
|
||||
- Example: `paths = ["apps", "lib", "."]`
|
||||
- `[using.<name>]` — named packages (file or directory)
|
||||
- Keys: `path = "lib/math_utils/"`, optional `main = "math_utils.nyash"`
|
||||
- Keys: `path = "lib/math_utils/"`, optional `main = "math_utils.hako"`
|
||||
- Optional `kind = "dylib"` with `bid = "MathBox"` for plug‑ins (dev only)
|
||||
- `[using.aliases]` — alias mapping from short name to a package name
|
||||
- Example: `aliases.json = "json_native"`
|
||||
|
||||
Notes
|
||||
- Aliases are fully resolved: `using json` first rewrites to `json_native`, then resolves to a concrete path via `[using.json_native]`.
|
||||
- `include` は廃止。代替は `using "./path/to/file.nyash" as Name`。prod では `nyash.toml` への登録が必須。
|
||||
- `include` は廃止。代替は `using "./path/to/file.hako" as Name`。prod では `nyash.toml` への登録が必須。
|
||||
|
||||
Development toggles
|
||||
- Resolution is performed by the Runner when `NYASH_ENABLE_USING=1`(既定ON)。
|
||||
@ -138,7 +138,7 @@ Development toggles
|
||||
|
||||
Syntax
|
||||
- Namespace: `using core.std` or `using core.std as Std`
|
||||
- File path: `using "apps/examples/string_p0.nyash" as Strings`
|
||||
- File path: `using "apps/examples/string_p0.hako" as Strings`
|
||||
- Relative path is allowed; absolute paths are discouraged.
|
||||
|
||||
Style
|
||||
@ -150,7 +150,7 @@ Style
|
||||
Examples
|
||||
```nyash
|
||||
using core.std as Std
|
||||
using "apps/examples/string_p0.nyash" as Strings
|
||||
using "apps/examples/string_p0.hako" as Strings
|
||||
|
||||
static box Main {
|
||||
main(args) {
|
||||
@ -168,7 +168,7 @@ paths = ["apps", "lib", "."]
|
||||
|
||||
[using.json_native]
|
||||
path = "apps/lib/json_native/"
|
||||
main = "parser.nyash"
|
||||
main = "parser.hako"
|
||||
|
||||
[using.aliases]
|
||||
json = "json_native"
|
||||
@ -204,13 +204,13 @@ static box Main {
|
||||
|
||||
Runner Configuration
|
||||
- Enable using pre‑processing: `NYASH_ENABLE_USING=1`
|
||||
- CLI from-the-top registration: `--using "ns as Alias"` or `--using '"apps/foo.nyash" as Foo'` (repeatable)
|
||||
- CLI from-the-top registration: `--using "ns as Alias"` or `--using '"apps/foo.hako" as Foo'` (repeatable)
|
||||
- Using profiles (phase‑in): `NYASH_USING_PROFILE={dev|ci|prod}`
|
||||
- dev: AST マージ 既定ON、legacy前置きは既定で無効(必要時は `NYASH_LEGACY_USING_ALLOW=1` で一時許可)
|
||||
- ci: AST マージ 既定ON、legacy前置きは既定で無効(同上の一時許可)
|
||||
- prod: AST マージ 既定OFF、toml のみ(file using/path はエラー・追記ガイド)
|
||||
- Strict mode (plugin prefix required): `NYASH_PLUGIN_REQUIRE_PREFIX=1` または `nyash.toml` の `[plugins] require_prefix=true`
|
||||
- Aliases from env: `NYASH_ALIASES="Foo=apps/foo/main.nyash,Bar=lib/bar.nyash"`
|
||||
- Aliases from env: `NYASH_ALIASES="Foo=apps/foo/main.hako,Bar=lib/bar.hako"`
|
||||
- Additional search paths: `NYASH_USING_PATH="apps:lib:."`
|
||||
- Selfhost pipeline keeps child stdout quiet and extracts JSON only: `NYASH_JSON_ONLY=1` (set by Runner automatically for child)
|
||||
- Selfhost emits `meta.usings` automatically when present; no additional flags required.
|
||||
@ -273,7 +273,7 @@ Notes
|
||||
|
||||
このセクションは移行期の参考情報です。`include` は設計上の一貫性と学習コスト低減のため廃止しました。今後はすべて `using` に一本化してください(ファイル・パッケージ・DLL すべてを `using` で扱えます)。既存コードの移行は以下の対応例を推奨します。
|
||||
|
||||
- `local M = include "./path/module.nyash"` → `using "./path/module.nyash" as M`
|
||||
- `local M = include "./path/module.hako"` → `using "./path/module.hako" as M`
|
||||
- `include` の探索ルートは `[using.paths]` に統合(`nyash.toml`)
|
||||
|
||||
注: `include` は完全に非推奨です。コードは `using` に書き換えてください(互換シムは提供しません)。
|
||||
@ -283,7 +283,7 @@ Overview
|
||||
|
||||
Syntax
|
||||
```
|
||||
local Math = include "lib/math.nyash"
|
||||
local Math = include "lib/math.hako"
|
||||
local r = Math.add(1, 2)
|
||||
```
|
||||
|
||||
@ -294,7 +294,7 @@ Rules
|
||||
- Path resolution(MVP):
|
||||
- Relative allowed; absolute discouraged
|
||||
- nyash.toml `[include.roots]` で `std=/stdlib` 等のルート定義を許可
|
||||
- 省略拡張は `.nyash`、ディレクトリなら `index.nyash`
|
||||
- 省略拡張は `.hako`、ディレクトリなら `index.hako`
|
||||
|
||||
Backends
|
||||
- Interpreter: 実行時に評価し Box を返す
|
||||
|
||||
@ -49,16 +49,16 @@ nyash.toml example (subject to refinement):
|
||||
```
|
||||
[macros]
|
||||
paths = [
|
||||
"apps/macros/examples/echo_macro.nyash",
|
||||
"apps/macros/examples/upper_string_macro.nyash",
|
||||
"apps/macros/examples/echo_macro.hako",
|
||||
"apps/macros/examples/upper_string_macro.hako",
|
||||
]
|
||||
|
||||
[macro_caps."apps/macros/examples/echo_macro.nyash"]
|
||||
[macro_caps."apps/macros/examples/echo_macro.hako"]
|
||||
io = false
|
||||
net = false
|
||||
env = false
|
||||
|
||||
[macro_caps."apps/macros/examples/upper_string_macro.nyash"]
|
||||
[macro_caps."apps/macros/examples/upper_string_macro.hako"]
|
||||
io = false
|
||||
net = false
|
||||
env = false
|
||||
@ -79,7 +79,7 @@ Phase‑2 PoC maps these to the child process environment/sandbox:
|
||||
|
||||
## Diagnostics/Observability
|
||||
- Trace JSONL: `NYASH_MACRO_TRACE_JSONL=<file>` produces one JSON record per pass with size/time/change flags.
|
||||
- Dump expanded AST: `--dump-expanded-ast-json <file.nyash>` prints AST JSON v0 post‑expansion for golden diffs.
|
||||
- Dump expanded AST: `--dump-expanded-ast-json <file.hako>` prints AST JSON v0 post‑expansion for golden diffs.
|
||||
- Strict mode failures are surfaced with non‑zero exit codes (2/124).
|
||||
|
||||
## Recommendations
|
||||
|
||||
@ -30,7 +30,7 @@ MIRダンプ出力を正しく読み解くためのガイドです。
|
||||
|
||||
## 実例での比較
|
||||
|
||||
### plugin_boxref_return.nyashのMIRダンプ
|
||||
### plugin_boxref_return.hakoのMIRダンプ
|
||||
```mir
|
||||
11: %7 = new FileBox()
|
||||
12: call %7.birth()
|
||||
|
||||
@ -49,4 +49,4 @@
|
||||
## 7. 参考
|
||||
- 仕様: `docs/reference/plugin-system/nyash-toml-v2_1-spec.md`
|
||||
- 実装: `src/runtime/plugin_loader_v2.rs`(引数検証/Handle戻り値復元)
|
||||
- 例: `docs/guides/examples/plugin_boxref_return.nyash`
|
||||
- 例: `docs/guides/examples/plugin_boxref_return.hako`
|
||||
|
||||
@ -175,7 +175,7 @@ search_paths = [
|
||||
"./plugins/*/target/release", # 開発時リリースビルド
|
||||
"./plugins/*/target/debug", # 開発時デバッグビルド
|
||||
"/usr/local/lib/nyash/plugins", # システムインストール
|
||||
"~/.nyash/plugins" # ユーザーローカル
|
||||
"~/.hako/plugins" # ユーザーローカル
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ PyVMは**一般的なプログラム実行には使用しないでください**
|
||||
#### 1. JSON v0ブリッジ機能
|
||||
```bash
|
||||
# セルフホスティング実行(PyVM自動使用)
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.nyash
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.hako
|
||||
```
|
||||
- **用途**: Rust→Python連携でMIR JSON生成
|
||||
- **重要性**: Phase 15.3コンパイラMVP開発に必須
|
||||
@ -20,7 +20,7 @@ NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.nyash
|
||||
#### 2. using処理共通パイプライン
|
||||
```bash
|
||||
# using前処理(PyVM内部使用)
|
||||
./target/release/nyash --enable-using program_with_using.nyash
|
||||
./target/release/nyash --enable-using program_with_using.hako
|
||||
```
|
||||
- **用途**: `strip_using_and_register`統一処理
|
||||
- **重要性**: Rust VM・LLVMとの共通前処理基盤
|
||||
@ -29,7 +29,7 @@ NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.nyash
|
||||
#### 3. サンドボックス実行環境
|
||||
```bash
|
||||
# 開発者の明示的使用(上級者のみ)
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash program.nyash
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash program.hako
|
||||
```
|
||||
- **用途**: 安全なコード実行制御、実験的検証
|
||||
- **対象**: 開発者・研究者の明示的使用のみ
|
||||
@ -39,31 +39,31 @@ NYASH_VM_USE_PY=1 ./target/release/nyash program.nyash
|
||||
#### 1. 一般的なプログラム実行
|
||||
```bash
|
||||
# ❌ 使わないでください
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash my_application.nyash
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash my_application.hako
|
||||
|
||||
# ✅ 代わりにこれを使用
|
||||
./target/release/nyash my_application.nyash # Rust VM
|
||||
./target/release/nyash --backend llvm my_application.nyash # LLVM
|
||||
./target/release/nyash my_application.hako # Rust VM
|
||||
./target/release/nyash --backend llvm my_application.hako # LLVM
|
||||
```
|
||||
|
||||
#### 2. 性能比較・ベンチマーク
|
||||
```bash
|
||||
# ❌ 意味のない比較
|
||||
time NYASH_VM_USE_PY=1 ./target/release/nyash program.nyash
|
||||
time NYASH_VM_USE_PY=1 ./target/release/nyash program.hako
|
||||
|
||||
# ✅ 意味のある比較
|
||||
time ./target/release/nyash program.nyash # Rust VM
|
||||
time ./target/release/nyash --backend llvm program.nyash # LLVM
|
||||
time ./target/release/nyash program.hako # Rust VM
|
||||
time ./target/release/nyash --backend llvm program.hako # LLVM
|
||||
```
|
||||
|
||||
#### 3. 新機能開発・テスト
|
||||
```bash
|
||||
# ❌ PyVMでの新機能テスト
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash new_feature.nyash
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash new_feature.hako
|
||||
|
||||
# ✅ 2本柱での新機能テスト
|
||||
./target/release/nyash new_feature.nyash # Rust VM開発
|
||||
./target/release/nyash --backend llvm new_feature.nyash # LLVM検証
|
||||
./target/release/nyash new_feature.hako # Rust VM開発
|
||||
./target/release/nyash --backend llvm new_feature.hako # LLVM検証
|
||||
```
|
||||
|
||||
## 🎯 **Phase 15推奨実行方法**
|
||||
@ -71,31 +71,31 @@ NYASH_VM_USE_PY=1 ./target/release/nyash new_feature.nyash
|
||||
### **開発・デバッグ・一般用途**
|
||||
```bash
|
||||
# 基本実行(最も推奨)
|
||||
./target/release/nyash program.nyash
|
||||
./target/release/nyash program.hako
|
||||
|
||||
# 詳細診断
|
||||
NYASH_CLI_VERBOSE=1 ./target/release/nyash program.nyash
|
||||
NYASH_CLI_VERBOSE=1 ./target/release/nyash program.hako
|
||||
|
||||
# プラグインエラー対策
|
||||
NYASH_DISABLE_PLUGINS=1 ./target/release/nyash program.nyash
|
||||
NYASH_DISABLE_PLUGINS=1 ./target/release/nyash program.hako
|
||||
```
|
||||
|
||||
### **本番・最適化・配布用途**
|
||||
```bash
|
||||
# LLVM最適化実行
|
||||
./target/release/nyash --backend llvm program.nyash
|
||||
./target/release/nyash --backend llvm program.hako
|
||||
|
||||
# LLVM詳細診断
|
||||
NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend llvm program.nyash
|
||||
NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend llvm program.hako
|
||||
```
|
||||
|
||||
### **セルフホスティング開発用途**
|
||||
```bash
|
||||
# JSON v0ブリッジ(PyVM自動使用)
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.nyash
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.hako
|
||||
|
||||
# using処理テスト
|
||||
./target/release/nyash --enable-using program_with_using.nyash
|
||||
./target/release/nyash --enable-using program_with_using.hako
|
||||
```
|
||||
|
||||
## 📊 **技術的根拠**
|
||||
@ -121,12 +121,12 @@ NYASH_SELFHOST_EXEC=1 ./target/release/nyash program.nyash
|
||||
```bash
|
||||
# ❌ 間違い
|
||||
echo "Performance test:"
|
||||
time NYASH_VM_USE_PY=1 ./target/release/nyash benchmark.nyash
|
||||
time NYASH_VM_USE_PY=1 ./target/release/nyash benchmark.hako
|
||||
|
||||
# ✅ 正しい
|
||||
echo "Performance test:"
|
||||
time ./target/release/nyash benchmark.nyash # Rust VM
|
||||
time ./target/release/nyash --backend llvm benchmark.nyash # LLVM
|
||||
time ./target/release/nyash benchmark.hako # Rust VM
|
||||
time ./target/release/nyash --backend llvm benchmark.hako # LLVM
|
||||
```
|
||||
|
||||
### **誤用例2: デフォルトとしてのPyVM使用**
|
||||
@ -136,16 +136,16 @@ export NYASH_VM_USE_PY=1 # グローバル設定として使用
|
||||
|
||||
# ✅ 正しい
|
||||
# デフォルトはRust VM、特殊用途のみ個別指定
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash selfhost_script.nyash
|
||||
NYASH_SELFHOST_EXEC=1 ./target/release/nyash selfhost_script.hako
|
||||
```
|
||||
|
||||
### **誤用例3: 学習・練習でのPyVM使用**
|
||||
```bash
|
||||
# ❌ 間違い(学習者向け)
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash hello_world.nyash
|
||||
NYASH_VM_USE_PY=1 ./target/release/nyash hello_world.hako
|
||||
|
||||
# ✅ 正しい(学習者向け)
|
||||
./target/release/nyash hello_world.nyash # シンプルで高品質なRust VM
|
||||
./target/release/nyash hello_world.hako # シンプルで高品質なRust VM
|
||||
```
|
||||
|
||||
## 💡 **まとめ**
|
||||
|
||||
@ -13,16 +13,16 @@ MIR仕様の揺れ・バックエンド差異・最適化バグを**即座検出
|
||||
### **基本原理**
|
||||
```bash
|
||||
# 1. MIR「黄金標準」生成
|
||||
nyash --dump-mir program.nyash > program.golden.mir
|
||||
nyash --dump-mir program.hako > program.golden.mir
|
||||
|
||||
# 2. 実行時MIR比較(回帰検出)
|
||||
nyash --dump-mir program.nyash > program.current.mir
|
||||
nyash --dump-mir program.hako > program.current.mir
|
||||
diff program.golden.mir program.current.mir
|
||||
|
||||
# 3. 全バックエンド出力比較(互換検証)
|
||||
nyash --target interp program.nyash > interp.out
|
||||
nyash --target vm program.nyash > vm.out
|
||||
nyash --target wasm program.nyash > wasm.out
|
||||
nyash --target interp program.hako > interp.out
|
||||
nyash --target vm program.hako > vm.out
|
||||
nyash --target wasm program.hako > wasm.out
|
||||
diff interp.out vm.out && diff vm.out wasm.out
|
||||
```
|
||||
|
||||
@ -141,7 +141,7 @@ fn normalize_value_ids(func: &MirFunction) -> MirFunction {
|
||||
// tests/golden_dump/output_compatibility_tests.rs
|
||||
#[test]
|
||||
fn test_cross_backend_arithmetic_output() {
|
||||
let program = "arithmetic_test.nyash";
|
||||
let program = "arithmetic_test.hako";
|
||||
|
||||
let interp_output = run_backend("interp", program);
|
||||
let vm_output = run_backend("vm", program);
|
||||
@ -155,7 +155,7 @@ fn test_cross_backend_arithmetic_output() {
|
||||
|
||||
#[test]
|
||||
fn test_cross_backend_object_lifecycle() {
|
||||
let program = "object_lifecycle_test.nyash";
|
||||
let program = "object_lifecycle_test.hako";
|
||||
|
||||
let results = run_all_backends(program);
|
||||
|
||||
@ -169,7 +169,7 @@ fn test_cross_backend_object_lifecycle() {
|
||||
|
||||
#[test]
|
||||
fn test_cross_backend_weak_reference_behavior() {
|
||||
let program = "weak_reference_test.nyash";
|
||||
let program = "weak_reference_test.hako";
|
||||
|
||||
let results = run_all_backends(program);
|
||||
|
||||
@ -187,10 +187,10 @@ fn test_cross_backend_weak_reference_behavior() {
|
||||
#[test]
|
||||
fn test_cross_backend_error_handling() {
|
||||
let error_programs = [
|
||||
"null_dereference.nyash",
|
||||
"division_by_zero.nyash",
|
||||
"weak_reference_after_fini.nyash",
|
||||
"infinite_recursion.nyash"
|
||||
"null_dereference.hako",
|
||||
"division_by_zero.hako",
|
||||
"weak_reference_after_fini.hako",
|
||||
"infinite_recursion.hako"
|
||||
];
|
||||
|
||||
for program in &error_programs {
|
||||
@ -212,7 +212,7 @@ fn test_cross_backend_error_handling() {
|
||||
// tests/golden_dump/optimization_tests.rs
|
||||
#[test]
|
||||
fn test_bus_elision_output_equivalence() {
|
||||
let program = "bus_communication_test.nyash";
|
||||
let program = "bus_communication_test.hako";
|
||||
|
||||
let elision_on = run_with_flag(program, "--elide-bus");
|
||||
let elision_off = run_with_flag(program, "--no-elide-bus");
|
||||
@ -224,7 +224,7 @@ fn test_bus_elision_output_equivalence() {
|
||||
|
||||
#[test]
|
||||
fn test_pure_function_optimization_equivalence() {
|
||||
let program = "pure_function_optimization.nyash";
|
||||
let program = "pure_function_optimization.hako";
|
||||
|
||||
let optimized = run_with_flag(program, "--optimize");
|
||||
let reference = run_with_flag(program, "--no-optimize");
|
||||
@ -238,7 +238,7 @@ fn test_pure_function_optimization_equivalence() {
|
||||
|
||||
#[test]
|
||||
fn test_memory_layout_compatibility() {
|
||||
let program = "memory_intensive_test.nyash";
|
||||
let program = "memory_intensive_test.hako";
|
||||
|
||||
let results = run_all_backends(program);
|
||||
|
||||
@ -256,9 +256,9 @@ fn test_memory_layout_compatibility() {
|
||||
#[test]
|
||||
fn test_performance_regression() {
|
||||
let benchmarks = [
|
||||
"arithmetic_heavy.nyash",
|
||||
"object_creation_heavy.nyash",
|
||||
"weak_reference_heavy.nyash"
|
||||
"arithmetic_heavy.hako",
|
||||
"object_creation_heavy.hako",
|
||||
"weak_reference_heavy.hako"
|
||||
];
|
||||
|
||||
for benchmark in &benchmarks {
|
||||
@ -333,8 +333,8 @@ jobs:
|
||||
echo "🏆 Golden Dump更新中..."
|
||||
|
||||
# 1. 現在のMIRを新しい黄金標準として設定
|
||||
for test_file in tests/golden_dump/programs/*.nyash; do
|
||||
program_name=$(basename "$test_file" .nyash)
|
||||
for test_file in tests/golden_dump/programs/*.hako; do
|
||||
program_name=$(basename "$test_file" .hako)
|
||||
echo "更新中: $program_name"
|
||||
|
||||
# MIR golden dump更新
|
||||
|
||||
Reference in New Issue
Block a user