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:
nyash-codex
2025-11-06 15:41:52 +09:00
parent 2dc370223d
commit 77d4fd72b3
1658 changed files with 6288 additions and 2612 deletions

View File

@ -19,7 +19,7 @@ Everything you need to know about building Nyash for different platforms and con
cargo build --release -j32
# Run
./target/release/nyash program.nyash
./target/release/nyash program.hako
```
### Windows Cross-Compile from WSL
@ -38,7 +38,7 @@ cargo xwin build --target x86_64-pc-windows-msvc --release
| **Standard** | `cargo build --release` | Linux/macOS binary | Local development |
| **Windows Cross** | `cargo xwin build --target x86_64-pc-windows-msvc` | Windows .exe | Windows distribution |
| **WebAssembly** | `wasm-pack build --target web` | .wasm + JS | Browser deployment |
| **AOT Native** | `./tools/build_aot.sh program.nyash` | Standalone executable | High-performance deployment |
| **AOT Native** | `./tools/build_aot.sh program.hako` | Standalone executable | High-performance deployment |
| **Plugins** | `cargo build --release` (in plugin dir) | .so/.dll/.dylib | Extending Nyash |
## 🖥️ Platform-Specific Builds
@ -94,7 +94,7 @@ cargo build --release
```powershell
# Requires Cranelift + (clang または MSYS2/WSL の bash+cc)
cargo build --release --features cranelift-jit
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input examples\aot_min_string_len.nyash -Out app.exe
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input examples\aot_min_string_len.hako -Out app.exe
./app.exe
```
@ -120,8 +120,8 @@ wasm-pack build --target web
#### 2. Compile Nyash Code to WASM
```bash
# Compile .nyash to .wat (WebAssembly Text)
./target/release/nyash --compile-wasm program.nyash -o output.wat
# Compile .hako to .wat (WebAssembly Text)
./target/release/nyash --compile-wasm program.hako -o output.wat
# Convert to binary WASM (requires wabt)
wat2wasm output.wat -o output.wasm
@ -137,7 +137,7 @@ Compile Nyash programs to standalone native executables:
cargo build --release --features cranelift-jit
# Compile to native
./tools/build_aot.sh program.nyash -o app
./tools/build_aot.sh program.hako -o app
./app # Standalone executable!
```
@ -145,7 +145,7 @@ cargo build --release --features cranelift-jit
```powershell
# From PowerShell
cargo build --release --features cranelift-jit
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input program.nyash -Out app.exe
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input program.hako -Out app.exe
.\app.exe
```
@ -209,8 +209,8 @@ cp nyash.toml dist/
# 4. Copy plugin DLLs
cp plugins/*/target/x86_64-pc-windows-msvc/release/*.dll dist/plugins/
# 5. Add your .nyash files
cp your_app.nyash dist/
# 5. Add your .hako files
cp your_app.hako dist/
```
**Distribution structure:**
@ -218,7 +218,7 @@ cp your_app.nyash dist/
dist/
├── nyash.exe
├── nyash.toml
├── your_app.nyash
├── your_app.hako
└── plugins/
├── nyash_filebox_plugin.dll
├── nyash_array_plugin.dll

View File

@ -35,7 +35,7 @@ Use the provided build script:
```bash
# Basic usage
./tools/build_aot.sh program.nyash -o myapp
./tools/build_aot.sh program.hako -o myapp
# Run the native executable
./myapp
@ -52,7 +52,7 @@ From PowerShell:
```powershell
# Build native executable
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input program.nyash -Out myapp.exe
powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input program.hako -Out myapp.exe
# Run it
.\myapp.exe
@ -62,13 +62,13 @@ From WSL (cross-compile):
```bash
# Use the bash script even for Windows targets
NYASH_TARGET=windows ./tools/build_aot.sh program.nyash -o myapp.exe
NYASH_TARGET=windows ./tools/build_aot.sh program.hako -o myapp.exe
```
## 🎯 AOT Compilation Pipeline
```
program.nyash
program.hako
[Nyash Parser]
@ -108,7 +108,7 @@ Native Executable
### Example: Simple Calculation
```nyash
// aot_example.nyash
// aot_example.hako
static box Main {
main() {
local x = 10
@ -137,14 +137,14 @@ static box Main {
```bash
# See what's happening
NYASH_CLI_VERBOSE=1 ./tools/build_aot.sh program.nyash
NYASH_CLI_VERBOSE=1 ./tools/build_aot.sh program.hako
```
### Check JIT Coverage
```bash
# See which operations are supported
NYASH_JIT_DUMP=1 ./target/release/nyash --backend vm program.nyash
NYASH_JIT_DUMP=1 ./target/release/nyash --backend vm program.hako
```
### Common Issues
@ -171,7 +171,7 @@ hint: Strict mode forbids fallback. Ensure main() is lowerable under current JIT
### Benchmark Results
| Execution Mode | Time (ny_bench.nyash) | Relative |
| Execution Mode | Time (ny_bench.hako) | Relative |
|----------------|----------------------|----------|
| Interpreter | 110.10ms | 1.0x |
| VM | 8.14ms | 13.5x |
@ -185,7 +185,7 @@ hint: Strict mode forbids fallback. Ensure main() is lowerable under current JIT
RUSTFLAGS="-C target-cpu=native" cargo build --release --features cranelift-jit
# Then compile your program
./tools/build_aot.sh program.nyash -o optimized_app
./tools/build_aot.sh program.hako -o optimized_app
```
## 🔌 Plugin Support in AOT
@ -196,7 +196,7 @@ The goal is to statically link plugins:
```bash
# Future syntax (not yet implemented)
./tools/build_aot.sh program.nyash \
./tools/build_aot.sh program.hako \
--static-plugins filebox,stringbox \
-o standalone_app
```

View File

@ -173,19 +173,19 @@ extern "C" {
# test_all_platforms.sh
echo "=== Testing Linux Build ==="
./target/release/nyash test/cross_platform.nyash
./target/release/nyash test/cross_platform.hako
echo "=== Testing Windows Build (Wine) ==="
wine ./target/x86_64-pc-windows-msvc/release/nyash.exe test/cross_platform.nyash
wine ./target/x86_64-pc-windows-msvc/release/nyash.exe test/cross_platform.hako
echo "=== Testing WASM Build ==="
wasmtime ./target/wasm32-wasi/release/nyash.wasm test/cross_platform.nyash
wasmtime ./target/wasm32-wasi/release/nyash.wasm test/cross_platform.hako
```
### Cross-Platform Test Program
```nyash
// test/cross_platform.nyash
// test/cross_platform.hako
print("Platform Test Starting...")
// Test basic plugins

View File

@ -48,7 +48,7 @@ cargo build --release
my-nyash-app/
├── nyash.exe # Main executable (4.1MB)
├── nyash.toml # Configuration
├── app.nyash # Your application
├── app.hako # Your application
├── README.txt # User instructions
└── plugins/ # Plugin DLLs
├── nyash_array_plugin.dll
@ -107,7 +107,7 @@ cp plugins/nyash-array-plugin/target/x86_64-pc-windows-msvc/release/nyash_array_
#### 5. Add Your Application
```bash
cp your_app.nyash dist/my-nyash-app/app.nyash
cp your_app.hako dist/my-nyash-app/app.hako
```
#### 6. Create Run Script (Optional)
@ -115,7 +115,7 @@ cp your_app.nyash dist/my-nyash-app/app.nyash
Create `run.bat`:
```batch
@echo off
nyash.exe app.nyash %*
nyash.exe app.hako %*
```
## 🚀 Real-World Example
@ -144,14 +144,14 @@ for plugin in filebox array map string integer; do
done
# 5. Test on Windows
cmd.exe /c "cd C:\tmp\nyash-windows-dist && nyash.exe test.nyash"
cmd.exe /c "cd C:\tmp\nyash-windows-dist && nyash.exe test.hako"
```
## 🎯 Testing Your Distribution
### Basic Test Program
Create `test.nyash`:
Create `test.hako`:
```nyash
print("=== Testing Nyash Distribution ===")
@ -174,14 +174,14 @@ print("Map test: " + map.get("status"))
```batch
:: Basic run
nyash.exe test.nyash
nyash.exe test.hako
:: With verbose output
nyash.exe --verbose test.nyash
nyash.exe --verbose test.hako
:: Check plugin loading
set NYASH_CLI_VERBOSE=1
nyash.exe test.nyash
nyash.exe test.hako
```
## 📝 Important Notes
@ -237,11 +237,11 @@ DefaultGroupName=My Nyash App
[Files]
Source: "nyash.exe"; DestDir: "{app}"
Source: "nyash.toml"; DestDir: "{app}"
Source: "app.nyash"; DestDir: "{app}"
Source: "app.hako"; DestDir: "{app}"
Source: "plugins\*.dll"; DestDir: "{app}\plugins"
[Icons]
Name: "{group}\My Nyash App"; Filename: "{app}\nyash.exe"; Parameters: "app.nyash"
Name: "{group}\My Nyash App"; Filename: "{app}\nyash.exe"; Parameters: "app.hako"
```
### Using zip for Simple Distribution

View File

@ -20,8 +20,8 @@
使用例(式 If
```
local JB = include "apps/lib/json_builder.nyash"
local CF = include "apps/lib/cf_builder.nyash" // 実装後に利用
local JB = include "apps/lib/json_builder.hako"
local CF = include "apps/lib/cf_builder.hako" // 実装後に利用
local cond = JB.binary("<", JB.variable("a"), JB.variable("b"))
local then_e = JB.literal_int(10)
@ -32,9 +32,9 @@ local stmts = CF.if_expr(cond, then_e, else_e, "__res0")
使用例(式 Match
```
local JB = include "apps/lib/json_builder.nyash"
local CF = include "apps/lib/cf_builder.nyash"
local PT = include "apps/lib/pattern_builder.nyash"
local JB = include "apps/lib/json_builder.hako"
local CF = include "apps/lib/cf_builder.hako"
local PT = include "apps/lib/pattern_builder.hako"
local scrut = JB.variable("x")
local c_small = PT.or_([ PT.eq(JB.literal_int(0)), PT.eq(JB.literal_int(1)) ])

View File

@ -22,10 +22,10 @@
- `cargo build --release --features cranelift-jit`
3) AOT EXE を生成(ワンショット推奨)
- Windows ワンショット: `pwsh -File tools/windows/build_egui_aot.ps1 -Input apps/egui-hello-plugin/main.nyash -Out app_egui`
- Windows ワンショット: `pwsh -File tools/windows/build_egui_aot.ps1 -Input apps/egui-hello-plugin/main.hako -Out app_egui`
- このスクリプトは他スクリプトをネスト呼び出しせず、引数を確実に伝播します(従来の「スクリプト→スクリプト」連鎖で引数が落ちる問題を解消)。
- 共通版PowerShell: `powershell -ExecutionPolicy Bypass -File tools/build_aot.ps1 -Input apps/egui-hello-plugin/main.nyash -Out app_egui`
- 代替Bash 版): `bash tools/build_aot.sh apps/egui-hello-plugin/main.nyash -o app_egui`
- 共通版PowerShell: `powershell -ExecutionPolicy Bypass -File tools/build_aot.ps1 -Input apps/egui-hello-plugin/main.hako -Out app_egui`
- 代替Bash 版): `bash tools/build_aot.sh apps/egui-hello-plugin/main.hako -o app_egui`
4) 実行(画面が表示されれば成功)
@ -55,6 +55,6 @@ WSL で表示されない場合Wayland→X11 切り替え)
- `NYASH_CLI_VERBOSE=1` で補助的な実行ログを有効化
補足
- 旧ビルトイン Eguiapps/egui-hello/main.nyash)は `gui-builtin-legacy` 機能に隔離されました。
AOT での GUI はプラグイン版apps/egui-hello-plugin/main.nyash)を使用してください。
- 旧ビルトイン Eguiapps/egui-hello/main.hako)は `gui-builtin-legacy` 機能に隔離されました。
AOT での GUI はプラグイン版apps/egui-hello-plugin/main.hako)を使用してください。
- JIT ランタイムCranelift JIT 直実行)は封印中です。必要時のみ `--features "cranelift-jit,jit-runtime"` で有効化してください。

View File

@ -18,8 +18,8 @@ Rules
Enablement
- Use the provided pre-expander script for dev: `tools/dev/at_local_preexpand.sh`.
- Example:
- `tools/dev/at_local_preexpand.sh apps/tests/dev_sugar/at_local_basic.nyash > /tmp/out.nyash`
- `NYASH_VM_USE_PY=1 ./target/release/nyash --backend vm /tmp/out.nyash`
- `tools/dev/at_local_preexpand.sh apps/tests/dev_sugar/at_local_basic.hako > /tmp/out.hako`
- `NYASH_VM_USE_PY=1 ./target/release/nyash --backend vm /tmp/out.hako`
Style
- Shared/committed code: prefer explicit `local` (nyfmt may normalize @ to `local`).

View File

@ -8,7 +8,7 @@ Overview
Current
- Use `--dev` to enable development defaults:
- `nyash --dev script.nyash`
- `nyash --dev script.hako`
- Enables AST using + Operator Boxes (observe) by default. Output remains stable.
- Dev shortcuts remain available:
- `./tools/opbox-json.sh` JSON Roundtrip/Nested with Operator Boxes
@ -49,6 +49,6 @@ Priority
- CLI `--profile` > explicit env > nyash.toml defaults > builtin defaults.
Acceptance
- `nyash script.nyash` runs with stable defaults.
- `nyash --dev script.nyash` enables AST using + Operator Boxes (observe) and passes JSON Roundtrip/Nested.
- `nyash script.hako` runs with stable defaults.
- `nyash --dev script.hako` enables AST using + Operator Boxes (observe) and passes JSON Roundtrip/Nested.
- Smokes use `--dev` path when appropriate; profiles remain as a convenience.

View File

@ -1,6 +1,6 @@
# Examples: Plugin BoxRef Return (v2.2)
- File: `plugin_boxref_return.nyash`
- File: `plugin_boxref_return.hako`
- Purpose: Demonstrates a plugin method returning a Box (BoxRef/Handle), and passing Box as an argument.
How to run (after full build):
@ -8,7 +8,7 @@ How to run (after full build):
- `copyFrom = { method_id = 7, args = [ { kind = "box", category = "plugin" } ] }`
- `cloneSelf = { method_id = 8 }`
- Build the plugin: `cd plugins/nyash-filebox-plugin && cargo build --release`
- Run the example: `./target/release/nyash docs/guides/examples/plugin_boxref_return.nyash`
- Run the example: `./target/release/nyash docs/guides/examples/plugin_boxref_return.hako`
Expected behavior:
- Creates two FileBox instances (`f`, `g`), writes to `f`, copies content to `g` via `copyFrom`, then closes both.

View File

@ -4,10 +4,10 @@
## 実行方法(代表)
```bash
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_err.nyash vm_stats_err.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_err.hako vm_stats_err.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
```
## 戻り値モデル

View File

@ -84,5 +84,5 @@ connect(url)
// Stage3 parser gate quick smoke (direct acceptance)
// NYASH_PARSER_STAGE3=1 ./target/release/nyash --backend vm \
// apps/tests/macro/exception/expr_postfix_direct.nyash
// apps/tests/macro/exception/expr_postfix_direct.hako
```

View File

@ -36,7 +36,7 @@ MIR Builder (optional, EXE)
- Run: `./app_out` (exit `7` expected for `return 1+2*3`).
Runner with EXEFirst Parser
- `NYASH_USE_NY_COMPILER=1 NYASH_USE_NY_COMPILER_EXE=1 ./target/release/nyash --backend vm tmp/sample.nyash`
- `NYASH_USE_NY_COMPILER=1 NYASH_USE_NY_COMPILER_EXE=1 ./target/release/nyash --backend vm tmp/sample.hako`
- Smoke: `./tools/exe_first_runner_smoke.sh`
Troubleshooting

View File

@ -19,11 +19,11 @@ cd nyash/nyash-rust
cargo build
# 実行
./target/debug/nyash your_program.nyash
./target/debug/nyash your_program.hako
```
### **2. はじめてのNyashプログラム**
`hello.nyash`を作成:
`hello.hako`を作成:
```nyash
print("Hello, Nyash World!")
print("Everything is Box! 🎉")
@ -31,7 +31,7 @@ print("Everything is Box! 🎉")
実行:
```bash
./target/debug/nyash hello.nyash
./target/debug/nyash hello.hako
```
出力:
@ -244,10 +244,10 @@ VMバックエンドの命令統計を有効化すると、性能分析に役立
```bash
# 人間向け表示
nyash --backend vm --vm-stats hello.nyash
nyash --backend vm --vm-stats hello.hako
# JSON出力ツール連携向け
nyash --backend vm --vm-stats --vm-stats-json hello.nyash
nyash --backend vm --vm-stats --vm-stats-json hello.hako
```
環境変数での制御も可能です(`NYASH_VM_STATS`, `NYASH_VM_STATS_JSON`)。
@ -422,24 +422,24 @@ debuggingDemo()
### **プロジェクト構造**
```
my_nyash_project/
├── main.nyash # メインプログラム
├── main.hako # メインプログラム
├── utils/
│ ├── math.nyash # 数学ユーティリティ
│ ├── string.nyash # 文字列ユーティリティ
│ └── debug.nyash # デバッグ関数
│ ├── math.hako # 数学ユーティリティ
│ ├── string.hako # 文字列ユーティリティ
│ └── debug.hako # デバッグ関数
└── models/
├── person.nyash # Personクラス
└── calculator.nyash # Calculatorクラス
├── person.hako # Personクラス
└── calculator.hako # Calculatorクラス
```
### **main.nyash**
### **main.hako**
```nyash
# 📦 Module System Example
include "utils/math.nyash"
include "utils/string.nyash"
include "models/person.nyash"
include "models/calculator.nyash"
include "utils/math.hako"
include "utils/string.hako"
include "models/person.hako"
include "models/calculator.hako"
function main() {
print("🚀 Multi-module Nyash Application")
@ -523,7 +523,7 @@ loop(i < 1000) {
### **学習順序**
1.**基本構文** - このガイドで完了
2. **並行処理** - `test_async_*.nyash`を参考に
2. **並行処理** - `test_async_*.hako`を参考に
3. **Static Box応用** - ユーティリティクラス作成
4. **デバッグ技法** - DebugBox完全活用
5. **アプリケーション開発** - 実践的なプロジェクト
@ -531,10 +531,10 @@ loop(i < 1000) {
### **サンプルプログラム**
```bash
# 実装済みサンプル
./target/debug/nyash test_local_init.nyash # 初期化付き変数
./target/debug/nyash app_dice_rpg.nyash # RPGバトルゲーム
./target/debug/nyash app_statistics.nyash # 統計計算
./target/debug/nyash test_async_parallel.nyash # 並行処理
./target/debug/nyash test_local_init.hako # 初期化付き変数
./target/debug/nyash app_dice_rpg.hako # RPGバトルゲーム
./target/debug/nyash app_statistics.hako # 統計計算
./target/debug/nyash test_async_parallel.hako # 並行処理
```
### **リファレンス**

View File

@ -7,16 +7,16 @@
- マクロ登録(例):
```
export NYASH_MACRO_ENABLE=1
export NYASH_MACRO_PATHS=apps/macros/examples/loop_normalize_macro.nyash
export NYASH_MACRO_PATHS=apps/macros/examples/loop_normalize_macro.hako
```
- 自己ホスト前展開autoを利用して、parse直後にLoopForm展開を有効化PyVM環境
JSON生成ユーティリティJsonBuilder
- ループ正規化では AST JSON v0 の断片を安全に構成する必要があります。
- 最小ユーティリティとして `apps/lib/json_builder.nyash` を提供していますincludeで読み込み、文字列でJSON断片を生成
- 最小ユーティリティとして `apps/lib/json_builder.hako` を提供していますincludeで読み込み、文字列でJSON断片を生成
- 例:
```
local JB = include "apps/lib/json_builder.nyash"
local JB = include "apps/lib/json_builder.hako"
local v_i = JB.variable("i")
local v_sum = JB.variable("sum")
local lit_0 = JB.literal_int(0)
@ -48,7 +48,7 @@ while (i < n) {
AST JSON v0 のスケッチJsonBuilder を用いた生成例)
```
local JB = include "apps/lib/json_builder.nyash"
local JB = include "apps/lib/json_builder.hako"
local v_i = JB.variable("i")
local v_s = JB.variable("sum")
local v_n = JB.variable("n")
@ -126,10 +126,10 @@ for / foreach の糖衣と正規化(概要)
- 出力一致スモークVM, v2
- `tools/smokes/v2/run.sh --profile quick --filter "loop_two_vars|macro"`
- 自己ホスト前展開PyVM 経由)
- `NYASH_VM_USE_PY=1 NYASH_USE_NY_COMPILER=1 NYASH_MACRO_ENABLE=1 NYASH_MACRO_PATHS=apps/macros/examples/loop_normalize_macro.nyash ./target/release/nyash --macro-preexpand --backend vm apps/tests/macro/loopform/simple.nyash`
- `NYASH_VM_USE_PY=1 NYASH_USE_NY_COMPILER=1 NYASH_MACRO_ENABLE=1 NYASH_MACRO_PATHS=apps/macros/examples/loop_normalize_macro.hako ./target/release/nyash --macro-preexpand --backend vm apps/tests/macro/loopform/simple.hako`
Selfhost compiler prepass恒等→最小正規化
- Runner が `NYASH_LOOPFORM_NORMALIZE=1``--loopform` にマップして子に渡し、`apps/lib/loopform_normalize.nyash` の前処理を適用(現状は恒等)。
- Runner が `NYASH_LOOPFORM_NORMALIZE=1``--loopform` にマップして子に渡し、`apps/lib/loopform_normalize.hako` の前処理を適用(現状は恒等)。
- 既定OFF。将来、キー順正規化→簡易キャリア整列を段階的に追加する。
実装メモ(内蔵変換ルート / Rust

View File

@ -23,8 +23,8 @@ Registration
```
[macros]
paths = [
"apps/macros/my_macro.nyash",
"apps/macros/json_lints.nyash"
"apps/macros/my_macro.hako",
"apps/macros/json_lints.hako"
]
```
- Loading policy: register via `NYASH_MACRO_PATHS=path1,path2`(推奨)。

View File

@ -17,9 +17,9 @@ Profiles
- trace: OFF
CLI
- `nyash --profile lite file.nyash`
- `nyash --profile dev file.nyash`
- `nyash --profile ci file.nyash`
- `nyash --profile lite file.hako`
- `nyash --profile dev file.hako`
- `nyash --profile ci file.hako`
ENV mapping (non-breaking; can be overridden)
- lite → `NYASH_MACRO_ENABLE=0`, `NYASH_MACRO_STRICT=0`, `NYASH_MACRO_TRACE=0`

View File

@ -22,7 +22,7 @@ Status: MVP available behind environment gates (default OFF). This page describe
Example
```
NYASH_MACRO_ENABLE=1 ./target/release/nyash --backend vm apps/APP/main.nyash
NYASH_MACRO_ENABLE=1 ./target/release/nyash --backend vm apps/APP/main.hako
```
## Test runner (MVP)
@ -46,17 +46,17 @@ NYASH_MACRO_ENABLE=1 ./target/release/nyash --backend vm apps/APP/main.nyash
Examples
```
# run all tests in a file
./target/release/nyash --run-tests apps/tests/my_tests.nyash
./target/release/nyash --run-tests apps/tests/my_tests.hako
# filter + wrap entry + default arg injection
NYASH_MACRO_ENABLE=1 NYASH_TEST_ARGS_DEFAULTS=1 \
./target/release/nyash --run-tests --test-filter http --test-entry wrap apps/tests/my_tests.nyash
./target/release/nyash --run-tests --test-filter http --test-entry wrap apps/tests/my_tests.hako
```
## Expansion dump
```
./target/release/nyash --expand --dump-ast apps/tests/ternary_basic.nyash
./target/release/nyash --expand --dump-ast apps/tests/ternary_basic.hako
```
Shows pre/post expansion AST (debug only).

View File

@ -27,17 +27,17 @@ Behavior
- The operators live under `apps/lib/std/operators/` and are autoinjected into the AST prelude (dev only) so functions are materialized without changing user sources.
Operator definitions (MVP)
- Stringify — `apps/lib/std/operators/stringify.nyash`
- Stringify — `apps/lib/std/operators/stringify.hako`
- If `value` has `stringify()`, call it; else return `"" + value`.
- Compare — `apps/lib/std/operators/compare.nyash`
- Compare — `apps/lib/std/operators/compare.hako`
- `apply(op, a, b)`; observeronly for now, returns `true` and the VM performs the real compare.
- Add — `apps/lib/std/operators/add.nyash`
- Add — `apps/lib/std/operators/add.hako`
- `apply(a, b)`; observeronly for now, VM performs the real addition.
- Sub/Mul/Div/Mod — `apps/lib/std/operators/{sub,mul,div,mod}.nyash`
- Sub/Mul/Div/Mod — `apps/lib/std/operators/{sub,mul,div,mod}.hako`
- `apply(a, b)`; direct evaluation.
- Bitwise/Shifts — `apps/lib/std/operators/{bitand,bitor,bitxor,shl,shr}.nyash`
- Bitwise/Shifts — `apps/lib/std/operators/{bitand,bitor,bitxor,shl,shr}.hako`
- `apply(a, b)`; direct evaluation on integers.
- Unary — `apps/lib/std/operators/{neg,not,bitnot}.nyash`
- Unary — `apps/lib/std/operators/{neg,not,bitnot}.hako`
- `apply(a)`; negate / logical-not / bitwise-not.
Design Notes

View File

@ -166,7 +166,7 @@ transport.on_receive コールバックで受信
### **基本動作確認テスト**
```nyash
// tests/phase2/p2p_basic_test.nyash
// tests/phase2/p2p_basic_test.hako
node_a = new P2PBox("alice", transport: "inprocess")
node_b = new P2PBox("bob", transport: "inprocess")

View File

@ -13,8 +13,8 @@
使用例
```
local JB = include "apps/lib/json_builder.nyash"
local PT = include "apps/lib/pattern_builder.nyash"
local JB = include "apps/lib/json_builder.hako"
local PT = include "apps/lib/pattern_builder.hako"
local scrut = JB.variable("x")
local p = PT.or_([ PT.eq(JB.literal_int(0)), PT.eq(JB.literal_int(1)) ])

View File

@ -23,5 +23,5 @@ Symptoms and Hints
Tools
- JSON trace: set `NYASH_LLVM_TRACE_PHI=1` and `NYASH_LLVM_TRACE_OUT=<path>`
- One-shot: `tools/phi_trace_run.sh <app.nyash> [--strict-zero]`
- One-shot: `tools/phi_trace_run.sh <app.hako> [--strict-zero]`
- Strict verifier (PHI-off): `NYASH_VERIFY_EDGE_COPY_STRICT=1 cargo test --lib`

View File

@ -35,6 +35,6 @@ Runtime Trace
- `[mir][hint] ScopeLeave(0)` at function exit
Example
- `apps/tests/macro/if/assign_both_branches.nyash` emits JoinResult(x):
- `apps/tests/macro/if/assign_both_branches.hako` emits JoinResult(x):
- `if (cond) { x = 10 } else { x = 20 }`
- Both branches assign `x`, builder hints the join.

View File

@ -6,7 +6,7 @@ Overview
How to enable
- Inject ScopeBox wrappers during core normalization by setting:
- `NYASH_SCOPEBOX_ENABLE=1`
- Selfhost compiler path: Runner maps `NYASH_SCOPEBOX_ENABLE=1` to child arg `--scopebox` and applies a JSON prepass via `apps/lib/scopebox_inject.nyash`(現状は恒等: 構文確認のみ)。
- Selfhost compiler path: Runner maps `NYASH_SCOPEBOX_ENABLE=1` to child arg `--scopebox` and applies a JSON prepass via `apps/lib/scopebox_inject.hako`(現状は恒等: 構文確認のみ)。
- Injection points:
- If.then / If.else bodies
- Loop.body

View File

@ -5,9 +5,9 @@ Overview
- Default remains envgated for safety; CI runs smokes to build confidence.
Recommended Flows
- Runner (pilot): `NYASH_USE_NY_COMPILER=1 ./target/release/nyash --backend vm apps/examples/string_p0.nyash`
- Runner (pilot): `NYASH_USE_NY_COMPILER=1 ./target/release/nyash --backend vm apps/examples/string_p0.hako`
- Emitonly: `NYASH_USE_NY_COMPILER=1 NYASH_NY_COMPILER_EMIT_ONLY=1 ...`
- EXEfirst (parser EXE): `tools/build_compiler_exe.sh && NYASH_USE_NY_COMPILER=1 NYASH_USE_NY_COMPILER_EXE=1 ./target/release/nyash --backend vm apps/examples/string_p0.nyash`
- EXEfirst (parser EXE): `tools/build_compiler_exe.sh && NYASH_USE_NY_COMPILER=1 NYASH_USE_NY_COMPILER_EXE=1 ./target/release/nyash --backend vm apps/examples/string_p0.hako`
- LLVM AOT: `NYASH_LLVM_USE_HARNESS=1 tools/build_llvm.sh apps/... -o app && ./app`
CI Workflows
@ -16,11 +16,11 @@ CI Workflows
- Selfhost EXEfirstoptional
- crate 直結ny-llvmcで JSON→EXE→実行までを最短経路で確認できるよ。
- 手順(ローカル):
1) MIR(JSON) を出力: `./target/release/nyash --emit-mir-json tmp/app.json --backend mir apps/tests/ternary_basic.nyash`
1) MIR(JSON) を出力: `./target/release/nyash --emit-mir-json tmp/app.json --backend mir apps/tests/ternary_basic.hako`
2) EXE 生成: `./target/release/ny-llvmc --in tmp/app.json --emit exe --nyrt target/release --out tmp/app`
3) 実行: `./tmp/app`(戻り値が exit code
- ワンコマンドスモーク: `bash tools/crate_exe_smoke.sh apps/tests/ternary_basic.nyash`
- CLI で直接 EXE 出力: `./target/release/nyash --emit-exe tmp/app --backend mir apps/tests/ternary_basic.nyash`
- ワンコマンドスモーク: `bash tools/crate_exe_smoke.sh apps/tests/ternary_basic.hako`
- CLI で直接 EXE 出力: `./target/release/nyash --emit-exe tmp/app --backend mir apps/tests/ternary_basic.hako`
- Installs LLVM 18 + llvmlite, then runs `tools/exe_first_smoke.sh`.
Useful Env Flags

View File

@ -1,36 +1,61 @@
Source Extensions Policy — .nyash vs .hako (Interim)
Source Extensions Policy — .hako と .nyash の等価性Phase 20.47
Intent
- Keep development stable while Hakorune VM (v1 Dispatcher/IR/φ) is brought up.
- Avoid crosscontamination between frontends; converge at MIR.
- 拡張子が異なるだけで、言語は 1 つ(.hako / .nyash は等価)。
- using は言語中立な“テキスト・プレリュード統合”に一本化してからパーサへ渡す。
Execution Mapping (current)
- .nyash → Nyash VM (Rust): NyashParser → MIR → VM. Full runtime/plugins path.
- .hako → Hakorune VM (v1): JSON v1 Dispatcher/IR/φbringup coverage; guarded extern.
- verify (MIR v1) → Hakorune primary, Core fallback for diagnosis.
Execution Mapping (unified)
- .hako / .nyash → using のテキスト統合merge_prelude_text Nyash Parser → MIR → VM 実行。
- verify (MIR v1) → hv1 早期経路NYASH_VERIFY_JSON + HAKO_VERIFY_V1_FORCE_HAKOVM=1
Resolver/Include/Normalize
- Using: unify to textmerge (merge_prelude_text). AST prelude merge is retired.
- Include: languagelevel unsupported; quick profile treats include as ERROR. Preinclude is testharness onlyverify の include fallback は撤去済み)。
- Normalize (inline/dev): CRLF→LF, redundant `; }` trimmed, tolerant `local` at line head in Hakorune inline drivers.
- Using: 常にテキスト統合。AST プレリュード統合は任意(プロファイルによる)。
- 拡張子の扱い: .hako を優先、.nyash を次点(両方探索)。
- using.paths 既定: apps, lib, ., lang/srcnyash.toml/hakorune.toml
- Include: 言語としては非推奨quick は ERROR。必要時のみ preinclude スクリプトを使用。
- Normalizeinline/dev: CRLF→LF、冗長 `; }` の最小削除、先頭 `local` の互換補助 等。
FailFast Guards
- Hako in Nyash VM: rejected by default (FailFast). Toggle: `HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=0` for dev only.
- Extern (Hako provider): `HAKO_V1_EXTERN_PROVIDER=1`; optional CABI tag/bridge with `HAKO_V1_EXTERN_PROVIDER_C_ABI=1` (default OFF).
FailFast Guards / Profiles
- FailFast: 既定OFF。`HAKO_FAIL_FAST_ON_HAKO_IN_NYASH_VM=1` のときのみ Hako 風ソースを Nyash VM 経路で拒否(診断用)。
- Profiles:
- dev/ci: using 有効。AST マージ 既定ON。相対パス using は許容。
- prod: using は名前解決のみalias/modules。相対パス using は ERROR。`NYASH_USING_PROFILE=prod`
- ExternHako provider: `HAKO_V1_EXTERN_PROVIDER=1`(開発時ガード)、`HAKO_V1_EXTERN_PROVIDER_C_ABI=1`(任意タグ)。
Why two extensions now?
- Same language intent, but different stability constraints at the frontend boundary:
- .hako through NyashParser caused parse/timeout/alias issues historically.
- We intentionally stopped that path and direct .hako to Hakorune VM while it matures.
Why two extensions?
- 言語は 1 つ。拡張子が異なるだけ(歴史的理由)。解決は等価で、.hako を優先・.nyash を次点で探索する。
Migration Plan (phased)
1) P2: IR iteration complete; φ table robust; dispatcher loop scanfree; extern canaries PASS without harness shim.
2) P3: verify default → Hakorune (Core fallback); document toggles and remove adhoc heuristics.
3) Prep: introduce stable Nyash→MIR v1 emit route to feed Hakorune VM when (and if) we want .nyash on hv1.
4) Deprecation: warn on `.nyash` (optin), then FailFast once hv1 parity is sufficient; remove legacy code in a later phase.
Migration Plan
- 本ドキュメントの時点で統一完了Phase 20.47)。以降は代表拡張/ハードニングを Phase 21.x で進める。
Best Practices (now)
- Prefer alias/modules over path using; avoid include in source.
- Keep quotes ASCII (`"`); avoid trailing semicolons before `}`.
- For verify, pass JSON via env (`NYASH_VERIFY_JSON`) and parse last numeric line as rc.
- Inline-cドライバは alias のみで構成include 不要)。
- パス using ではなく、nyash.toml/hakorune.toml の [modules]/[using.paths]/[aliases]/workspace を活用。
- ソース内 include は避ける(必要時は preinclude を使ってテキスト展開)。
- verify JSON env`NYASH_VERIFY_JSON`)経由で渡し、末尾数値を rc として評価。
Quick Example (alias using)
```
using selfhost.vm.entry as MiniVmEntryBox
static box Main { method main(args) {
// alias 解決の確認(静的メソッド呼び出し)
local _s = MiniVmEntryBox.int_to_str(0)
return 0
} }
```
実行quick プロファイル、dev 想定):
`bash tools/smokes/v2/run.sh --profile quick --filter 'phase2047/using_alias_selfhost_vm_entry_canary_vm.sh'`
Nested Prelude Example
```
using selfhost.vm.hakorune-vm.json_v1_reader as JsonV1ReaderBox
static box Main { method main(args) {
local seg = JsonV1ReaderBox.get_block0_instructions('{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[]}]}]}')
return seg == "" ? 0 : 1
} }
```
実行:
`bash tools/smokes/v2/run.sh --profile quick --filter 'phase2047/using_alias_nested_prelude_json_v1_reader_canary_vm.sh'`
Notes (this pass)
- StageB emit の安定化: inline コンパイラ無効化と失敗時 tail 出力で原因を可視化。
- hv1 inline の拡張: const/compare/branch/jump/phi/extern最小を実装。

View File

@ -78,7 +78,7 @@ box Bad {
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 {
escJson(s) { // lowerCamelCase for methods

View File

@ -17,7 +17,7 @@ Authoring
- During unquote: the `Program`s statements are spliced into the argument list.
Tooling
- `nyash --expand --dump-ast file.nyash` shows pre/post expansion.
- `nyash --expand --dump-ast file.hako` shows pre/post expansion.
- Macro gate: `NYASH_MACRO_ENABLE=1`.
Compatibility

View File

@ -5,12 +5,12 @@
⚠️ **ルートディレクトリの汚染防止ルール** ⚠️
```bash
# ❌ 絶対ダメ:ルートで実行
./target/release/nyash test.nyash # ログがルートに散乱!
./target/release/nyash test.hako # ログがルートに散乱!
cargo test > test_output.txt # 出力ファイルがルートに!
# ✅ 正しい方法:必ずディレクトリを使う
cd local_tests && ../target/release/nyash test.nyash
./target/release/nyash local_tests/test.nyash
cd local_tests && ../target/release/nyash test.hako
./target/release/nyash local_tests/test.hako
```
**必須ルール:**
@ -32,30 +32,30 @@ cargo test
# テストファイル作成・実行例
mkdir -p local_tests
echo 'print("Hello Nyash!")' > local_tests/test_hello.nyash
./target/debug/nyash local_tests/test_hello.nyash
echo 'print("Hello Nyash!")' > local_tests/test_hello.hako
./target/debug/nyash local_tests/test_hello.hako
# 演算子統合テストlocal_testsから実行
./target/debug/nyash local_tests/test_comprehensive_operators.nyash
./target/debug/nyash local_tests/test_comprehensive_operators.hako
# 実用アプリテスト
./target/debug/nyash app_dice_rpg.nyash
./target/debug/nyash app_dice_rpg.hako
# JIT 実行フラグCLI
./target/release/nyash --backend vm \
--jit-exec --jit-stats --jit-dump --jit-threshold 1 \
--jit-phi-min --jit-hostcall --jit-handle-debug \
examples/jit_branch_demo.nyash
examples/jit_branch_demo.hako
# 既存の環境変数でも可:
# NYASH_JIT_EXEC/NYASH_JIT_STATS(/_JSON)/NYASH_JIT_DUMP/NYASH_JIT_THRESHOLD
# NYASH_JIT_PHI_MIN/NYASH_JIT_HOSTCALL/NYASH_JIT_HANDLE_DEBUG
# HostCallハンドルPoCの例
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_array_param_call.nyash
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_map_param_call.nyash
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_map_int_keys_param_call.nyash
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_string_param_length.nyash
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_string_is_empty.nyash
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_array_param_call.hako
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_map_param_call.hako
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_map_int_keys_param_call.hako
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_string_param_length.hako
./target/release/nyash --backend vm --jit-exec --jit-hostcall examples/jit_string_is_empty.hako
```
## PHI ポリシーPhase15と検証トグル
@ -128,9 +128,9 @@ cargo build --release
### パーサー無限ループ対策2025-08-09実装
```bash
# 🔥 デバッグ燃料でパーサー制御
./target/release/nyash --debug-fuel 1000 program.nyash # 1000回制限
./target/release/nyash --debug-fuel unlimited program.nyash # 無制限
./target/release/nyash program.nyash # デフォルト10万回
./target/release/nyash --debug-fuel 1000 program.hako # 1000回制限
./target/release/nyash --debug-fuel unlimited program.hako # 無制限
./target/release/nyash program.hako # デフォルト10万回
# パーサー無限ループが検出されると自動停止+詳細情報表示
🚨 PARSER INFINITE LOOP DETECTED at method call argument parsing
@ -154,7 +154,7 @@ print(DEBUG.memoryReport())
Nyash provides a macro-powered lightweight test runner in Phase 16 (MVP).
- Enable and run tests in a script file:
- `nyash --run-tests apps/tests/my_tests.nyash`
- `nyash --run-tests apps/tests/my_tests.hako`
- Discovers top-level `test_*` functions and Box `test_*` methods (static/instance).
- Filtering: `--test-filter NAME` (substring match) or env `NYASH_TEST_FILTER`.
- Entry policy when a main exists:

View File

@ -19,11 +19,11 @@ cd nyash/nyash-rust
cargo build
# 実行
./target/debug/nyash your_program.nyash
./target/debug/nyash your_program.hako
```
### **2. はじめてのNyashプログラム**
`hello.nyash`を作成:
`hello.hako`を作成:
```nyash
print("Hello, Nyash World!")
print("Everything is Box! 🎉")
@ -31,7 +31,7 @@ print("Everything is Box! 🎉")
実行:
```bash
./target/debug/nyash hello.nyash
./target/debug/nyash hello.hako
```
出力:
@ -408,24 +408,24 @@ debuggingDemo()
### **プロジェクト構造**
```
my_nyash_project/
├── main.nyash # メインプログラム
├── main.hako # メインプログラム
├── utils/
│ ├── math.nyash # 数学ユーティリティ
│ ├── string.nyash # 文字列ユーティリティ
│ └── debug.nyash # デバッグ関数
│ ├── math.hako # 数学ユーティリティ
│ ├── string.hako # 文字列ユーティリティ
│ └── debug.hako # デバッグ関数
└── models/
├── person.nyash # Personクラス
└── calculator.nyash # Calculatorクラス
├── person.hako # Personクラス
└── calculator.hako # Calculatorクラス
```
### **main.nyash**
### **main.hako**
```nyash
# 📦 Module System Example
include "utils/math.nyash"
include "utils/string.nyash"
include "models/person.nyash"
include "models/calculator.nyash"
include "utils/math.hako"
include "utils/string.hako"
include "models/person.hako"
include "models/calculator.hako"
function main() {
print("🚀 Multi-module Nyash Application")
@ -509,7 +509,7 @@ loop(i < 1000) {
### **学習順序**
1.**基本構文** - このガイドで完了
2. **並行処理** - `test_async_*.nyash`を参考に
2. **並行処理** - `test_async_*.hako`を参考に
3. **Static Box応用** - ユーティリティクラス作成
4. **デバッグ技法** - DebugBox完全活用
5. **アプリケーション開発** - 実践的なプロジェクト
@ -517,10 +517,10 @@ loop(i < 1000) {
### **サンプルプログラム**
```bash
# 実装済みサンプル
./target/debug/nyash test_local_init.nyash # 初期化付き変数
./target/debug/nyash app_dice_rpg.nyash # RPGバトルゲーム
./target/debug/nyash app_statistics.nyash # 統計計算
./target/debug/nyash test_async_parallel.nyash # 並行処理
./target/debug/nyash test_local_init.hako # 初期化付き変数
./target/debug/nyash app_dice_rpg.hako # RPGバトルゲーム
./target/debug/nyash app_statistics.hako # 統計計算
./target/debug/nyash test_async_parallel.hako # 並行処理
```
### **リファレンス**

View File

@ -6,9 +6,9 @@ Status: PoC complete; PyVM sandbox route wired. This guide explains how to autho
- Register user macros (recommended minimal env):
- `NYASH_MACRO_ENABLE=1`
- `NYASH_MACRO_PATHS=apps/macros/examples/echo_macro.nyash`
- `NYASH_MACRO_PATHS=apps/macros/examples/echo_macro.hako`
- Run your program as usual (macro expansion happens once before MIR):
- `./target/release/nyash --backend vm apps/tests/ternary_basic.nyash`
- `./target/release/nyash --backend vm apps/tests/ternary_basic.hako`
Environment overview (recommended minimal set)
- `NYASH_MACRO_ENABLE=1`既定ON
@ -50,10 +50,10 @@ static box MacroBoxSpec {
}
```
Example (repo): `apps/macros/examples/echo_macro.nyash`.
Example (repo): `apps/macros/examples/echo_macro.hako`.
Editing template (string literal uppercasing)
- Example: `apps/macros/examples/upper_string_macro.nyash`
- Example: `apps/macros/examples/upper_string_macro.hako`
- Behavior: if a string literal value starts with `UPPER:`, the suffix is uppercased.
- Input: `print("UPPER:hello")` → Output: `print("HELLO")`
@ -63,10 +63,10 @@ Register and run via env (simple):
```bash
export NYASH_MACRO_ENABLE=1
export NYASH_MACRO_PATHS=apps/macros/examples/echo_macro.nyash
export NYASH_MACRO_PATHS=apps/macros/examples/echo_macro.hako
# Run your program (macro expansion happens before MIR)
./target/release/nyash --backend vm apps/tests/ternary_basic.nyash
./target/release/nyash --backend vm apps/tests/ternary_basic.hako
```
Selfhost pathNYASH_USE_NY_COMPILER=1での前展開開発用
@ -75,7 +75,7 @@ Selfhost pathNYASH_USE_NY_COMPILER=1での前展開開発用
NYASH_USE_NY_COMPILER=1 \
NYASH_MACRO_SELFHOST_PRE_EXPAND=1 \
NYASH_VM_USE_PY=1 \
./target/release/nyash --backend vm apps/tests/ternary_basic.nyash
./target/release/nyash --backend vm apps/tests/ternary_basic.hako
```
Notes: 現状は PyVM ルートのみ対応。`NYASH_VM_USE_PY=1` が必須。
@ -84,7 +84,7 @@ CLI プロファイル(推奨)
- `--profile dev`(既定相当: マクロON/厳格ON
- `--profile lite`マクロOFFの軽量モード
- `--profile ci|strict`マクロON/厳格ON
- 例: `./target/release/nyash --profile dev --backend vm apps/tests/ternary_basic.nyash`
- 例: `./target/release/nyash --profile dev --backend vm apps/tests/ternary_basic.hako`
Notes
- Built-in child route (stdin JSON -> stdout JSON) remains available when `NYASH_MACRO_BOX_CHILD_RUNNER=0`.
@ -103,17 +103,17 @@ Testing
- Negative (invalid JSON strict/nonstrict): covered by v2 smokeslegacy paths removed
Array/Map editing examples
- Array prepend zero: `apps/macros/examples/array_prepend_zero_macro.nyash`
- Array prepend zero: `apps/macros/examples/array_prepend_zero_macro.hako`
- Transforms every `{"kind":"Array","elements":[...]}` into one with a leading `0` literal element.
- Example input: `print([1, 2])` → Expanded: elements `[0, 1, 2]`.
- Map insert tag: `apps/macros/examples/map_insert_tag_macro.nyash`
- Map insert tag: `apps/macros/examples/map_insert_tag_macro.hako`
- Transforms every `{"kind":"Map","entries":[...]}` by inserting the first entry `{k:"__macro", v: "on"}`.
- Example input: `print({"a": 1})` → Expanded entries: `[{"__macro":"on"}, {"a":1}]`.
## Inspect Expanded AST
```bash
./target/release/nyash --dump-expanded-ast-json apps/tests/ternary_basic.nyash
./target/release/nyash --dump-expanded-ast-json apps/tests/ternary_basic.hako
```
Outputs AST JSON v0 after expansion; use this for golden comparison.

View File

@ -18,10 +18,10 @@ Nyash WebAssemblyWASM実行に関する包括的ガイド
### WASM コンパイル
```bash
# 基本コンパイル
./target/release/nyash --compile-wasm program.nyash
./target/release/nyash --compile-wasm program.hako
# AOT コンパイル(配布用)
./target/release/nyash --aot program.nyash
./target/release/nyash --aot program.hako
```
### ブラウザー実行
@ -41,10 +41,10 @@ Nyash WebAssemblyWASM実行に関する包括的ガイド
| 用途 | 方式 | コマンド |
|------|------|----------|
| **開発・テスト** | インタープリター | `nyash program.nyash` |
| **高速実行** | VM | `nyash --backend vm program.nyash` |
| **Web配布** | WASM | `nyash --compile-wasm program.nyash` |
| **ネイティブ配布** | AOT | `nyash --aot program.nyash` |
| **開発・テスト** | インタープリター | `nyash program.hako` |
| **高速実行** | VM | `nyash --backend vm program.hako` |
| **Web配布** | WASM | `nyash --compile-wasm program.hako` |
| **ネイティブ配布** | AOT | `nyash --aot program.hako` |
## 📊 性能比較

View File

@ -104,7 +104,7 @@ cargo update
cargo build --release
# WASM/AOT テスト
./target/release/nyash --aot test_simple.nyash
./target/release/nyash --aot test_simple.hako
wasmtime --allow-precompiled test_simple.cwasm
```
@ -170,7 +170,7 @@ config.cranelift_opt_level(OptLevel::Speed)?;
### 技術指標
```bash
# ✅ 成功条件
./target/release/nyash --aot test.nyash # コンパイル成功
./target/release/nyash --aot test.hako # コンパイル成功
wasmtime --allow-precompiled test.cwasm # 実行成功
echo $? # 0 (正常終了)
```

View File

@ -154,10 +154,10 @@ wasmtime 35.0.0 # 実行時
### 基本動作テスト
```bash
# BoxCall テスト
./target/release/nyash --compile-wasm test_boxcall.nyash
./target/release/nyash --compile-wasm test_boxcall.hako
# AOT テスト
./target/release/nyash --aot test_simple.nyash
./target/release/nyash --aot test_simple.hako
wasmtime --allow-precompiled test_simple.cwasm
```

View File

@ -179,7 +179,7 @@ impl RuntimeImports {
### Level 1: 基本BoxCall
```nyash
# test_basic_boxcall.nyash
# test_basic_boxcall.hako
local str = "Hello"
local len = str.length() # BoxCall実装必要
print("Length: " + len.toString()) # BoxCall + ExternCall
@ -187,7 +187,7 @@ print("Length: " + len.toString()) # BoxCall + ExternCall
### Level 2: Box操作
```nyash
# test_box_operations.nyash
# test_box_operations.hako
local arr = new ArrayBox()
arr.push("item1") # BoxCall実装必要
local item = arr.get(0) # BoxCall実装必要
@ -196,7 +196,7 @@ print(item.toString()) # BoxCall実装必要
### Level 3: 外部連携
```nyash
# test_extern_integration.nyash
# test_extern_integration.hako
local console = new ExternBox("console")
console.call("log", "Hello Browser!") # ExternCall実装必要
```
@ -208,9 +208,9 @@ console.call("log", "Hello Browser!") # ExternCall実装必要
### 基本機能復旧
```bash
# 以下が全て成功すること
./target/release/nyash --compile-wasm test_basic_boxcall.nyash
./target/release/nyash --compile-wasm test_box_operations.nyash
./target/release/nyash --compile-wasm test_extern_integration.nyash
./target/release/nyash --compile-wasm test_basic_boxcall.hako
./target/release/nyash --compile-wasm test_box_operations.hako
./target/release/nyash --compile-wasm test_extern_integration.hako
# WASM実行成功
wasmtime test_basic_boxcall.wasm