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:
@ -123,7 +123,7 @@ cargo build --release
|
||||
|
||||
### 実行検証
|
||||
```bash
|
||||
./target/release/hakorune /tmp/cleanup_test.nyash
|
||||
./target/release/hakorune /tmp/cleanup_test.hako
|
||||
```
|
||||
- **テストコード**: `print("Cleanup test OK!")`
|
||||
- **結果**: ✅ 成功
|
||||
|
||||
@ -87,7 +87,7 @@ cargo build --release
|
||||
|
||||
### 実行検証
|
||||
```bash
|
||||
./target/release/hakorune /tmp/phase2_test.nyash
|
||||
./target/release/hakorune /tmp/phase2_test.hako
|
||||
```
|
||||
- **テストコード**: `print("Phase 2 OK!")`
|
||||
- **結果**: ✅ 成功
|
||||
|
||||
@ -22,12 +22,12 @@
|
||||
|
||||
### 4. 新しい例の追加
|
||||
|
||||
#### `examples/jit_stats_bool_ret.nyash`
|
||||
#### `examples/jit_stats_bool_ret.hako`
|
||||
- 統計JSONをプリントする最小デモ
|
||||
- 最後にブールを返す
|
||||
- JIT統計の動作確認用
|
||||
|
||||
#### `examples/jit_mixed_f64_compare.nyash`
|
||||
#### `examples/jit_mixed_f64_compare.hako`
|
||||
- f64比較のデモ
|
||||
- **注意**: VMのf64演算/比較未対応のため、Cranelift有効環境向けサンプル
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
### 統計+JSON出力
|
||||
```bash
|
||||
NYASH_JIT_STATS=1 NYASH_JIT_STATS_JSON=1 NYASH_JIT_THRESHOLD=1 \
|
||||
./target/release/nyash --backend vm examples/jit_stats_bool_ret.nyash
|
||||
./target/release/nyash --backend vm examples/jit_stats_bool_ret.hako
|
||||
```
|
||||
|
||||
JSONに以下が出力される:
|
||||
@ -47,14 +47,14 @@ JSONに以下が出力される:
|
||||
|
||||
### CFG/PHIダンプ
|
||||
```bash
|
||||
NYASH_JIT_DUMP=1 ./target/release/nyash --backend vm examples/phi_bool_merge.nyash
|
||||
NYASH_JIT_DUMP=1 ./target/release/nyash --backend vm examples/phi_bool_merge.hako
|
||||
```
|
||||
- b1 PHIには `(b1)` タグが付与される
|
||||
|
||||
## 注意事項
|
||||
|
||||
- VMのf64演算/比較は未対応
|
||||
- `jit_mixed_f64_compare.nyash` はCranelift有効環境(JIT実行)での確認用
|
||||
- `jit_mixed_f64_compare.hako` はCranelift有効環境(JIT実行)での確認用
|
||||
- VMでの実行はエラーになる
|
||||
|
||||
## 実装の意義
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
## 🔴 重要:ループビルダーのバグ発見(詳細調査完了)
|
||||
|
||||
### 問題詳細
|
||||
- **症状**: dep_tree_min_string.nyashがVM実行でエラー `Invalid value: Value %57 not set`
|
||||
- **症状**: dep_tree_min_string.hakoがVM実行でエラー `Invalid value: Value %57 not set`
|
||||
- **発生箇所**: `loop(i + m <= n) { if ... { return 1 } i = i + 1 }`のような構造
|
||||
|
||||
### 根本原因(深掘り調査結果)
|
||||
@ -51,12 +51,12 @@ Nyashの開発哲学「Everything is Box」に従い、スコープも箱化す
|
||||
- 各ブロックの変数状態を自動的に箱として保存
|
||||
- 実装工数: 中程度(既存構造を活用)
|
||||
- 代替案A: ループビルダーの根本的な再設計(工数大)
|
||||
- 代替案B: 一時的なワークアラウンド(dep_tree_min_string.nyashの書き換え)
|
||||
- 代替案B: 一時的なワークアラウンド(dep_tree_min_string.hakoの書き換え)
|
||||
2. dep-tree 深さ1(直下 include)を children に反映(行ベースの素朴抽出、`//`/`#` 行コメントスキップ)。
|
||||
3. `make dep-tree` 結果の JSON 形を確認(先頭 `{`、必須キー、children のリーフが path のみ)。
|
||||
4. その後、深さ2→任意深さ(max-depth=64、visited)を段階的に解禁。
|
||||
|
||||
代表コマンド
|
||||
- ビルド: `cargo build --release`
|
||||
- 最小 dep-tree: `./target/release/nyash --backend vm apps/selfhost/tools/dep_tree_min_string.nyash`
|
||||
- 最小 dep-tree: `./target/release/nyash --backend vm apps/selfhost/tools/dep_tree_min_string.hako`
|
||||
- 生成: `make dep-tree`(`tmp/deps.json`)
|
||||
|
||||
@ -8,7 +8,7 @@ Scope (Phase 0)
|
||||
- Runner bridge: `NYASH_DEPS_JSON=<path>` is read and logged only (no behavior change).
|
||||
|
||||
Tool
|
||||
- `apps/selfhost/tools/dep_tree_min_string.nyash`
|
||||
- `apps/selfhost/tools/dep_tree_min_string.hako`
|
||||
- Recursively reads source files, scans for `include "path"` outside of strings and comments.
|
||||
- Comments: `//` and `#` (line comments) are ignored.
|
||||
- Strings: `"..."` with `\"` escapes are honored.
|
||||
@ -30,10 +30,10 @@ Acceptance criteria
|
||||
- Cycles do not crash or loop; the repeated node is represented as a leaf.
|
||||
|
||||
Examples
|
||||
- Root: `apps/selfhost/smokes/dep_smoke_root.nyash` (includes `dep_smoke_child.nyash`)
|
||||
- Cycle: `apps/selfhost/smokes/dep_smoke_cycle_a.nyash` ↔ `dep_smoke_cycle_b.nyash`
|
||||
- Root: `apps/selfhost/smokes/dep_smoke_root.hako` (includes `dep_smoke_child.hako`)
|
||||
- Cycle: `apps/selfhost/smokes/dep_smoke_cycle_a.hako` ↔ `dep_smoke_cycle_b.hako`
|
||||
|
||||
Validation (examples)
|
||||
- `echo apps/selfhost/smokes/dep_smoke_root.nyash | ./target/release/nyash --backend vm apps/selfhost/tools/dep_tree_min_string.nyash`
|
||||
- `echo apps/selfhost/smokes/dep_smoke_root.hako | ./target/release/nyash --backend vm apps/selfhost/tools/dep_tree_min_string.hako`
|
||||
- `make dep-tree`
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ API Semantics
|
||||
|
||||
Implementation Plan (staged, non‑breaking)
|
||||
1) Provide MVP cursor boxes (done)
|
||||
- apps/libs/utf8_cursor.nyash
|
||||
- apps/libs/byte_cursor.nyash
|
||||
- apps/libs/utf8_cursor.hako
|
||||
- apps/libs/byte_cursor.hako
|
||||
2) Delegate StringBox public methods to Utf8CursorBox (internal only; behavior unchanged)
|
||||
- Start with length → indexOf → substring
|
||||
- Add targeted smokes for edge cases (multi‑byte CP, boundaries)
|
||||
|
||||
@ -36,7 +36,7 @@ CLI/ツール統合(案)
|
||||
- バックエンドキー: `--backend cranelift-aot`
|
||||
- PoC フラグ: `--poc-const N`(`ny_main` が `N` を返す単機能)
|
||||
- 補助スクリプト(設計のみ、本ブランチでは作成しない):
|
||||
- `tools/aot_smoke_cranelift.sh apps/APP/main.nyash -o app`
|
||||
- `tools/aot_smoke_cranelift.sh apps/APP/main.hako -o app`
|
||||
- 流れ: Nyash → MIR → CraneliftAotBox → `.o` → LinkerBox/cc → `app`
|
||||
|
||||
ロードマップ
|
||||
|
||||
@ -43,7 +43,7 @@ src/backend/llvm/
|
||||
|
||||
```bash
|
||||
# Run with mock LLVM backend
|
||||
cargo run -- --backend llvm test_program.nyash
|
||||
cargo run -- --backend llvm test_program.hako
|
||||
|
||||
# This will:
|
||||
# 1. Parse Nyash source to AST
|
||||
@ -63,7 +63,7 @@ sudo apt install llvm-17-dev clang-17
|
||||
cargo build --features llvm --release
|
||||
|
||||
# Run with real LLVM backend
|
||||
cargo run --features llvm -- --backend llvm test_program.nyash
|
||||
cargo run --features llvm -- --backend llvm test_program.hako
|
||||
|
||||
# This will:
|
||||
# 1. Parse Nyash source to AST
|
||||
@ -78,7 +78,7 @@ cargo run --features llvm -- --backend llvm test_program.nyash
|
||||
|
||||
### Basic Return Test
|
||||
|
||||
**File**: `local_tests/test_return_42.nyash`
|
||||
**File**: `local_tests/test_return_42.hako`
|
||||
```nyash
|
||||
static box Main {
|
||||
main() {
|
||||
@ -95,7 +95,7 @@ static box Main {
|
||||
|
||||
```bash
|
||||
# Test mock implementation
|
||||
cargo run -- --backend llvm local_tests/test_return_42.nyash
|
||||
cargo run -- --backend llvm local_tests/test_return_42.hako
|
||||
echo "Exit code: $?"
|
||||
|
||||
# Should show mock execution and exit code 0 (42 when real implementation is complete)
|
||||
|
||||
@ -35,7 +35,7 @@ CraneliftAotBox インタフェース草案(Phase 15 準備)
|
||||
使用例(PoC フロー)
|
||||
1) NyRT ビルド: `cargo build -p nyrt --release`
|
||||
2) オブジェクト出力(CLIイメージ):
|
||||
- `nyash --backend cranelift-aot --poc-const 42 apps/hello/main.nyash -o ny_main.o`
|
||||
- `nyash --backend cranelift-aot --poc-const 42 apps/hello/main.hako -o ny_main.o`
|
||||
3) リンク:
|
||||
- Linux: `cc -o app ny_main.o target/release/libnyrt.a -ldl -lpthread`
|
||||
- Windows: `link ny_main.obj nyrt.lib /OUT:app.exe`
|
||||
@ -48,7 +48,7 @@ CraneliftAotBox インタフェース草案(Phase 15 準備)
|
||||
補助スクリプトの仕様(設計のみ)
|
||||
- ファイル: `tools/aot_smoke_cranelift.sh`
|
||||
- 目的: `.o/.obj` を生成→リンク→実行して PoC を自動検証。
|
||||
- 主要引数: `apps/APP/main.nyash -o app`、必要に応じ `--const` を透過的に渡す。
|
||||
- 主要引数: `apps/APP/main.hako -o app`、必要に応じ `--const` を透過的に渡す。
|
||||
|
||||
今後の拡張(非ブロッキング)
|
||||
- NyRT の外部関数呼び出し(checkpoint など)の導入。
|
||||
|
||||
@ -5,7 +5,7 @@ Status: open
|
||||
Summary
|
||||
|
||||
- When compiling code that concatenates a string literal with a non-string (e.g., integer), LLVM object emission fails with a type mismatch in binop.
|
||||
- Example from `apps/ny-map-llvm-smoke/main.nyash`: `print("Map: v=" + v)` and `print("size=" + s)`.
|
||||
- Example from `apps/ny-map-llvm-smoke/main.hako`: `print("Map: v=" + v)` and `print("size=" + s)`.
|
||||
|
||||
Environment
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Notes:
|
||||
Run checks:
|
||||
- Build (JIT): `cargo build --release --features cranelift-jit`
|
||||
- jit‑direct smokes:
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-branch-ret/main.nyash`
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-phi-min/main.nyash`
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-branch-multi/main.nyash`
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-branch-ret/main.hako`
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-phi-min/main.hako`
|
||||
- `NYASH_JIT_THRESHOLD=1 ./target/release/nyash --jit-direct apps/tests/mir-branch-multi/main.hako`
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ C-ABI境界デバッグのGUIツール。**「ぽいっと付け外し」「視
|
||||
|
||||
## 📁 Files Structure
|
||||
|
||||
- `gemini-ipc-implementation.nyash` - Geminiの172行実装コード
|
||||
- `gemini-ipc-implementation.hako` - Geminiの172行実装コード
|
||||
- `chatgpt-design-spec.md` - ChatGPTの設計仕様
|
||||
- `inspiration-process.md` - 1分発想プロセスの記録
|
||||
- `technical-roadmap.md` - 実装ロードマップ(2週間MVP)
|
||||
|
||||
@ -63,7 +63,7 @@ C ABI Calls → Real-time Logs → JSON Stream → 可視化
|
||||
"outcome": "Ok",
|
||||
"elapsed_us": 87,
|
||||
"by_name": false,
|
||||
"site": {"file":"apps/x.nyash","line":42}
|
||||
"site": {"file":"apps/x.hako","line":42}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -36,11 +36,11 @@ description = "素晴らしいNyashプロジェクト"
|
||||
|
||||
[dependencies]
|
||||
# 標準ライブラリ
|
||||
nyashstd = { path = "./stdlib/nyashstd.nyash" }
|
||||
nyashstd = { path = "./stdlib/nyashstd.hako" }
|
||||
|
||||
# ユーザーライブラリ
|
||||
mylib = { path = "./libs/mylib.nyash" }
|
||||
utils = { path = "./src/utils.nyash" }
|
||||
mylib = { path = "./libs/mylib.hako" }
|
||||
utils = { path = "./src/utils.hako" }
|
||||
|
||||
# 将来の外部パッケージ(例)
|
||||
# http_client = { version = "1.0.0", registry = "nyash-pkg" }
|
||||
@ -51,7 +51,7 @@ libs = "./libs/"
|
||||
src = "./src/"
|
||||
|
||||
[build]
|
||||
entry_point = "./src/main.nyash"
|
||||
entry_point = "./src/main.hako"
|
||||
```
|
||||
|
||||
### 依存関係タイプ
|
||||
@ -59,7 +59,7 @@ entry_point = "./src/main.nyash"
|
||||
#### 1. **ローカル依存**
|
||||
```toml
|
||||
[dependencies]
|
||||
my_module = { path = "./src/my_module.nyash" }
|
||||
my_module = { path = "./src/my_module.hako" }
|
||||
```
|
||||
|
||||
#### 2. **標準ライブラリ**
|
||||
@ -130,30 +130,30 @@ nyashstd.string.upper("hello") // using不要
|
||||
my-nyash-project/
|
||||
├── nyash.link # 依存関係定義
|
||||
├── src/
|
||||
│ ├── main.nyash # エントリーポイント
|
||||
│ ├── utils.nyash # ユーティリティモジュール
|
||||
│ ├── main.hako # エントリーポイント
|
||||
│ ├── utils.hako # ユーティリティモジュール
|
||||
│ └── models/
|
||||
│ └── user.nyash # モデル定義
|
||||
│ └── user.hako # モデル定義
|
||||
├── libs/ # プロジェクト固有ライブラリ
|
||||
│ └── mylib.nyash
|
||||
│ └── mylib.hako
|
||||
├── stdlib/ # 標準ライブラリ(システム配布)
|
||||
│ └── nyashstd.nyash
|
||||
│ └── nyashstd.hako
|
||||
└── tests/ # テストファイル
|
||||
└── test_main.nyash
|
||||
└── test_main.hako
|
||||
```
|
||||
|
||||
### 標準ライブラリ構造
|
||||
```
|
||||
stdlib/
|
||||
├── nyashstd.nyash # メインエントリー
|
||||
├── nyashstd.hako # メインエントリー
|
||||
├── string/
|
||||
│ └── mod.nyash # string関連機能
|
||||
│ └── mod.hako # string関連機能
|
||||
├── math/
|
||||
│ └── mod.nyash # 数学関数
|
||||
│ └── mod.hako # 数学関数
|
||||
├── http/
|
||||
│ └── mod.nyash # HTTP関連
|
||||
│ └── mod.hako # HTTP関連
|
||||
└── io/
|
||||
└── mod.nyash # I/O関連
|
||||
└── mod.hako # I/O関連
|
||||
```
|
||||
|
||||
## 🔄 動作フロー
|
||||
@ -167,13 +167,13 @@ cd my-project
|
||||
|
||||
### 2. 実行時解決
|
||||
```
|
||||
main.nyash実行
|
||||
main.hako実行
|
||||
↓
|
||||
nyash.link読み込み
|
||||
↓
|
||||
using nyashstd解析
|
||||
↓
|
||||
./stdlib/nyashstd.nyash読み込み
|
||||
./stdlib/nyashstd.hako読み込み
|
||||
↓
|
||||
namespace nyashstd解析・登録
|
||||
↓
|
||||
@ -200,7 +200,7 @@ mylib.hello() // 関数呼び出し
|
||||
|
||||
// nyash.link
|
||||
[dependencies]
|
||||
mylib = { path = "./mylib.nyash" }
|
||||
mylib = { path = "./mylib.hako" }
|
||||
```
|
||||
|
||||
### Phase 2: 名前空間サポート
|
||||
@ -209,7 +209,7 @@ mylib = { path = "./mylib.nyash" }
|
||||
using nyashstd
|
||||
string.upper("hello")
|
||||
|
||||
// nyashstd.nyash
|
||||
// nyashstd.hako
|
||||
namespace nyashstd {
|
||||
static box string {
|
||||
static upper(str) { ... }
|
||||
@ -237,7 +237,7 @@ namespace nyashstd {
|
||||
|
||||
### 📝 Medium(来週)
|
||||
7. **namespace構文** - static box解析
|
||||
8. **標準ライブラリ設計** - nyashstd.nyash作成
|
||||
8. **標準ライブラリ設計** - nyashstd.hako作成
|
||||
9. **完全修飾名** - nyashstd.string.upper()
|
||||
|
||||
### 🔮 Future(今後)
|
||||
|
||||
@ -256,7 +256,7 @@ impl UniversalNamespaceRegistry {
|
||||
},
|
||||
Dependency::Path { path } => {
|
||||
let module = ExternalModule::load_from_file(Path::new(path))?;
|
||||
self.nyash_modules.insert(namespace_name.clone(), Arc::new(module));
|
||||
self.hako_modules.insert(namespace_name.clone(), Arc::new(module));
|
||||
},
|
||||
Dependency::Builtin { .. } => {
|
||||
// 組み込みライブラリは既に初期化済み
|
||||
@ -298,7 +298,7 @@ impl UniversalNamespaceRegistry {
|
||||
}
|
||||
|
||||
// Nyashモジュールチェック
|
||||
if let Some(_module) = self.nyash_modules.get(namespace_name) {
|
||||
if let Some(_module) = self.hako_modules.get(namespace_name) {
|
||||
if !context.module_namespaces.contains(&namespace_name.to_string()) {
|
||||
context.module_namespaces.push(namespace_name.to_string());
|
||||
}
|
||||
@ -351,7 +351,7 @@ impl UniversalNamespaceRegistry {
|
||||
|
||||
// 3. Nyashモジュール解決
|
||||
for namespace in &context.module_namespaces {
|
||||
if let Some(module) = self.nyash_modules.get(namespace) {
|
||||
if let Some(module) = self.hako_modules.get(namespace) {
|
||||
if let Some(function) = module.resolve_function(box_name, method_name) {
|
||||
return Ok(ResolvedCall::ModuleCall {
|
||||
namespace: namespace.clone(),
|
||||
@ -580,7 +580,7 @@ impl VmBackend {
|
||||
|
||||
#### **Phase 0: 基本統合テスト**
|
||||
```nyash
|
||||
# test_basic_integration.nyash
|
||||
# test_basic_integration.hako
|
||||
using nyashstd
|
||||
|
||||
# 組み込み標準ライブラリのみ
|
||||
@ -590,7 +590,7 @@ assert(math.sin(0) == 0)
|
||||
|
||||
#### **Phase 1: BID統合テスト**
|
||||
```nyash
|
||||
# test_bid_integration.nyash
|
||||
# test_bid_integration.hako
|
||||
using nyashstd
|
||||
using console_api
|
||||
|
||||
@ -601,7 +601,7 @@ console.log("Testing") # FFI-ABI
|
||||
|
||||
#### **Phase 2: 完全統合テスト**
|
||||
```nyash
|
||||
# test_full_integration.nyash
|
||||
# test_full_integration.hako
|
||||
using nyashstd
|
||||
using console_api
|
||||
using mylib
|
||||
@ -614,7 +614,7 @@ mylib.process("data") # Nyashモジュール
|
||||
|
||||
### エラーハンドリングテスト
|
||||
```nyash
|
||||
# test_error_handling.nyash
|
||||
# test_error_handling.hako
|
||||
try {
|
||||
using nonexistent_api
|
||||
} catch error {
|
||||
|
||||
@ -386,7 +386,7 @@ string_box.split(separator) // 新規実装不要
|
||||
|
||||
#### **基本機能テスト**
|
||||
```nyash
|
||||
# test_builtin_stdlib_basic.nyash
|
||||
# test_builtin_stdlib_basic.hako
|
||||
using nyashstd
|
||||
|
||||
# 文字列操作
|
||||
@ -406,7 +406,7 @@ assert(array.get(arr, 1) == 2)
|
||||
|
||||
#### **エラーハンドリング**
|
||||
```nyash
|
||||
# test_builtin_stdlib_errors.nyash
|
||||
# test_builtin_stdlib_errors.hako
|
||||
using nyashstd
|
||||
|
||||
# 引数数エラー
|
||||
|
||||
@ -7,15 +7,15 @@
|
||||
my-awesome-app/
|
||||
├── nyash.link # 依存関係定義
|
||||
├── src/
|
||||
│ ├── main.nyash # メインファイル
|
||||
│ ├── main.hako # メインファイル
|
||||
│ ├── models/
|
||||
│ │ └── user.nyash # ユーザーモデル
|
||||
│ │ └── user.hako # ユーザーモデル
|
||||
│ └── utils/
|
||||
│ └── helpers.nyash # ヘルパー関数
|
||||
│ └── helpers.hako # ヘルパー関数
|
||||
├── libs/
|
||||
│ └── custom_lib.nyash # カスタムライブラリ
|
||||
│ └── custom_lib.hako # カスタムライブラリ
|
||||
└── stdlib/
|
||||
└── nyashstd.nyash # 標準ライブラリ
|
||||
└── nyashstd.hako # 標準ライブラリ
|
||||
```
|
||||
|
||||
### 📋 nyash.linkファイル例
|
||||
@ -27,14 +27,14 @@ description = "Everything is Box philosophy in action!"
|
||||
|
||||
[dependencies]
|
||||
# 標準ライブラリ
|
||||
nyashstd = { path = "./stdlib/nyashstd.nyash" }
|
||||
nyashstd = { path = "./stdlib/nyashstd.hako" }
|
||||
|
||||
# プロジェクト内モジュール
|
||||
user_model = { path = "./src/models/user.nyash" }
|
||||
helpers = { path = "./src/utils/helpers.nyash" }
|
||||
user_model = { path = "./src/models/user.hako" }
|
||||
helpers = { path = "./src/utils/helpers.hako" }
|
||||
|
||||
# カスタムライブラリ
|
||||
custom_lib = { path = "./libs/custom_lib.nyash" }
|
||||
custom_lib = { path = "./libs/custom_lib.hako" }
|
||||
|
||||
[search_paths]
|
||||
stdlib = "./stdlib/"
|
||||
@ -42,14 +42,14 @@ src = "./src/"
|
||||
libs = "./libs/"
|
||||
|
||||
[build]
|
||||
entry_point = "./src/main.nyash"
|
||||
entry_point = "./src/main.hako"
|
||||
```
|
||||
|
||||
## 🌟 実用的なコード例
|
||||
|
||||
### 1. 基本的なusing使用
|
||||
```nyash
|
||||
# ===== src/main.nyash =====
|
||||
# ===== src/main.hako =====
|
||||
using nyashstd
|
||||
using helpers
|
||||
|
||||
@ -77,7 +77,7 @@ static box Main {
|
||||
|
||||
### 2. 標準ライブラリ定義例
|
||||
```nyash
|
||||
# ===== stdlib/nyashstd.nyash =====
|
||||
# ===== stdlib/nyashstd.hako =====
|
||||
namespace nyashstd {
|
||||
static box string {
|
||||
static upper(str) {
|
||||
@ -139,7 +139,7 @@ namespace nyashstd {
|
||||
|
||||
### 3. ヘルパーモジュール例
|
||||
```nyash
|
||||
# ===== src/utils/helpers.nyash =====
|
||||
# ===== src/utils/helpers.hako =====
|
||||
using nyashstd
|
||||
|
||||
static function process_data(data) {
|
||||
@ -161,7 +161,7 @@ static function format_user_name(first, last) {
|
||||
|
||||
### 4. モデル定義例
|
||||
```nyash
|
||||
# ===== src/models/user.nyash =====
|
||||
# ===== src/models/user.hako =====
|
||||
using nyashstd
|
||||
using helpers
|
||||
|
||||
@ -200,7 +200,7 @@ box User {
|
||||
|
||||
### 1. シンプルなWebサーバー
|
||||
```nyash
|
||||
# ===== web_server.nyash =====
|
||||
# ===== web_server.hako =====
|
||||
using nyashstd
|
||||
using custom_lib
|
||||
|
||||
@ -245,7 +245,7 @@ server.start()
|
||||
|
||||
### 2. データ処理パイプライン
|
||||
```nyash
|
||||
# ===== data_processor.nyash =====
|
||||
# ===== data_processor.hako =====
|
||||
using nyashstd
|
||||
using helpers
|
||||
|
||||
@ -341,8 +341,8 @@ local sin_val = sin(3.14) # math.sin不要
|
||||
### Before(現在のinclude使用)
|
||||
```nyash
|
||||
# ===== 既存のtext_adventure例 =====
|
||||
include "text_adventure/items.nyash"
|
||||
include "text_adventure/rooms.nyash"
|
||||
include "text_adventure/items.hako"
|
||||
include "text_adventure/rooms.hako"
|
||||
|
||||
# アイテム作成
|
||||
local sword = new Weapon("Sword", 10)
|
||||
@ -352,10 +352,10 @@ local sword = new Weapon("Sword", 10)
|
||||
```nyash
|
||||
# ===== nyash.link =====
|
||||
[dependencies]
|
||||
game_items = { path = "./text_adventure/items.nyash" }
|
||||
game_rooms = { path = "./text_adventure/rooms.nyash" }
|
||||
game_items = { path = "./text_adventure/items.hako" }
|
||||
game_rooms = { path = "./text_adventure/rooms.hako" }
|
||||
|
||||
# ===== main.nyash =====
|
||||
# ===== main.hako =====
|
||||
using game_items
|
||||
using game_rooms
|
||||
|
||||
|
||||
@ -321,7 +321,7 @@ pub struct NamespaceRegistry {
|
||||
### 📁 nyash.link対応
|
||||
```toml
|
||||
[dependencies]
|
||||
mylib = { path = "./mylib.nyash" }
|
||||
mylib = { path = "./mylib.hako" }
|
||||
|
||||
# using mylib # Phase 2で対応
|
||||
```
|
||||
@ -330,7 +330,7 @@ mylib = { path = "./mylib.nyash" }
|
||||
|
||||
### Phase 0テスト
|
||||
```nyash
|
||||
# test_phase0_basic.nyash
|
||||
# test_phase0_basic.hako
|
||||
using nyashstd
|
||||
|
||||
# 基本動作
|
||||
@ -347,7 +347,7 @@ try {
|
||||
|
||||
### Phase 1テスト
|
||||
```nyash
|
||||
# test_phase1_qualified.nyash
|
||||
# test_phase1_qualified.hako
|
||||
# using不要のテスト
|
||||
assert(nyashstd.string.upper("hello") == "HELLO")
|
||||
assert(nyashstd.math.sin(0) == 0)
|
||||
@ -355,7 +355,7 @@ assert(nyashstd.math.sin(0) == 0)
|
||||
|
||||
### Phase 2テスト
|
||||
```nyash
|
||||
# test_phase2_external.nyash
|
||||
# test_phase2_external.hako
|
||||
using mylib
|
||||
|
||||
assert(mylib.custom.process("data") == "processed: data")
|
||||
|
||||
@ -187,7 +187,7 @@ impl ModuleResolver {
|
||||
}
|
||||
|
||||
// ファイルパス解決
|
||||
let file_path = self.nyash_link.resolve_dependency(module_name)
|
||||
let file_path = self.hako_link.resolve_dependency(module_name)
|
||||
.ok_or(ResolverError::ModuleNotFound(module_name.to_string()))?;
|
||||
|
||||
// 再帰的読み込み防止
|
||||
@ -376,15 +376,15 @@ impl NyashInterpreter {
|
||||
|
||||
### Phase 1テスト
|
||||
```nyash
|
||||
# test_basic_using.nyash
|
||||
# test_basic_using.hako
|
||||
# 基本using文テスト
|
||||
|
||||
# ファイル: mylib.nyash
|
||||
# ファイル: mylib.hako
|
||||
static function hello() {
|
||||
return "Hello from mylib!"
|
||||
}
|
||||
|
||||
# ファイル: main.nyash
|
||||
# ファイル: main.hako
|
||||
using mylib
|
||||
local result = mylib.hello()
|
||||
assert(result == "Hello from mylib!")
|
||||
@ -392,12 +392,12 @@ assert(result == "Hello from mylib!")
|
||||
|
||||
### Phase 2テスト
|
||||
```nyash
|
||||
# test_nyash_link.nyash
|
||||
# test_nyash_link.hako
|
||||
# nyash.linkファイル連携テスト
|
||||
|
||||
# nyash.link内容:
|
||||
# [dependencies]
|
||||
# mylib = { path = "./mylib.nyash" }
|
||||
# mylib = { path = "./mylib.hako" }
|
||||
|
||||
using mylib
|
||||
local result = mylib.process("data")
|
||||
@ -406,10 +406,10 @@ assert(result == "processed: data")
|
||||
|
||||
### Phase 3テスト
|
||||
```nyash
|
||||
# test_namespace.nyash
|
||||
# test_namespace.hako
|
||||
# 名前空間システムテスト
|
||||
|
||||
# nyashstd.nyash:
|
||||
# nyashstd.hako:
|
||||
# namespace nyashstd {
|
||||
# static box string {
|
||||
# static upper(str) { ... }
|
||||
@ -457,7 +457,7 @@ assert(result2 == "WORLD")
|
||||
- 動的モジュール読み込み
|
||||
|
||||
### Phase 6: 標準ライブラリ
|
||||
- nyashstd.nyash完全実装
|
||||
- nyashstd.hako完全実装
|
||||
- string/math/io/http モジュール
|
||||
- ドキュメント生成
|
||||
|
||||
|
||||
@ -149,9 +149,9 @@ http_api = {
|
||||
}
|
||||
|
||||
# === Nyashモジュール(従来通り) ===
|
||||
mylib = { path = "./src/mylib.nyash" }
|
||||
mylib = { path = "./src/mylib.hako" }
|
||||
utils = { path = "./src/utils/" }
|
||||
models = { path = "./src/models.nyash" }
|
||||
models = { path = "./src/models.hako" }
|
||||
|
||||
# === 将来の外部パッケージ ===
|
||||
awesome_lib = {
|
||||
@ -161,7 +161,7 @@ awesome_lib = {
|
||||
}
|
||||
|
||||
[build]
|
||||
entry_point = "./src/main.nyash"
|
||||
entry_point = "./src/main.hako"
|
||||
backends = ["vm", "wasm", "aot"]
|
||||
optimization_level = "release"
|
||||
|
||||
|
||||
@ -342,7 +342,7 @@ impl NyashParser {
|
||||
|
||||
#### **基本using文テスト**
|
||||
```nyash
|
||||
# test_using_basic.nyash
|
||||
# test_using_basic.hako
|
||||
using nyashstd
|
||||
|
||||
local result = string.upper("hello")
|
||||
@ -354,7 +354,7 @@ assert(lower == "world")
|
||||
|
||||
#### **数学関数テスト**
|
||||
```nyash
|
||||
# test_math_basic.nyash
|
||||
# test_math_basic.hako
|
||||
using nyashstd
|
||||
|
||||
local sin_result = math.sin(0)
|
||||
@ -366,7 +366,7 @@ assert(sqrt_result == 4)
|
||||
|
||||
#### **配列操作テスト**
|
||||
```nyash
|
||||
# test_array_basic.nyash
|
||||
# test_array_basic.hako
|
||||
using nyashstd
|
||||
|
||||
local arr = [1, 2, 3]
|
||||
@ -410,7 +410,7 @@ namespace mylib {
|
||||
```toml
|
||||
# nyash.link
|
||||
[dependencies]
|
||||
mylib = { path = "./mylib.nyash" }
|
||||
mylib = { path = "./mylib.hako" }
|
||||
```
|
||||
|
||||
## 🎯 実装優先順位
|
||||
|
||||
@ -11,7 +11,7 @@ canvas_api = { bid = "./apis/canvas.yaml" }
|
||||
dom_api = { bid = "./apis/dom.yaml" }
|
||||
audio_api = { bid = "./apis/webaudio.yaml" }
|
||||
|
||||
# === game.nyash ===
|
||||
# === game.hako ===
|
||||
using nyashstd
|
||||
using canvas_api
|
||||
using dom_api
|
||||
@ -123,7 +123,7 @@ numpy_api = { bid = "./apis/numpy.yaml", library = "./libs/numpy.so" }
|
||||
matplotlib_api = { bid = "./apis/matplotlib.yaml", library = "./libs/matplotlib.so" }
|
||||
file_api = { bid = "./apis/file.yaml" }
|
||||
|
||||
# === image_processor.nyash ===
|
||||
# === image_processor.hako ===
|
||||
using nyashstd
|
||||
using opencv_api
|
||||
using numpy_api
|
||||
@ -213,7 +213,7 @@ sqlite_api = { bid = "./apis/sqlite.yaml", library = "./libs/sqlite.so" }
|
||||
json_api = { bid = "./apis/json.yaml" }
|
||||
crypto_api = { bid = "./apis/crypto.yaml", library = "./libs/openssl.so" }
|
||||
|
||||
# === api_server.nyash ===
|
||||
# === api_server.hako ===
|
||||
using nyashstd
|
||||
using http_server_api
|
||||
using sqlite_api
|
||||
@ -342,7 +342,7 @@ libc_api = { bid = "./apis/libc.yaml", library = "system" }
|
||||
inotify_api = { bid = "./apis/inotify.yaml", library = "system" }
|
||||
filesystem_api = { bid = "./apis/filesystem.yaml" }
|
||||
|
||||
# === file_monitor.nyash ===
|
||||
# === file_monitor.hako ===
|
||||
using nyashstd
|
||||
using libc_api
|
||||
using inotify_api
|
||||
|
||||
@ -55,15 +55,15 @@ opencv = { bid = "./apis/opencv.yaml", library = "./libs/opencv.so" }
|
||||
sqlite = { bid = "./apis/sqlite.yaml", library = "./libs/sqlite.so" }
|
||||
|
||||
# === Nyashモジュール(従来通り) ===
|
||||
mylib = { path = "./src/mylib.nyash" }
|
||||
utils = { path = "./src/utils.nyash" }
|
||||
mylib = { path = "./src/mylib.hako" }
|
||||
utils = { path = "./src/utils.hako" }
|
||||
models = { path = "./src/models/" }
|
||||
|
||||
# === 将来の外部パッケージ ===
|
||||
# http_client = { version = "1.0.0", registry = "nyash-pkg" }
|
||||
|
||||
[build]
|
||||
entry_point = "./src/main.nyash"
|
||||
entry_point = "./src/main.hako"
|
||||
backends = ["vm", "wasm", "aot"] # 対象バックエンド指定
|
||||
```
|
||||
|
||||
@ -207,7 +207,7 @@ impl UniversalNamespaceRegistry {
|
||||
}
|
||||
|
||||
// Nyashモジュール
|
||||
if self.nyash_modules.contains_key(namespace_name) {
|
||||
if self.hako_modules.contains_key(namespace_name) {
|
||||
if !context.module_imports.contains(&namespace_name.to_string()) {
|
||||
context.module_imports.push(namespace_name.to_string());
|
||||
}
|
||||
@ -249,7 +249,7 @@ impl UniversalNamespaceRegistry {
|
||||
|
||||
// 3. Nyashモジュール検索
|
||||
for namespace in &context.module_imports {
|
||||
if let Some(module) = self.nyash_modules.get(namespace) {
|
||||
if let Some(module) = self.hako_modules.get(namespace) {
|
||||
if let Some(target) = module.resolve_method(box_name, method_name) {
|
||||
return Ok(CallTarget::NyashModule(target));
|
||||
}
|
||||
@ -520,7 +520,7 @@ impl AotCompiler {
|
||||
|
||||
### 基本統合テスト
|
||||
```nyash
|
||||
# test_universal_integration.nyash
|
||||
# test_universal_integration.hako
|
||||
using nyashstd
|
||||
using console_api
|
||||
using mylib
|
||||
@ -533,7 +533,7 @@ assert(mylib.process("data") == "processed") # Nyash
|
||||
|
||||
### FFI-ABI統合テスト
|
||||
```nyash
|
||||
# test_ffi_abi_integration.nyash
|
||||
# test_ffi_abi_integration.hako
|
||||
using canvas_api
|
||||
|
||||
# Canvas API経由での描画
|
||||
|
||||
@ -217,14 +217,14 @@ echo 'static box Main {
|
||||
|
||||
return me.server.isServer()
|
||||
}
|
||||
}' > test_arc_fix.nyash
|
||||
}' > test_arc_fix.hako
|
||||
```
|
||||
|
||||
### 実行・検証
|
||||
```bash
|
||||
# ビルド・実行
|
||||
cargo build --release
|
||||
./target/release/nyash test_arc_fix.nyash
|
||||
./target/release/nyash test_arc_fix.hako
|
||||
|
||||
# 期待される結果:
|
||||
# === Before bind ===
|
||||
@ -251,7 +251,7 @@ cargo build --release
|
||||
## 🎯 修正完了条件
|
||||
|
||||
### ✅ 成功条件
|
||||
1. **テスト成功**: `test_arc_fix.nyash` で `isServer: true` が表示される
|
||||
1. **テスト成功**: `test_arc_fix.hako` で `isServer: true` が表示される
|
||||
2. **コンパイル成功**: `cargo build --release` でエラーなし
|
||||
3. **既存テスト成功**: `cargo test` でテスト通過
|
||||
4. **デバッグログ確認**: 同一SocketBox IDが維持される
|
||||
|
||||
@ -342,7 +342,7 @@ impl VMManager {
|
||||
|
||||
#### **JSON v0 完全ローダー**
|
||||
```nyash
|
||||
// apps/selfhost/vm/json_loader.nyash
|
||||
// apps/selfhost/vm/json_loader.hako
|
||||
static box JSONLoader {
|
||||
parse_mir_module(json_string: StringBox) -> MirModuleBox {
|
||||
local root = me.parse_json_object(json_string)
|
||||
@ -422,7 +422,7 @@ static box JSONLoader {
|
||||
|
||||
#### **MIR14命令完全実装**
|
||||
```nyash
|
||||
// apps/selfhost/vm/mir_executor.nyash
|
||||
// apps/selfhost/vm/mir_executor.hako
|
||||
static box MirExecutor {
|
||||
stack: ArrayBox
|
||||
heap: MapBox
|
||||
@ -607,7 +607,7 @@ static box MirExecutor {
|
||||
./tools/test/phase1/mini_vm_vs_pyvm.sh
|
||||
|
||||
# 期待する成功例
|
||||
echo '{"functions": [{"name": "main", "body": [...]}]}' | ./mini_vm.nyash
|
||||
echo '{"functions": [{"name": "main", "body": [...]}]}' | ./mini_vm.hako
|
||||
# → PyVMと同一の出力
|
||||
```
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ High‑Value Candidates
|
||||
|
||||
Low‑Risk Cleanups
|
||||
- Tools scripts: dedupe `tools/*smoke*.sh` into `tools/smokes/` with common helpers (env, timeout, exit filtering).
|
||||
- Tests naming: prefer `*_test.rs` and `apps/tests/*.nyash` consistency for smokes.
|
||||
- Tests naming: prefer `*_test.rs` and `apps/tests/*.hako` consistency for smokes.
|
||||
- Logging: add `NYASH_CLI_VERBOSE` guards consistently; provide `runner::trace!(...)` macro for concise on/off.
|
||||
|
||||
Suggested Sequencing
|
||||
|
||||
@ -26,8 +26,8 @@ Current Performance (100 iterations avg):
|
||||
**実装アプローチ**:
|
||||
```bash
|
||||
# 新CLI機能
|
||||
nyash --compile-native program.nyash -o program.exe
|
||||
nyash --aot program.nyash # 短縮形
|
||||
nyash --compile-native program.hako -o program.exe
|
||||
nyash --aot program.hako # 短縮形
|
||||
|
||||
# 内部パイプライン
|
||||
Nyash → AST → MIR → WASM → wasmtime compile → Native Binary
|
||||
@ -50,7 +50,7 @@ Nyash → AST → MIR → WASM → wasmtime compile → Native Binary
|
||||
**実装ファイル**:
|
||||
- `src/backend/native_aot.rs` - AOTコンパイラ
|
||||
- `src/main.rs` - CLI統合
|
||||
- `benchmarks/bench_native.nyash` - ネイティブ性能測定
|
||||
- `benchmarks/bench_native.hako` - ネイティブ性能測定
|
||||
|
||||
### 🥈 Phase B: Cranelift Direct (中期 - 2-3ヶ月)
|
||||
**Goal**: MIRから直接ネイティブコード生成
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
#### **Phase A: AOT WASM** (最優先 - 2-3週間)
|
||||
```bash
|
||||
nyash --compile-native program.nyash -o program.exe
|
||||
nyash --compile-native program.hako -o program.exe
|
||||
```
|
||||
- **技術**: wasmtime compile でネイティブ化
|
||||
- **効果**: 13.5倍 → 100倍 (7倍追加向上)
|
||||
|
||||
@ -123,12 +123,12 @@ Scope:
|
||||
Tasks:
|
||||
- Cargo.toml: examples/GUI を feature でガード(default は CLI 最小)。
|
||||
- ビルド検証: `cargo build --bin nyash`(Linux/Windows)。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.nyash`。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.hako`。
|
||||
- ドキュメント: 上記手順を how-to-build-native に追記/点検。
|
||||
|
||||
Acceptance Criteria:
|
||||
- Linux/Windows で `cargo build --bin nyash` が成功する。
|
||||
- `local_tests/` 配下の簡単な .nyash が実行できる。
|
||||
- `local_tests/` 配下の簡単な .hako が実行できる。
|
||||
- 他 bin/examples が壊れていても `--bin nyash` だけで通る。
|
||||
|
||||
Out of Scope:
|
||||
@ -255,7 +255,7 @@ Summary:
|
||||
Scope/Tasks:
|
||||
- AST: BoxDeclaration(is_static=true, name=Main) を検出 → main() を抽出
|
||||
- Lowering: body を Program に変換して既存経路に渡す
|
||||
- Tests: local_tests/mir_loop_no_local.nyash で dump/VM が通る
|
||||
- Tests: local_tests/mir_loop_no_local.hako で dump/VM が通る
|
||||
|
||||
Acceptance Criteria:
|
||||
- `--dump-mir` が static Main サンプルで成功
|
||||
@ -350,7 +350,7 @@ Expected Duration: 1週間
|
||||
|
||||
### 成功基準
|
||||
- Phase 8.3のBox操作WASMが実際に動作
|
||||
- test_wasm_box_ops.nyash が正常実行
|
||||
- test_wasm_box_ops.hako が正常実行
|
||||
- ユーザー定義Boxの完全サポート
|
||||
|
||||
------------------------------------------------------------
|
||||
@ -555,7 +555,7 @@ Scope/Tasks:
|
||||
- 起動時間・配布サイズ最適化
|
||||
|
||||
Acceptance Criteria:
|
||||
- `nyash --compile-native app.nyash -o app.exe` 動作
|
||||
- `nyash --compile-native app.hako -o app.exe` 動作
|
||||
- 起動時間大幅短縮(JIT起動コスト除去)
|
||||
- 配布可能実行ファイル生成
|
||||
|
||||
|
||||
@ -124,12 +124,12 @@ Scope:
|
||||
Tasks:
|
||||
- Cargo.toml: examples/GUI を feature でガード(default は CLI 最小)。
|
||||
- ビルド検証: `cargo build --bin nyash`(Linux/Windows)。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.nyash`。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.hako`。
|
||||
- ドキュメント: 上記手順を how-to-build-native に追記/点検。
|
||||
|
||||
Acceptance Criteria:
|
||||
- Linux/Windows で `cargo build --bin nyash` が成功する。
|
||||
- `local_tests/` 配下の簡単な .nyash が実行できる。
|
||||
- `local_tests/` 配下の簡単な .hako が実行できる。
|
||||
- 他 bin/examples が壊れていても `--bin nyash` だけで通る。
|
||||
|
||||
Out of Scope:
|
||||
@ -256,7 +256,7 @@ Summary:
|
||||
Scope/Tasks:
|
||||
- AST: BoxDeclaration(is_static=true, name=Main) を検出 → main() を抽出
|
||||
- Lowering: body を Program に変換して既存経路に渡す
|
||||
- Tests: local_tests/mir_loop_no_local.nyash で dump/VM が通る
|
||||
- Tests: local_tests/mir_loop_no_local.hako で dump/VM が通る
|
||||
|
||||
Acceptance Criteria:
|
||||
- `--dump-mir` が static Main サンプルで成功
|
||||
@ -350,7 +350,7 @@ Expected Duration: 1週間
|
||||
|
||||
### 成功基準
|
||||
- Phase 8.3のBox操作WASMが実際に動作
|
||||
- test_wasm_box_ops.nyash が正常実行
|
||||
- test_wasm_box_ops.hako が正常実行
|
||||
- ユーザー定義Boxの完全サポート
|
||||
|
||||
------------------------------------------------------------
|
||||
@ -555,7 +555,7 @@ Scope/Tasks:
|
||||
- 起動時間・配布サイズ最適化
|
||||
|
||||
Acceptance Criteria:
|
||||
- `nyash --compile-native app.nyash -o app.exe` 動作
|
||||
- `nyash --compile-native app.hako -o app.exe` 動作
|
||||
- 起動時間大幅短縮(JIT起動コスト除去)
|
||||
- 配布可能実行ファイル生成
|
||||
|
||||
@ -592,7 +592,7 @@ Summary:
|
||||
|
||||
1. **WASM/AOT コンパイルエラー(最重要)**
|
||||
```bash
|
||||
$ ./target/release/nyash --compile-wasm test_simple_loop.nyash
|
||||
$ ./target/release/nyash --compile-wasm test_simple_loop.hako
|
||||
❌ Unsupported instruction: Jump { target: BasicBlockId(1) }
|
||||
```
|
||||
**影響**: ループ・条件分岐を含む全プログラムがWASM/AOT化不可
|
||||
@ -623,7 +623,7 @@ Summary:
|
||||
- グレースフルシャットダウン
|
||||
|
||||
Acceptance Criteria:
|
||||
- ✅ `nyash --compile-wasm test_loop.nyash` 成功
|
||||
- ✅ `nyash --compile-wasm test_loop.hako` 成功
|
||||
- ✅ HTTPサーバー実動作(curl http://localhost:8080/)
|
||||
- ✅ unwrap()使用箇所: 26 → 5以下
|
||||
- ✅ WASM性能: 11.5倍 → 13.5倍達成
|
||||
|
||||
@ -123,12 +123,12 @@ Scope:
|
||||
Tasks:
|
||||
- Cargo.toml: examples/GUI を feature でガード(default は CLI 最小)。
|
||||
- ビルド検証: `cargo build --bin nyash`(Linux/Windows)。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.nyash`。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.hako`。
|
||||
- ドキュメント: 上記手順を how-to-build-native に追記/点検。
|
||||
|
||||
Acceptance Criteria:
|
||||
- Linux/Windows で `cargo build --bin nyash` が成功する。
|
||||
- `local_tests/` 配下の簡単な .nyash が実行できる。
|
||||
- `local_tests/` 配下の簡単な .hako が実行できる。
|
||||
- 他 bin/examples が壊れていても `--bin nyash` だけで通る。
|
||||
|
||||
Out of Scope:
|
||||
@ -255,7 +255,7 @@ Summary:
|
||||
Scope/Tasks:
|
||||
- AST: BoxDeclaration(is_static=true, name=Main) を検出 → main() を抽出
|
||||
- Lowering: body を Program に変換して既存経路に渡す
|
||||
- Tests: local_tests/mir_loop_no_local.nyash で dump/VM が通る
|
||||
- Tests: local_tests/mir_loop_no_local.hako で dump/VM が通る
|
||||
|
||||
Acceptance Criteria:
|
||||
- `--dump-mir` が static Main サンプルで成功
|
||||
@ -349,7 +349,7 @@ Expected Duration: 1週間
|
||||
|
||||
### 成功基準
|
||||
- Phase 8.3のBox操作WASMが実際に動作
|
||||
- test_wasm_box_ops.nyash が正常実行
|
||||
- test_wasm_box_ops.hako が正常実行
|
||||
- ユーザー定義Boxの完全サポート
|
||||
|
||||
------------------------------------------------------------
|
||||
@ -553,7 +553,7 @@ Scope/Tasks:
|
||||
- 起動時間・配布サイズ最適化
|
||||
|
||||
Acceptance Criteria:
|
||||
- `nyash --compile-native app.nyash -o app.exe` 動作
|
||||
- `nyash --compile-native app.hako -o app.exe` 動作
|
||||
- 起動時間大幅短縮(JIT起動コスト除去)
|
||||
- 配布可能実行ファイル生成
|
||||
|
||||
|
||||
@ -124,12 +124,12 @@ Scope:
|
||||
Tasks:
|
||||
- Cargo.toml: examples/GUI を feature でガード(default は CLI 最小)。
|
||||
- ビルド検証: `cargo build --bin nyash`(Linux/Windows)。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.nyash`。
|
||||
- 実行検証: `cargo run -- ./local_tests/sample.hako`。
|
||||
- ドキュメント: 上記手順を how-to-build-native に追記/点検。
|
||||
|
||||
Acceptance Criteria:
|
||||
- Linux/Windows で `cargo build --bin nyash` が成功する。
|
||||
- `local_tests/` 配下の簡単な .nyash が実行できる。
|
||||
- `local_tests/` 配下の簡単な .hako が実行できる。
|
||||
- 他 bin/examples が壊れていても `--bin nyash` だけで通る。
|
||||
|
||||
Out of Scope:
|
||||
@ -256,7 +256,7 @@ Summary:
|
||||
Scope/Tasks:
|
||||
- AST: BoxDeclaration(is_static=true, name=Main) を検出 → main() を抽出
|
||||
- Lowering: body を Program に変換して既存経路に渡す
|
||||
- Tests: local_tests/mir_loop_no_local.nyash で dump/VM が通る
|
||||
- Tests: local_tests/mir_loop_no_local.hako で dump/VM が通る
|
||||
|
||||
Acceptance Criteria:
|
||||
- `--dump-mir` が static Main サンプルで成功
|
||||
@ -350,7 +350,7 @@ Expected Duration: 1週間
|
||||
|
||||
### 成功基準
|
||||
- Phase 8.3のBox操作WASMが実際に動作
|
||||
- test_wasm_box_ops.nyash が正常実行
|
||||
- test_wasm_box_ops.hako が正常実行
|
||||
- ユーザー定義Boxの完全サポート
|
||||
|
||||
------------------------------------------------------------
|
||||
@ -555,7 +555,7 @@ Scope/Tasks:
|
||||
- 起動時間・配布サイズ最適化
|
||||
|
||||
Acceptance Criteria:
|
||||
- `nyash --compile-native app.nyash -o app.exe` 動作
|
||||
- `nyash --compile-native app.hako -o app.exe` 動作
|
||||
- 起動時間大幅短縮(JIT起動コスト除去)
|
||||
- 配布可能実行ファイル生成
|
||||
|
||||
@ -592,7 +592,7 @@ Summary:
|
||||
|
||||
1. **WASM/AOT コンパイルエラー(最重要)**
|
||||
```bash
|
||||
$ ./target/release/nyash --compile-wasm test_simple_loop.nyash
|
||||
$ ./target/release/nyash --compile-wasm test_simple_loop.hako
|
||||
❌ Unsupported instruction: Jump { target: BasicBlockId(1) }
|
||||
```
|
||||
**影響**: ループ・条件分岐を含む全プログラムがWASM/AOT化不可
|
||||
@ -623,7 +623,7 @@ Summary:
|
||||
- グレースフルシャットダウン
|
||||
|
||||
Acceptance Criteria:
|
||||
- ✅ `nyash --compile-wasm test_loop.nyash` 成功
|
||||
- ✅ `nyash --compile-wasm test_loop.hako` 成功
|
||||
- ✅ HTTPサーバー実動作(curl http://localhost:8080/)
|
||||
- ✅ unwrap()使用箇所: 26 → 5以下
|
||||
- ✅ WASM性能: 11.5倍 → 13.5倍達成
|
||||
|
||||
@ -27,7 +27,7 @@ nyash-macos (1.8MB) - 署名付き
|
||||
### **2. 開発者向け配布**
|
||||
```bash
|
||||
# LLVM IRの中立性を活用
|
||||
nyashc --emit-bitcode program.nyash
|
||||
nyashc --emit-bitcode program.hako
|
||||
# → program.bc (プラットフォーム中立)
|
||||
|
||||
# 各自のマシンで最適化コンパイル
|
||||
|
||||
@ -9,7 +9,7 @@ LLVM IRはプラットフォーム中立。だから**1回のIR生成から同
|
||||
|
||||
```rust
|
||||
// 革命的ワンパス・マルチターゲット生成
|
||||
nyashc --targets linux,windows,macos program.nyash
|
||||
nyashc --targets linux,windows,macos program.hako
|
||||
|
||||
// 出力(同時生成!)
|
||||
dist/x86_64-unknown-linux-musl/nyash # Linux版
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#### **即効性のある解決策(Week 1-3)**
|
||||
```bash
|
||||
# Linux + Windows同時生成
|
||||
nyashc --targets linux,windows-gnu program.nyash
|
||||
nyashc --targets linux,windows-gnu program.hako
|
||||
|
||||
# 出力
|
||||
dist/linux/nyash # Linux版(musl静的)
|
||||
|
||||
@ -14,7 +14,7 @@ Phase 9.78 LLVM PoCの第一歩として、inkwellクレートを導入し、最
|
||||
以下のNyashプログラムがLLVM経由で実行され、正しい終了コードを返すこと:
|
||||
|
||||
```nyash
|
||||
// test_return_42.nyash
|
||||
// test_return_42.hako
|
||||
static box Main {
|
||||
main() {
|
||||
return 42
|
||||
@ -24,7 +24,7 @@ static box Main {
|
||||
|
||||
期待される動作:
|
||||
```bash
|
||||
$ cargo run --features llvm -- --backend llvm test_return_42.nyash
|
||||
$ cargo run --features llvm -- --backend llvm test_return_42.hako
|
||||
$ echo $?
|
||||
42
|
||||
```
|
||||
|
||||
@ -29,7 +29,7 @@ Phase 9.78 LLVM PoCの開始です!最初のステップとして、inkwellク
|
||||
## 🎯 成功条件
|
||||
|
||||
```nyash
|
||||
// test_return_42.nyash
|
||||
// test_return_42.hako
|
||||
static box Main {
|
||||
main() {
|
||||
return 42
|
||||
@ -68,7 +68,7 @@ static box Main {
|
||||
## ✅ 完了条件
|
||||
|
||||
- [ ] inkwellがビルドできる
|
||||
- [ ] test_return_42.nyashがコンパイルできる
|
||||
- [ ] test_return_42.hakoがコンパイルできる
|
||||
- [ ] 実行ファイルが終了コード42を返す
|
||||
- [ ] 基本的なテストがパスする
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ cargo build --features llvm
|
||||
### 4. **テストプログラム作成**(5分)
|
||||
```bash
|
||||
# テスト用Nyashファイル
|
||||
cat > test_return_42.nyash << 'EOF'
|
||||
cat > test_return_42.hako << 'EOF'
|
||||
static box Main {
|
||||
main() {
|
||||
return 42
|
||||
|
||||
@ -70,7 +70,7 @@ fn load_builtin_plugins(&mut self) {
|
||||
|
||||
#### 2.2 テストプログラム
|
||||
```nyash
|
||||
// test_array_plugin.nyash
|
||||
// test_array_plugin.hako
|
||||
local arr
|
||||
arr = new ArrayBox() // プラグイン版を呼ぶ
|
||||
print(arr.length()) // 0が出力されれば成功
|
||||
@ -78,7 +78,7 @@ print(arr.length()) // 0が出力されれば成功
|
||||
|
||||
#### 2.3 VM実行
|
||||
```bash
|
||||
./target/release/nyash --backend vm test_array_plugin.nyash
|
||||
./target/release/nyash --backend vm test_array_plugin.hako
|
||||
```
|
||||
|
||||
### Step 3: JIT動作確認
|
||||
@ -97,7 +97,7 @@ match box_type {
|
||||
|
||||
#### 3.2 JIT実行テスト
|
||||
```bash
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm test_array_plugin.nyash
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm test_array_plugin.hako
|
||||
```
|
||||
|
||||
### Step 4: 段階的移行
|
||||
@ -123,7 +123,7 @@ if env::var("NYASH_USE_PLUGIN_BUILTINS").is_ok() {
|
||||
|
||||
#### 5.1 ベンチマーク作成
|
||||
```nyash
|
||||
// bench_array_ops.nyash
|
||||
// bench_array_ops.hako
|
||||
local arr = new ArrayBox()
|
||||
local start = Timer.now()
|
||||
loop(i in 0..1000000) {
|
||||
@ -136,10 +136,10 @@ print("Time: " + elapsed)
|
||||
#### 5.2 比較測定
|
||||
```bash
|
||||
# 従来版
|
||||
./target/release/nyash --benchmark bench_array_ops.nyash
|
||||
./target/release/nyash --benchmark bench_array_ops.hako
|
||||
|
||||
# プラグイン版
|
||||
NYASH_USE_PLUGIN_BUILTINS=1 ./target/release/nyash --benchmark bench_array_ops.nyash
|
||||
NYASH_USE_PLUGIN_BUILTINS=1 ./target/release/nyash --benchmark bench_array_ops.hako
|
||||
```
|
||||
|
||||
## 🎯 成功基準
|
||||
@ -169,10 +169,10 @@ NYASH_USE_PLUGIN_BUILTINS=1 ./target/release/nyash --benchmark bench_array_ops.n
|
||||
|
||||
```bash
|
||||
# プラグインロード確認
|
||||
NYASH_DEBUG_PLUGIN=1 ./target/release/nyash test.nyash
|
||||
NYASH_DEBUG_PLUGIN=1 ./target/release/nyash test.hako
|
||||
|
||||
# JIT呼び出し確認
|
||||
NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm test.nyash
|
||||
NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm test.hako
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@ -58,7 +58,7 @@ This plan refines how we leverage the existing plugin system (BID-FFI) to unify
|
||||
- Link scripts and `nyc build-aot` proof-of-concept.
|
||||
- Hello World-level standalone EXE on Linux/macOS.
|
||||
- DoD:
|
||||
- `nyc build-aot <file.nyash> -o app` runs without JIT/VM.
|
||||
- `nyc build-aot <file.hako> -o app` runs without JIT/VM.
|
||||
- Basic debug info and minimal unwind.
|
||||
|
||||
### 10.5: Python Integration (moved; separate phase)
|
||||
|
||||
@ -46,7 +46,7 @@ export NYASH_PLUGIN_OVERRIDE_TYPES="ArrayBox,MapBox,ConsoleBox,StringBox,Integer
|
||||
export NYASH_DISABLE_BUILTINS=1
|
||||
|
||||
cargo build --release --features cranelift-jit
|
||||
./target/release/nyash --backend vm examples/console_demo.nyash
|
||||
./target/release/nyash --backend vm examples/console_demo.hako
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
@ -440,7 +440,7 @@ pub fn register_builtin_boxes(env: &mut Environment) {
|
||||
|
||||
### 6. 使用例とテストケース
|
||||
```nyash
|
||||
// test_python_parser_phase1.nyash
|
||||
// test_python_parser_phase1.hako
|
||||
local py = new PythonParserBox()
|
||||
|
||||
// Phase 1: 基本的な関数定義と演算
|
||||
@ -513,7 +513,7 @@ export NYASH_PYTHONPARSER_TELEMETRY=2 # 詳細ログ
|
||||
export NYASH_PYTHONPARSER_STRICT=1 # フォールバック時にパニック
|
||||
|
||||
# 実行例
|
||||
./target/release/nyash test_python_parser.nyash
|
||||
./target/release/nyash test_python_parser.hako
|
||||
|
||||
# 出力
|
||||
[PythonParser] Module: test.py (Python 3.11)
|
||||
|
||||
@ -46,7 +46,7 @@ result = add(10, 5)
|
||||
## 🛠️ コマンドラインツール
|
||||
```bash
|
||||
# 基本変換
|
||||
nyash-transpile input.py -o output.nyash
|
||||
nyash-transpile input.py -o output.hako
|
||||
|
||||
# 変換統計付き
|
||||
nyash-transpile --stats complex.py
|
||||
|
||||
@ -21,7 +21,7 @@ for i in range(10):
|
||||
↓ 変換
|
||||
|
||||
```nyash
|
||||
# output.nyash
|
||||
# output.hako
|
||||
function calculate(x, y) {
|
||||
local result
|
||||
result = x * 2 + y
|
||||
@ -74,7 +74,7 @@ impl PythonParserBox {
|
||||
### コマンドライン版
|
||||
```bash
|
||||
# PythonファイルをNyashに変換
|
||||
nyash-transpile input.py -o output.nyash
|
||||
nyash-transpile input.py -o output.hako
|
||||
|
||||
# 標準出力に出力
|
||||
nyash-transpile script.py
|
||||
@ -94,7 +94,7 @@ local python_code = FileBox.read("algorithm.py")
|
||||
local nyash_code = transpiler.to_nyash_source(python_code)
|
||||
|
||||
// ファイルに保存
|
||||
FileBox.write("algorithm.nyash", nyash_code)
|
||||
FileBox.write("algorithm.hako", nyash_code)
|
||||
|
||||
// または直接実行
|
||||
eval(nyash_code)
|
||||
|
||||
@ -17,8 +17,8 @@ Python統合を本格化する前に、配布可能なネイティブ実行フ
|
||||
|
||||
## ✅ 成果(DoD)
|
||||
- `cargo build --release --features cranelift-jit` の後、
|
||||
- Linux: `./tools/build_aot.sh examples/aot_min_string_len.nyash -o app && ./app`
|
||||
- Windows: `powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input examples\aot_min_string_len.nyash -Out app.exe && .\app.exe`
|
||||
- Linux: `./tools/build_aot.sh examples/aot_min_string_len.hako -o app && ./app`
|
||||
- Windows: `powershell -ExecutionPolicy Bypass -File tools\build_aot.ps1 -Input examples\aot_min_string_len.hako -Out app.exe && .\app.exe`
|
||||
- プラグインは `.so` 記述でも各OSで自動解決(.dll/.dylib へ変換、lib剥がし)
|
||||
- `tools/smoke_aot_vs_vm.sh` で VM/EXE の `Result:` 行比較が可能(差異は警告表示)
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
|
||||
### 10.5d JIT/AOT 統合(3–5日)
|
||||
- AOTパイプライン固定: Lower→CLIF→OBJ出力→`ny_main`+`libnyrt.a`リンク→EXE
|
||||
- CLI: `nyash --compile-native file.nyash -o app` を追加(失敗は非ゼロ終了)
|
||||
- CLI: `nyash --compile-native file.hako -o app` を追加(失敗は非ゼロ終了)
|
||||
- libnyrt: `nyash.python.*` 等のシムを提供し、未解決シンボル解決
|
||||
- ディスパッチ: type_id→`nyplug_*_invoke` の静的/動的ルート(第一段は動的優先)
|
||||
|
||||
@ -79,8 +79,8 @@
|
||||
- ドキュメント: 使用例、制約(GIL/スレッド)、AOT時のリンク・ランタイム要件
|
||||
|
||||
追加済みサンプル(最小チェーン)
|
||||
- VM: `examples/py_min_chain_vm.nyash`(import→getattr→call→println)
|
||||
- AOT: `examples/aot_py_min_chain.nyash`(import→getattr→call→return)
|
||||
- VM: `examples/py_min_chain_vm.hako`(import→getattr→call→println)
|
||||
- AOT: `examples/aot_py_min_chain.hako`(import→getattr→call→return)
|
||||
|
||||
## 🎯 DoD(定義)
|
||||
- NyashからPythonコードを評価し、PyObjectをHandleで往復できる
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
1) 到達イメージ(DoD)
|
||||
====================
|
||||
- Linux/Windows で以下が安定動作:
|
||||
- AOT: `examples/aot_py_min_chain.nyash` → `Result: 4`(math.sqrt(16))
|
||||
- VM: `examples/py_min_chain_vm.nyash` → 4.0 表示(NYASH_PY_AUTODECODE=1)
|
||||
- AOT: `examples/aot_py_min_chain.hako` → `Result: 4`(math.sqrt(16))
|
||||
- VM: `examples/py_min_chain_vm.hako` → 4.0 表示(NYASH_PY_AUTODECODE=1)
|
||||
- returns_result 系サンプル(importR/getattrR/callR)で Ok/Err が期待通りに表示
|
||||
- AOTビルドの配布体験が明確:
|
||||
- `tools/build_aot.{sh,ps1}` で .o → EXE、`nyash.toml`/plugins 解決、Windowsでは PATH/PYTHONHOME 調整
|
||||
@ -66,7 +66,7 @@ M5: 観測/CI(軽量)
|
||||
====================
|
||||
6) 成果物(Artifacts)
|
||||
====================
|
||||
- 例: `examples/aot_py_min_chain.nyash`, `examples/py_min_chain_vm.nyash`(既存)
|
||||
- 例: `examples/aot_py_min_chain.hako`, `examples/py_min_chain_vm.hako`(既存)
|
||||
- ツール: `tools/build_aot.{sh,ps1}`(Python節)、`tools/smoke_aot_vs_vm.sh`(Python最小)
|
||||
- Docs: `docs/guides/build/aot_quickstart.md`(Python節)、`docs/reference/abi/ffi_calling_convention_min.md`(bytes/N引数注記)
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
### 使用例1: 基本的な関数のネイティブ化
|
||||
|
||||
```nyash
|
||||
// example1_basic.nyash
|
||||
// example1_basic.hako
|
||||
// Pythonコードをネイティブコンパイル
|
||||
|
||||
// Step 1: Pythonコードを用意
|
||||
@ -51,7 +51,7 @@ if mir_module.isOk() {
|
||||
### 使用例2: コンパイル可否の明確な判定
|
||||
|
||||
```nyash
|
||||
// example2_clear_separation.nyash
|
||||
// example2_clear_separation.hako
|
||||
// コンパイルできるかどうか事前に判定
|
||||
|
||||
// Phase 1対応のコード
|
||||
@ -107,7 +107,7 @@ if result2.isOk() {
|
||||
### 使用例3: プログレッシブ最適化
|
||||
|
||||
```nyash
|
||||
// example3_progressive.nyash
|
||||
// example3_progressive.hako
|
||||
// 実行しながら徐々に最適化
|
||||
|
||||
// 型推論付きコンパイラー
|
||||
@ -153,7 +153,7 @@ for i in range(5) {
|
||||
### 使用例4: 言語間相互運用
|
||||
|
||||
```nyash
|
||||
// example4_interop.nyash
|
||||
// example4_interop.hako
|
||||
// PythonコードとNyashコードのシームレスな連携
|
||||
|
||||
// Pythonで数値計算関数を定義
|
||||
@ -198,7 +198,7 @@ box GameObject {
|
||||
### 使用例5: デバッグとプロファイリング
|
||||
|
||||
```nyash
|
||||
// example5_debug.nyash
|
||||
// example5_debug.hako
|
||||
// 開発時のデバッグ支援
|
||||
|
||||
// デバッグモード有効
|
||||
|
||||
@ -59,7 +59,7 @@ fn test_compile_arithmetic() {
|
||||
### 2. Differential Testing Framework
|
||||
|
||||
```nyash
|
||||
// tests/differential/framework.nyash
|
||||
// tests/differential/framework.hako
|
||||
box DifferentialTester {
|
||||
init { oracle, implementation, results }
|
||||
|
||||
@ -145,7 +145,7 @@ def test_arithmetic_properties(x, y):
|
||||
### 4. ベンチマークスイート
|
||||
|
||||
```nyash
|
||||
// benchmarks/numeric_suite.nyash
|
||||
// benchmarks/numeric_suite.hako
|
||||
box NumericBenchmark {
|
||||
run() {
|
||||
local suite = new BenchmarkSuite()
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
5) ベンチと回帰(最小)
|
||||
- 目標: ラインの性能/退行の早期検知
|
||||
- タスク:
|
||||
- ny_bench.nyash のケース整理(関数呼出/Map set-get/branch)
|
||||
- ny_bench.hako のケース整理(関数呼出/Map set-get/branch)
|
||||
- compare: VM vs JIT(ウォームアップ付き)
|
||||
- 受入: ベンチ出力に JIT/VM の比較が出る(改善/退行が見える)
|
||||
|
||||
@ -71,15 +71,15 @@
|
||||
```bash
|
||||
# math.min(関数スタイル)
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_math_function_style_min_float.nyash
|
||||
./target/release/nyash --backend vm examples/jit_math_function_style_min_float.hako
|
||||
|
||||
# Map.get HH直実行
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_map_get_param_hh.nyash
|
||||
./target/release/nyash --backend vm examples/jit_map_get_param_hh.hako
|
||||
|
||||
# Mutating opt-in(Array.push)
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_policy_optin_mutating.nyash
|
||||
./target/release/nyash --backend vm examples/jit_policy_optin_mutating.hako
|
||||
|
||||
## 例とスモーク(開発者向けクイック)
|
||||
- 例一覧: `examples/README.md`(HH直実行・mutating opt-in・GCデモ)
|
||||
|
||||
@ -11,7 +11,7 @@ How-To (Local)
|
||||
(env)
|
||||
set NYASH_GC_BARRIER_STRICT=1
|
||||
set NYASH_GC_TRACE=1
|
||||
nyash <program.nyash>
|
||||
nyash <program.hako>
|
||||
|
||||
Expected
|
||||
- Barrier sites log to stderr.
|
||||
|
||||
@ -25,7 +25,7 @@ Deliverables
|
||||
- Lowering updates: Branch/Jump hook uses real block IDs; Compare emits b1-friendly shape.
|
||||
- Env flags: Reuse `NYASH_JIT_EXEC/THRESHOLD/STATS/DUMP`; guard hostcalls by `NYASH_JIT_HOSTCALL`.
|
||||
- Docs: Update execution-backends.md with “JIT control-flow coverage (10.7)”.
|
||||
- Examples: `examples/jit_branch_demo.nyash` (if/loop minimal).
|
||||
- Examples: `examples/jit_branch_demo.hako` (if/loop minimal).
|
||||
|
||||
Design Sketch
|
||||
1) Block Mapping
|
||||
@ -59,13 +59,13 @@ Implementation Plan (Tasks)
|
||||
- For Branch/Jump, call builder with mapped blocks and condition value hint.
|
||||
- Compare: emit b1 icmp; when Compare is used as value elsewhere, allow i64 extend as needed.
|
||||
- T4: Minimal PHI support for a single merge (optional; guarded by env `NYASH_JIT_PHI_MIN=1`).
|
||||
- T5: Add `examples/jit_branch_demo.nyash` with: `if (a < b) { return 1 } else { return 2 }` and a small loop with early `return`.
|
||||
- T5: Add `examples/jit_branch_demo.hako` with: `if (a < b) { return 1 } else { return 2 }` and a small loop with early `return`.
|
||||
- T6: Docs update: execution-backends.md “JIT coverage 10.7” + env flags.
|
||||
- T7: Bench (optional): integrate into `--benchmark` with JIT warmup when `NYASH_JIT_EXEC=1`.
|
||||
|
||||
Validation
|
||||
- Build matrix: with/without `cranelift-jit` feature.
|
||||
- Smoke tests: run `jit_branch_demo.nyash` with `NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1`.
|
||||
- Smoke tests: run `jit_branch_demo.hako` with `NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1`.
|
||||
- Fallback verification: force a path with unsupported op to confirm VM fallback.
|
||||
- GC/scheduler: ensure safepoint path still works (unchanged).
|
||||
|
||||
|
||||
@ -14,10 +14,10 @@ Flags and CLI (common across 10.7)
|
||||
- CLI: --jit-exec --jit-stats --jit-stats-json --jit-dump --jit-threshold N --jit-phi-min --jit-hostcall
|
||||
|
||||
Examples to validate
|
||||
- examples/jit_branch_demo.nyash
|
||||
- examples/jit_loop_early_return.nyash
|
||||
- examples/jit_phi_demo.nyash
|
||||
- examples/jit_array_param_call.nyash, jit_map_param_call.nyash (when hostcall is enabled)
|
||||
- examples/jit_branch_demo.hako
|
||||
- examples/jit_loop_early_return.hako
|
||||
- examples/jit_phi_demo.hako
|
||||
- examples/jit_array_param_call.hako, jit_map_param_call.hako (when hostcall is enabled)
|
||||
|
||||
Sub-phases (10.7a → 10.7h)
|
||||
|
||||
|
||||
@ -42,9 +42,9 @@ Non-Goals (later 10.7b+)
|
||||
|
||||
Deliverables
|
||||
- Working minimal PHI + branch JIT execution on curated examples:
|
||||
- examples/jit_branch_demo.nyash
|
||||
- examples/jit_loop_early_return.nyash
|
||||
- examples/jit_phi_demo.nyash (single-PHI diamond)
|
||||
- examples/jit_branch_demo.hako
|
||||
- examples/jit_loop_early_return.hako
|
||||
- examples/jit_phi_demo.hako (single-PHI diamond)
|
||||
- Fallback correctness: traps/panic → VM path; results match VM
|
||||
- Configurable via CLI flags; metrics visible via JIT summary/JSON
|
||||
|
||||
|
||||
@ -67,11 +67,11 @@
|
||||
- `NYASH_JIT_EVENTS=1`(標準出力へJSON)
|
||||
- 任意: `NYASH_JIT_EVENTS_PATH=target/nyash/jit-events.jsonl`
|
||||
- 代表サンプル(VM経由でJITパス通過)
|
||||
- 成功: `./target/release/nyash --backend vm examples/jit_hostcall_len_string.nyash`
|
||||
- 失敗: `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_array_append.nyash`
|
||||
- 境界: `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_mismatch.nyash`
|
||||
- 署名一致(allow観測): `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_allow_float.nyash`
|
||||
- 関数スタイル(math.*): `NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_math_function_style_sin_float.nyash`
|
||||
- 成功: `./target/release/nyash --backend vm examples/jit_hostcall_len_string.hako`
|
||||
- 失敗: `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_array_append.hako`
|
||||
- 境界: `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_mismatch.hako`
|
||||
- 署名一致(allow観測): `NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_hostcall_math_sin_allow_float.hako`
|
||||
- 関数スタイル(math.*): `NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 ./target/release/nyash --backend vm examples/jit_math_function_style_sin_float.hako`
|
||||
- `cos/abs/min/max` も同様のサンプルあり
|
||||
- 詰まったら
|
||||
- `--features cranelift-jit` が付いているか
|
||||
@ -98,15 +98,15 @@
|
||||
```bash
|
||||
# math.*(関数スタイル): 署名一致でallow、戻りFloat表示
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_NATIVE_F64=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_math_function_style_min_float.nyash
|
||||
./target/release/nyash --backend vm examples/jit_math_function_style_min_float.hako
|
||||
|
||||
# Map.get(パラメータ受け+Handleキー → HH直実行)
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_map_get_param_hh.nyash
|
||||
./target/release/nyash --backend vm examples/jit_map_get_param_hh.hako
|
||||
|
||||
# Map.get(非パラメータ受け → fallback記録)
|
||||
NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EVENTS=1 \
|
||||
./target/release/nyash --backend vm examples/jit_hostcall_map_get_handle.nyash
|
||||
./target/release/nyash --backend vm examples/jit_hostcall_map_get_handle.hako
|
||||
```
|
||||
|
||||
### ⚙️ Quick flags(イベント観測を確実に)
|
||||
|
||||
@ -104,9 +104,9 @@ Status(2025-08-27)
|
||||
```bash
|
||||
cargo build --features cranelift-jit --release
|
||||
NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EXEC=1 \
|
||||
./target/release/nyash --backend vm examples/jit_array_param_call.nyash
|
||||
./target/release/nyash --backend vm examples/jit_array_param_call.hako
|
||||
NYASH_JIT_THRESHOLD=1 NYASH_JIT_HOSTCALL=1 NYASH_JIT_EXEC=1 \
|
||||
./target/release/nyash --backend vm examples/jit_map_param_call.nyash
|
||||
./target/release/nyash --backend vm examples/jit_map_param_call.hako
|
||||
```
|
||||
Notes
|
||||
- 関数パラメータに渡した配列/MapのみHostCall経由でアクセス(thread-local引数参照)
|
||||
@ -238,12 +238,12 @@ JIT実装(10_a~10_h)で構築したMIR→CLIF変換基盤をそのまま
|
||||
### 使用イメージ
|
||||
```bash
|
||||
# ネイティブ実行ファイル生成
|
||||
./target/release/nyash --compile-native program.nyash -o program
|
||||
./target/release/nyash --compile-native program.hako -o program
|
||||
./program # スタンドアロン実行!
|
||||
|
||||
# クロスコンパイル
|
||||
./target/release/nyash --compile-native --target x86_64-pc-windows-msvc program.nyash -o program.exe
|
||||
./target/release/nyash --compile-native --target aarch64-apple-darwin program.nyash -o program.mac
|
||||
./target/release/nyash --compile-native --target x86_64-pc-windows-msvc program.hako -o program.exe
|
||||
./target/release/nyash --compile-native --target aarch64-apple-darwin program.hako -o program.mac
|
||||
```
|
||||
|
||||
### 技術的詳細
|
||||
|
||||
@ -210,10 +210,10 @@ function sumStringLengths(strings) {
|
||||
### 2. プロファイリング
|
||||
```bash
|
||||
# Mutexプロファイル
|
||||
NYASH_PROFILE_LOCKS=1 ./target/release/nyash bench.nyash
|
||||
NYASH_PROFILE_LOCKS=1 ./target/release/nyash bench.hako
|
||||
|
||||
# Atomic最適化後
|
||||
NYASH_ATOMIC_OPT=1 ./target/release/nyash bench.nyash
|
||||
NYASH_ATOMIC_OPT=1 ./target/release/nyash bench.hako
|
||||
```
|
||||
|
||||
## 🚧 実装上の注意点
|
||||
|
||||
@ -265,10 +265,10 @@ async function fetchAll(urls) {
|
||||
### 2. ベンチマーク
|
||||
```bash
|
||||
# 10000並行リクエスト
|
||||
./target/release/nyash bench/async_stress.nyash
|
||||
./target/release/nyash bench/async_stress.hako
|
||||
|
||||
# メモリプロファイル
|
||||
NYASH_COROUTINE_STATS=1 ./target/release/nyash bench/async_memory.nyash
|
||||
NYASH_COROUTINE_STATS=1 ./target/release/nyash bench/async_memory.hako
|
||||
```
|
||||
|
||||
## 🚧 実装上の注意点
|
||||
|
||||
@ -10,7 +10,7 @@ Phase 11.5完了を待たずに、**今すぐ作れる**実用アプリ5本で
|
||||
**目的**: I/O・StringBoxの道通し確認
|
||||
|
||||
```nyash
|
||||
// apps/ny-echo/main.nyash
|
||||
// apps/ny-echo/main.hako
|
||||
static box Main {
|
||||
main(args) {
|
||||
local console = new ConsoleBox()
|
||||
@ -42,7 +42,7 @@ static box Main {
|
||||
**目的**: PyRuntimeBox/PyObjectBox経由のPluginInvoke検証
|
||||
|
||||
```nyash
|
||||
// apps/ny-jsonlint/main.nyash
|
||||
// apps/ny-jsonlint/main.hako
|
||||
static box Main {
|
||||
init { py, console }
|
||||
|
||||
@ -85,7 +85,7 @@ except Exception as e:
|
||||
**目的**: ArrayBox map/reduce、StatsBox導入、性能可視化
|
||||
|
||||
```nyash
|
||||
// apps/ny-array-bench/main.nyash
|
||||
// apps/ny-array-bench/main.hako
|
||||
static box Main {
|
||||
init { stats }
|
||||
|
||||
@ -139,7 +139,7 @@ static box Main {
|
||||
**目的**: BytesBox/FileBox(プラグイン)I/O、実用的なツール
|
||||
|
||||
```nyash
|
||||
// apps/ny-filegrep/main.nyash
|
||||
// apps/ny-filegrep/main.hako
|
||||
static box Main {
|
||||
init { pattern, recursive, results }
|
||||
|
||||
@ -202,7 +202,7 @@ static box Main {
|
||||
**目的**: NetBox(プラグイン)とイベントループ、FutureBox活用
|
||||
|
||||
```nyash
|
||||
// apps/ny-http-hello/main.nyash
|
||||
// apps/ny-http-hello/main.hako
|
||||
static box Main {
|
||||
init { server, running }
|
||||
|
||||
@ -292,7 +292,7 @@ nyash-apps-v1.0/
|
||||
│ ├── ny-filegrep[.exe]
|
||||
│ └── ny-http-hello[.exe]
|
||||
├── examples/
|
||||
│ └── *.nyash (ソースコード)
|
||||
│ └── *.hako (ソースコード)
|
||||
├── benchmarks/
|
||||
│ └── results.json
|
||||
└── README.md
|
||||
|
||||
@ -152,7 +152,7 @@ mod migration_tests {
|
||||
|
||||
#[test]
|
||||
fn test_unified_vs_legacy_semantics() {
|
||||
let test_cases = load_test_cases("tests/semantics/*.nyash");
|
||||
let test_cases = load_test_cases("tests/semantics/*.hako");
|
||||
|
||||
for case in test_cases {
|
||||
let legacy_result = legacy_interpreter.execute(&case);
|
||||
|
||||
@ -9,8 +9,8 @@ MIR→LLVM IR直接変換による最高性能AOT実現。Cranelift JITをスキ
|
||||
## 🎯 実装目標
|
||||
```bash
|
||||
# Phase 9基盤の拡張
|
||||
nyash --compile-llvm app.nyash -o app # LLVM AOT実行ファイル生成
|
||||
nyash --optimize app.nyash -o app # 最適化AOT(LTO・PGO)
|
||||
nyash --compile-llvm app.hako -o app # LLVM AOT実行ファイル生成
|
||||
nyash --optimize app.hako -o app # 最適化AOT(LTO・PGO)
|
||||
./app # 最高性能実行
|
||||
|
||||
# 内部実装パイプライン
|
||||
|
||||
@ -12,7 +12,7 @@ Last Updated: 2025-08-25
|
||||
- ExternCall命令(Phase 9.7)導入予定。ABIは`docs/予定/native-plan/box_ffi_abi.md`に準拠。
|
||||
|
||||
アウトカム(受け入れ基準)
|
||||
- CLI: `nyash --backend llvm --emit obj app.nyash -o app.o` が成功し、`clang app.o -o app` で実行可能。
|
||||
- CLI: `nyash --backend llvm --emit obj app.hako -o app.o` が成功し、`clang app.o -o app` で実行可能。
|
||||
- 代表サンプルで `main` が `i32` を返却(0=成功)。
|
||||
- `ExternCall(env.console.log)` を `printf` 等へ写像し、標準出力へ表示できる(文字列は (i8*, i32))。
|
||||
- 単純な四則演算・比較・分岐・ループが LLVM AOT で動作。
|
||||
|
||||
@ -146,7 +146,7 @@ impl OptPass for DeadCodeElimPass {
|
||||
|
||||
```bash
|
||||
# MIRからCへ変換
|
||||
nyash --emit-c program.nyash -o program.c
|
||||
nyash --emit-c program.hako -o program.c
|
||||
|
||||
# 最適化コンパイル
|
||||
zig cc -O3 -flto -march=native \
|
||||
@ -178,7 +178,7 @@ zig cc -O3 -fprofile-use program.c -o program_opt
|
||||
## 5. 性能測定の例
|
||||
|
||||
```nyash
|
||||
// benchmark.nyash
|
||||
// benchmark.hako
|
||||
static box Benchmark {
|
||||
main() {
|
||||
local start, end, result
|
||||
|
||||
@ -89,27 +89,27 @@ Branch(cond, then, else) → {likely: Some(true)} // thenが高確率
|
||||
Level 0: 開発モード
|
||||
- MIR最適化なし
|
||||
- デバッグ情報完全保持
|
||||
- nyash program.nyash
|
||||
- nyash program.hako
|
||||
|
||||
Level 1: 基本最適化(デフォルト)
|
||||
- MIRカノニカル化のみ
|
||||
- Cエミッタ → gcc -O2
|
||||
- nyash --release program.nyash
|
||||
- nyash --release program.hako
|
||||
|
||||
Level 2: 高速化
|
||||
- MIR全最適化パス
|
||||
- Cエミッタ → zig cc -O3 -flto
|
||||
- nyash --release --opt program.nyash
|
||||
- nyash --release --opt program.hako
|
||||
|
||||
Level 3: プロファイルガイド(PGO)
|
||||
- 実行プロファイル収集
|
||||
- ホットパス特定
|
||||
- nyash --release --pgo program.nyash
|
||||
- nyash --release --pgo program.hako
|
||||
|
||||
Level 4: 特殊用途
|
||||
- SIMD必要 → LLVM使用(ただし依存が重い)
|
||||
- 起動速度重視 → Cranelift JIT(推奨)
|
||||
- nyash --backend cranelift program.nyash
|
||||
- nyash --backend cranelift program.hako
|
||||
|
||||
================================================================================
|
||||
5. 実装計画
|
||||
|
||||
@ -231,9 +231,9 @@ override → O # オーバーライド
|
||||
**すべての糖衣構文は双方向変換可能:**
|
||||
```bash
|
||||
# フォーマッターによる自由な変換
|
||||
nyash format --style=explicit code.nyash # 明示的記法へ
|
||||
nyash format --style=sugar code.nyash # 糖衣構文へ
|
||||
nyash format --style=ancp code.nyash # 極限圧縮へ
|
||||
nyash format --style=explicit code.hako # 明示的記法へ
|
||||
nyash format --style=sugar code.hako # 糖衣構文へ
|
||||
nyash format --style=ancp code.hako # 極限圧縮へ
|
||||
```
|
||||
|
||||
**同じコードの3つの表現:**
|
||||
|
||||
@ -54,9 +54,9 @@ onHover(position) {
|
||||
### Phase 2: 実用化(2週間目)
|
||||
1. **CLI実装**(Codex提案)
|
||||
```bash
|
||||
ancp encode --layer F input.nyash -o output.f
|
||||
ancp encode --layer F input.hako -o output.f
|
||||
ancp decode output.f --map output.map
|
||||
ancp verify input.nyash output.f # MIR等価性チェック
|
||||
ancp verify input.hako output.f # MIR等価性チェック
|
||||
```
|
||||
|
||||
2. **プロジェクト辞書**(Gemini提案)
|
||||
|
||||
@ -102,7 +102,7 @@ esac
|
||||
|
||||
### Test 1: 最小Box
|
||||
```nyash
|
||||
# input.nyash
|
||||
# input.hako
|
||||
box Test {
|
||||
init { value }
|
||||
}
|
||||
@ -113,7 +113,7 @@ $Test{#{value}}
|
||||
|
||||
### Test 2: 簡単な関数
|
||||
```nyash
|
||||
# input.nyash
|
||||
# input.hako
|
||||
box Calculator {
|
||||
add(a, b) {
|
||||
return a + b
|
||||
|
||||
@ -252,22 +252,22 @@ peek ast {
|
||||
### ステップ1: 標準コードを書く
|
||||
```bash
|
||||
# 通常のNyashで開発
|
||||
vim src/feature.nyash
|
||||
vim src/feature.hako
|
||||
```
|
||||
|
||||
### ステップ2: 段階的圧縮
|
||||
```bash
|
||||
# L1: 糖衣構文適用
|
||||
nyashfmt --sugar src/feature.nyash > feature.sugar.nyash
|
||||
nyashfmt --sugar src/feature.hako > feature.sugar.hako
|
||||
|
||||
# L2: ANCP変換
|
||||
nyash2ancp feature.sugar.nyash > feature.ancp
|
||||
nyash2ancp feature.sugar.hako > feature.ancp
|
||||
|
||||
# L3: 極限糖衣
|
||||
nyashfmt --ultra feature.ancp > feature.ultra.nyash
|
||||
nyashfmt --ultra feature.ancp > feature.ultra.hako
|
||||
|
||||
# L4: 最大圧縮
|
||||
nyash2fusion feature.ultra.nyash > feature.fusion
|
||||
nyash2fusion feature.ultra.hako > feature.fusion
|
||||
```
|
||||
|
||||
### ステップ3: AIとの対話
|
||||
@ -284,10 +284,10 @@ cat *.fusion | clip
|
||||
### ステップ4: 可逆展開
|
||||
```bash
|
||||
# AIの応答を展開
|
||||
fusion2nyash --level=0 ai_response.fusion > fixed.nyash
|
||||
fusion2nyash --level=0 ai_response.fusion > fixed.hako
|
||||
|
||||
# 差分確認
|
||||
diff src/feature.nyash fixed.nyash
|
||||
diff src/feature.hako fixed.hako
|
||||
```
|
||||
|
||||
## 🛠️ ツールチェーン
|
||||
|
||||
@ -251,9 +251,9 @@ r=d\:_.isValid()/:_|>n|>t
|
||||
### 可逆変換の保証
|
||||
```bash
|
||||
# どの形式からでも相互変換可能
|
||||
nyash format --from=explicit --to=sugar code.nyash
|
||||
nyash format --from=sugar --to=ancp code.nyash
|
||||
nyash format --from=ancp --to=explicit code.nyash
|
||||
nyash format --from=explicit --to=sugar code.hako
|
||||
nyash format --from=sugar --to=ancp code.hako
|
||||
nyash format --from=ancp --to=explicit code.hako
|
||||
```
|
||||
|
||||
## 🚀 Phase 15との相乗効果
|
||||
|
||||
@ -178,7 +178,7 @@ result"
|
||||
5. 使用例:コマンドラインツール
|
||||
================================================================================
|
||||
|
||||
// nyashfmt.nyash - フォーマッターCLI
|
||||
// nyashfmt.hako - フォーマッターCLI
|
||||
static box Main {
|
||||
main(args) {
|
||||
local formatter = new NyashFormatter()
|
||||
@ -285,7 +285,7 @@ box LearningMode {
|
||||
8. 設定ファイル
|
||||
================================================================================
|
||||
|
||||
// .nyashfmt.json - プロジェクト別設定
|
||||
// .hakofmt.json - プロジェクト別設定
|
||||
{
|
||||
"mode": "standard",
|
||||
"rules": {
|
||||
|
||||
@ -156,7 +156,7 @@ impl SourceMap {
|
||||
// ANCP位置 → Nyash位置への変換
|
||||
self.mappings
|
||||
.binary_search_by_key(&ancp_pos, |m| m.ancp_pos)
|
||||
.map(|i| self.mappings[i].nyash_pos)
|
||||
.map(|i| self.mappings[i].hako_pos)
|
||||
.unwrap_or(ancp_pos)
|
||||
}
|
||||
}
|
||||
@ -214,7 +214,7 @@ expected_pattern=$2
|
||||
normal_output=$(./target/release/nyash "$test_file" 2>&1)
|
||||
|
||||
# 2. ANCP変換
|
||||
ancp_file="${test_file%.nyash}.ancp"
|
||||
ancp_file="${test_file%.hako}.ancp"
|
||||
./target/release/nyash2ancp -i "$test_file" -o "$ancp_file"
|
||||
|
||||
# 3. ANCP実行
|
||||
@ -289,8 +289,8 @@ def measure_file(nyash_path, ancp_path):
|
||||
|
||||
# 全サンプルファイルで測定
|
||||
results = []
|
||||
for nyash_file in glob.glob("examples/*.nyash"):
|
||||
ancp_file = nyash_file.replace(".nyash", ".ancp")
|
||||
for nyash_file in glob.glob("examples/*.hako"):
|
||||
ancp_file = nyash_file.replace(".hako", ".ancp")
|
||||
results.append(measure_file(nyash_file, ancp_file))
|
||||
|
||||
# 統計出力
|
||||
@ -316,7 +316,7 @@ jobs:
|
||||
|
||||
- name: Run roundtrip tests
|
||||
run: |
|
||||
for f in examples/*.nyash; do
|
||||
for f in examples/*.hako; do
|
||||
echo "Testing: $f"
|
||||
./tools/test_ancp_roundtrip.sh "$f"
|
||||
done
|
||||
|
||||
@ -161,14 +161,14 @@ impl Lexer {
|
||||
### 5.2 CLI統合
|
||||
```bash
|
||||
# 変換コマンド
|
||||
nyash --to-ancp input.nyash > output.ancp
|
||||
nyash --from-ancp input.ancp > output.nyash
|
||||
nyash --to-ancp input.hako > output.ancp
|
||||
nyash --from-ancp input.ancp > output.hako
|
||||
|
||||
# 直接実行
|
||||
nyash --dialect=ancp script.ancp
|
||||
|
||||
# フォーマット表示
|
||||
nyash --view=ancp script.nyash # Nyashファイルをancp形式で表示
|
||||
nyash --view=ancp script.hako # Nyashファイルをancp形式で表示
|
||||
nyash --view=hybrid script.ancp # 並列表示
|
||||
```
|
||||
|
||||
@ -209,7 +209,7 @@ fn roundtrip_all_constructs() {
|
||||
"loop(i < 10) { i = i + 1 }",
|
||||
|
||||
// 複雑な例
|
||||
include_str!("../examples/complex.nyash"),
|
||||
include_str!("../examples/complex.hako"),
|
||||
];
|
||||
|
||||
for case in test_cases {
|
||||
|
||||
@ -198,7 +198,7 @@ Expected 'token' but found 'actual'
|
||||
【エラーメッセージ例】
|
||||
```
|
||||
Error: Missing 'else' in peek expression
|
||||
--> program.nyash:10:5
|
||||
--> program.hako:10:5
|
||||
|
|
||||
10 | peek value {
|
||||
| ^^^^ peek expression requires 'else' branch
|
||||
|
||||
@ -167,7 +167,7 @@ if animal == "dog" {
|
||||
================================================================================
|
||||
|
||||
```nyash
|
||||
// test_peek_basic.nyash
|
||||
// test_peek_basic.hako
|
||||
local animal = "cat"
|
||||
local sound = peek animal {
|
||||
"dog" => "woof"
|
||||
@ -176,7 +176,7 @@ local sound = peek animal {
|
||||
}
|
||||
print(sound) // "meow"
|
||||
|
||||
// test_peek_block.nyash
|
||||
// test_peek_block.hako
|
||||
local result = peek x {
|
||||
1 => {
|
||||
local temp = "one"
|
||||
@ -185,7 +185,7 @@ local result = peek x {
|
||||
else => "other"
|
||||
}
|
||||
|
||||
// test_continue.nyash
|
||||
// test_continue.hako
|
||||
local i = 0
|
||||
local sum = 0
|
||||
loop(i < 5) {
|
||||
@ -197,7 +197,7 @@ loop(i < 5) {
|
||||
}
|
||||
print(sum) // 12 (1+2+4+5, 3はスキップ)
|
||||
|
||||
// test_field_declaration.nyash
|
||||
// test_field_declaration.hako
|
||||
box Point {
|
||||
public x: IntegerBox
|
||||
public y: IntegerBox
|
||||
|
||||
@ -134,7 +134,7 @@ processor.process(3.14) # すべてプラグインで動作!
|
||||
|
||||
```
|
||||
Nyashエコシステム(統一TypeBox ABI採用後):
|
||||
├── Nyashスクリプトプラグイン ← .nyashファイル(純粋なNyashコード)
|
||||
├── Nyashスクリプトプラグイン ← .hakoファイル(純粋なNyashコード)
|
||||
└── 統一TypeBoxプラグイン ← .so/.dll(ネイティブ実装)
|
||||
├── 基本機能(旧C ABI互換)
|
||||
├── 高速ディスパッチ(JIT最適化)
|
||||
|
||||
@ -195,7 +195,7 @@ tests/abi/
|
||||
|
||||
### nyash.toml設定
|
||||
```toml
|
||||
[plugins.nyash_abi_provider]
|
||||
[plugins.hako_abi_provider]
|
||||
path = "plugins/nyash_abi_provider.so"
|
||||
abi = "c"
|
||||
types = ["NyashABIProvider"]
|
||||
|
||||
@ -54,10 +54,10 @@ AIの頭の中:
|
||||
|
||||
```bash
|
||||
# スクリプトファイルをAOTコンパイル可能
|
||||
./nyash --aot script.nyash -o script.exe
|
||||
./nyash --aot script.hako -o script.exe
|
||||
|
||||
# JITで実行(ホットコードを自動最適化)
|
||||
./nyash --backend vm --jit script.nyash
|
||||
./nyash --backend vm --jit script.hako
|
||||
```
|
||||
|
||||
つまり:
|
||||
|
||||
@ -29,7 +29,7 @@ Nyashスクリプトプラグインは、**最もNyashらしいプラグイン
|
||||
### 1. シンプルなユーティリティBox
|
||||
|
||||
```nyash
|
||||
# math_utils.nyash - 数学ユーティリティプラグイン
|
||||
# math_utils.hako - 数学ユーティリティプラグイン
|
||||
|
||||
box MathUtils {
|
||||
init { }
|
||||
@ -66,7 +66,7 @@ box MathUtils {
|
||||
### 2. 他のプラグインと組み合わせる例
|
||||
|
||||
```nyash
|
||||
# data_processor.nyash - データ処理プラグイン
|
||||
# data_processor.hako - データ処理プラグイン
|
||||
|
||||
box DataProcessor {
|
||||
init { file, math, cache }
|
||||
@ -109,7 +109,7 @@ box DataProcessor {
|
||||
### 3. 高度なプラグイン - P2Pノード拡張
|
||||
|
||||
```nyash
|
||||
# mesh_node.nyash - P2Pメッシュネットワークノード
|
||||
# mesh_node.hako - P2Pメッシュネットワークノード
|
||||
|
||||
box MeshNode from P2PBox {
|
||||
init { routing, peers, messageHandlers }
|
||||
@ -181,8 +181,8 @@ box MeshNode from P2PBox {
|
||||
### 1. ローカルファイルとして
|
||||
|
||||
```nyash
|
||||
# main.nyash
|
||||
include "plugins/math_utils.nyash"
|
||||
# main.hako
|
||||
include "plugins/math_utils.hako"
|
||||
|
||||
local utils = new MathUtils()
|
||||
print(utils.factorial(5)) # 120
|
||||
@ -209,7 +209,7 @@ local utils = new MathUtils()
|
||||
|
||||
```nyash
|
||||
# 実行時にプラグインをロード
|
||||
local pluginCode = new FileBox().read("plugin.nyash")
|
||||
local pluginCode = new FileBox().read("plugin.hako")
|
||||
eval(pluginCode) # プラグインが利用可能に
|
||||
|
||||
local processor = new DataProcessor()
|
||||
@ -270,7 +270,7 @@ box SafeCalculator {
|
||||
| パフォーマンス | 中速 | 最速 | 高速 |
|
||||
| 開発効率 | 最高 | 中 | 中 |
|
||||
| デバッグ | 簡単 | 難しい | 中程度 |
|
||||
| 配布 | .nyashファイル | .so/.dll | 任意 |
|
||||
| 配布 | .hakoファイル | .so/.dll | 任意 |
|
||||
|
||||
## 📚 まとめ
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ my-awesome-package/
|
||||
│ └── README.md
|
||||
├── examples/
|
||||
│ └── basic_usage.ny
|
||||
└── .nyashignore # 公開時の除外ファイル
|
||||
└── .hakoignore # 公開時の除外ファイル
|
||||
```
|
||||
|
||||
### nyash.toml仕様
|
||||
@ -200,7 +200,7 @@ GET /search?q={query} # パッケージ検索
|
||||
"dependencies": {
|
||||
"basic-utils": "^2.0.0"
|
||||
},
|
||||
"tarball": "https://registry.nyash.dev/awesome-math-1.0.0.tgz"
|
||||
"tarball": "https://registry.hako.dev/awesome-math-1.0.0.tgz"
|
||||
}
|
||||
```
|
||||
|
||||
@ -221,7 +221,7 @@ public_key = "..."
|
||||
nyash_modules/
|
||||
└── awesome-math/
|
||||
├── nyash.toml
|
||||
└── .nyash-integrity # SHA256ハッシュ
|
||||
└── .hako-integrity # SHA256ハッシュ
|
||||
```
|
||||
|
||||
### 権限システム
|
||||
@ -247,9 +247,9 @@ members = [
|
||||
### プライベートレジストリ
|
||||
|
||||
```toml
|
||||
# .nyashrc
|
||||
# .hakorc
|
||||
[registries]
|
||||
default = "https://registry.nyash.dev"
|
||||
default = "https://registry.hako.dev"
|
||||
company = "https://npm.company.com"
|
||||
|
||||
[scopes]
|
||||
@ -276,7 +276,7 @@ nyash cache add awesome-math@1.0.0
|
||||
### インテリジェントキャッシュ
|
||||
|
||||
```
|
||||
~/.nyash/cache/
|
||||
~/.hako/cache/
|
||||
├── packages/
|
||||
│ └── awesome-math-1.0.0.tgz
|
||||
├── metadata/
|
||||
|
||||
@ -56,7 +56,7 @@ impl eframe::App for NyashBrowser {
|
||||
ui.text_edit_singleline(&mut self.url);
|
||||
if ui.button("Go").clicked() {
|
||||
// Nyashファイル実行
|
||||
if self.url.ends_with(".nyash") {
|
||||
if self.url.ends_with(".hako") {
|
||||
self.content = execute_nyash(&self.url);
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ impl eframe::App for NyashBrowser {
|
||||
// Tauriコマンドでブラウザ機能実装
|
||||
#[tauri::command]
|
||||
async fn browse_nyash(url: String) -> Result<BrowseResult, String> {
|
||||
if url.ends_with(".nyash") {
|
||||
if url.ends_with(".hako") {
|
||||
// Nyash VMで直接実行
|
||||
let vm = NyashVM::new();
|
||||
let result = vm.execute_file(&url)?;
|
||||
@ -158,7 +158,7 @@ box SharedMemoryRenderer {
|
||||
```nyash
|
||||
box DevServer from FileWatcherBox {
|
||||
watchAndReload(directory) {
|
||||
me.watch(directory, "*.nyash", (file) => {
|
||||
me.watch(directory, "*.hako", (file) => {
|
||||
// 変更を検出したら即座にリコンパイル
|
||||
local compiled = me.compiler.compileWithSourceMap(file)
|
||||
|
||||
@ -231,7 +231,7 @@ box CollaborativeEditor from P2PBox {
|
||||
- [ ] Nyash VM統合
|
||||
|
||||
### Week 2: コア機能
|
||||
- [ ] .nyashファイル実行
|
||||
- [ ] .hakoファイル実行
|
||||
- [ ] JIT/AOTコンパイル統合
|
||||
- [ ] 基本的なセキュリティ
|
||||
|
||||
|
||||
@ -14,15 +14,15 @@ Nyashでブラウザーを作り、ネイティブ実行する構想について
|
||||
{
|
||||
"name": "Nyash Browser Extension",
|
||||
"permissions": ["webRequest", "webRequestBlocking", "nativeMessaging"],
|
||||
"host_permissions": ["*://*/*.nyash"]
|
||||
"host_permissions": ["*://*/*.hako"]
|
||||
}
|
||||
|
||||
// background.js
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
(details) => {
|
||||
if (details.url.endsWith('.nyash')) {
|
||||
if (details.url.endsWith('.hako')) {
|
||||
// Native hostと通信してNyash VMで実行
|
||||
chrome.runtime.sendNativeMessage('com.nyash.runtime',
|
||||
chrome.runtime.sendNativeMessage('com.hako.runtime',
|
||||
{ command: 'execute', url: details.url },
|
||||
(response) => {
|
||||
// 結果を新しいタブで表示
|
||||
@ -99,8 +99,8 @@ async fn execute_nyash(window: Window, code: String) -> Result<Value, String> {
|
||||
fn nyash_protocol_handler(app: &AppHandle, request: &Request) -> Response {
|
||||
let path = request.uri().path();
|
||||
|
||||
// .nyashファイルを実行
|
||||
if path.ends_with(".nyash") {
|
||||
// .hakoファイルを実行
|
||||
if path.ends_with(".hako") {
|
||||
let code = std::fs::read_to_string(path).unwrap();
|
||||
let vm = VM::new();
|
||||
let result = vm.execute(&code).unwrap();
|
||||
@ -124,7 +124,7 @@ fn nyash_protocol_handler(app: &AppHandle, request: &Request) -> Response {
|
||||
#### 1. カスタムHTMLエレメント
|
||||
```html
|
||||
<!-- Nyashコードを直接HTMLに埋め込み -->
|
||||
<nyash-app src="todo-app.nyash">
|
||||
<nyash-app src="todo-app.hako">
|
||||
<template>
|
||||
<div class="todo-list">
|
||||
<nyash-for items="todos" as="todo">
|
||||
@ -423,7 +423,7 @@ impl eframe::App for NyashBrowser {
|
||||
|
||||
2. **Week 2**: カスタムプロトコル
|
||||
- nyash://プロトコルハンドラー
|
||||
- .nyashファイル実行
|
||||
- .hakoファイル実行
|
||||
- 結果表示
|
||||
|
||||
3. **Week 3**: 高速化
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
```javascript
|
||||
// Chrome拡張機能側
|
||||
chrome.webNavigation.onBeforeNavigate.addListener((details) => {
|
||||
if (details.url.endsWith('.nyash')) {
|
||||
if (details.url.endsWith('.hako')) {
|
||||
// Native Messagingでローカルプロセスと通信
|
||||
chrome.runtime.sendNativeMessage('com.nyash.executor',
|
||||
chrome.runtime.sendNativeMessage('com.hako.executor',
|
||||
{ action: 'execute', url: details.url },
|
||||
(response) => {
|
||||
// 実行結果をタブに表示
|
||||
@ -109,7 +109,7 @@ box NyashBrowser from TauriBox {
|
||||
init { apps, vm, cache }
|
||||
|
||||
navigateTo(url) {
|
||||
if url.endsWith(".nyash") {
|
||||
if url.endsWith(".hako") {
|
||||
// ローカルキャッシュチェック
|
||||
local app = me.cache.get(url)
|
||||
if !app {
|
||||
@ -216,7 +216,7 @@ let wasi_env = WasiEnv::builder("nyash-app")
|
||||
```nyash
|
||||
box DevServer {
|
||||
watch(directory) {
|
||||
me.fs.watchFiles(directory, "*.nyash", (file) => {
|
||||
me.fs.watchFiles(directory, "*.hako", (file) => {
|
||||
me.recompile(file)
|
||||
me.browser.reload()
|
||||
me.notify("Reloaded: " + file)
|
||||
|
||||
@ -56,10 +56,10 @@ I::Call { dst, func, callee, args, effects } => {
|
||||
#### 環境変数制御
|
||||
```bash
|
||||
# v1形式出力(統一Call対応)
|
||||
NYASH_MIR_UNIFIED_CALL=1 ./target/release/nyash program.nyash
|
||||
NYASH_MIR_UNIFIED_CALL=1 ./target/release/nyash program.hako
|
||||
|
||||
# v0形式出力(既存互換)
|
||||
NYASH_MIR_UNIFIED_CALL=0 ./target/release/nyash program.nyash
|
||||
NYASH_MIR_UNIFIED_CALL=0 ./target/release/nyash program.hako
|
||||
```
|
||||
|
||||
### 📊 優先度2: スキーマ情報追加
|
||||
|
||||
@ -37,7 +37,7 @@ Unified Call(開発既定ON)
|
||||
|
||||
4) NYABI(VM Kernel Bridge)下地(未配線・既定OFF)
|
||||
- docs/abi/vm-kernel.md(関数: caps()/policy.*()/resolve_method_batch())
|
||||
- スケルトン: apps/selfhost/vm/boxes/vm_kernel_box.nyash(policy スタブ)
|
||||
- スケルトン: apps/selfhost/vm/boxes/vm_kernel_box.hako(policy スタブ)
|
||||
- 既定OFFトグル予約: NYASH_VM_NY_KERNEL, *_TIMEOUT_MS, *_TRACE
|
||||
|
||||
非スコープ(やらない)
|
||||
@ -82,7 +82,7 @@ Unified Call(開発既定ON)
|
||||
- Phase 15.5(基盤整理): ../phase-15.5/README.md
|
||||
- Known/Rewrite 観測: src/mir/builder/{method_call_handlers.rs,builder_calls.rs}, src/debug/hub.rs
|
||||
- QuickRef(表示API): docs/reference/language/quick-reference.md
|
||||
- Mini‑VM: apps/selfhost/vm/boxes/mir_vm_min.nyash
|
||||
- Mini‑VM: apps/selfhost/vm/boxes/mir_vm_min.hako
|
||||
- スモーク: tools/smokes/v2/profiles/quick/core/
|
||||
|
||||
更新履歴
|
||||
|
||||
@ -133,10 +133,10 @@ Call { callee: Callee, args }
|
||||
|
||||
#### Phase 15.3 — Detailed Plan(Ny compiler MVP)
|
||||
- Directory layout(selfhost compiler)
|
||||
- `apps/selfhost-compiler/compiler.nyash`(CompilerBox entry; Ny→JSON v0 emit)
|
||||
- `apps/selfhost-compiler/parser/{lexer.nyash,parser.nyash,ast.nyash}`(Stage‑2 へ段階拡張)
|
||||
- `apps/selfhost-compiler/emitter/json_v0.nyash`(将来: emit 分離。MVPは inline でも可)
|
||||
- `apps/selfhost-compiler/mir/{builder.nyash,optimizer.nyash}`(将来)
|
||||
- `apps/selfhost-compiler/compiler.hako`(CompilerBox entry; Ny→JSON v0 emit)
|
||||
- `apps/selfhost-compiler/parser/{lexer.hako,parser.hako,ast.hako}`(Stage‑2 へ段階拡張)
|
||||
- `apps/selfhost-compiler/emitter/json_v0.hako`(将来: emit 分離。MVPは inline でも可)
|
||||
- `apps/selfhost-compiler/mir/{builder.hako,optimizer.hako}`(将来)
|
||||
- `apps/selfhost-compiler/tests/{stage1,stage2}`(サンプルと期待JSON)
|
||||
|
||||
- Runner integration(安全ゲート)
|
||||
@ -164,7 +164,7 @@ Call { callee: Callee, args }
|
||||
- `tools/build_compiler_exe.sh`(Selfhost Parser のEXE化)
|
||||
- `tools/ny_stage2_bridge_smoke.sh`(算術/比較/短絡/ネストif)
|
||||
- `tools/ny_parser_stage2_phi_smoke.sh`(If/Loop の PHI 合流)
|
||||
- `tools/parity.sh --lhs pyvm --rhs llvmlite <test.nyash>`(常時)
|
||||
- `tools/parity.sh --lhs pyvm --rhs llvmlite <test.hako>`(常時)
|
||||
|
||||
Imports/Namespace plan(15.3‑late)
|
||||
- See: imports-namespace-plan.md — keep `nyash.toml` resolution in runner; accept `using` in Ny compiler as no‑op (no resolution) gated by `NYASH_ENABLE_USING=1`.
|
||||
@ -182,7 +182,7 @@ Imports/Namespace plan(15.3‑late)
|
||||
|
||||
【受入(MVP)】
|
||||
- `tools/ny_roundtrip_smoke.sh` 緑(Case A/B)。
|
||||
- `apps/tests/esc_dirname_smoke.nyash` / `apps/selfhost/tools/dep_tree_min_string.nyash` を Ny パーサ経路で実行し、PyVM/llvmlite とパリティ一致(stdout/exit)。
|
||||
- `apps/tests/esc_dirname_smoke.hako` / `apps/selfhost/tools/dep_tree_min_string.hako` を Ny パーサ経路で実行し、PyVM/llvmlite とパリティ一致(stdout/exit)。
|
||||
|
||||
#### 予告: LoopForm(MIR18)での PHI 自動化(Phase‑15 後)
|
||||
- LoopForm を強化し、`loop.begin(loop_carried_values) / loop.iter / loop.branch / loop.end` の構造的情報から逆Loweringで PHI を合成。
|
||||
@ -433,9 +433,9 @@ ny_free_buf(buffer)
|
||||
- [ROADMAP.md](ROADMAP.md) - 進捗管理用チェックリスト
|
||||
|
||||
### ✅ クイックスモーク(現状)
|
||||
- PyVM↔llvmlite パリティ: `tools/parity.sh --lhs pyvm --rhs llvmlite apps/tests/esc_dirname_smoke.nyash`
|
||||
- dep_tree(ハーネスON): `NYASH_LLVM_FEATURE=llvm ./tools/build_llvm.sh apps/selfhost/tools/dep_tree_min_string.nyash -o app_dep && ./app_dep`
|
||||
- Selfhost Parser EXE: `tools/build_compiler_exe.sh && (cd dist/nyash_compiler && ./nyash_compiler tmp/sample.nyash > sample.json)`
|
||||
- PyVM↔llvmlite パリティ: `tools/parity.sh --lhs pyvm --rhs llvmlite apps/tests/esc_dirname_smoke.hako`
|
||||
- dep_tree(ハーネスON): `NYASH_LLVM_FEATURE=llvm ./tools/build_llvm.sh apps/selfhost/tools/dep_tree_min_string.hako -o app_dep && ./app_dep`
|
||||
- Selfhost Parser EXE: `tools/build_compiler_exe.sh && (cd dist/nyash_compiler && ./nyash_compiler tmp/sample.hako > sample.json)`
|
||||
- JSON v0 bridge spec: `docs/reference/ir/json_v0.md`
|
||||
- Stage‑2 smokes: `tools/ny_stage2_bridge_smoke.sh`, `tools/ny_parser_stage2_phi_smoke.sh`, `tools/ny_me_dummy_smoke.sh`
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ This roadmap is a living checklist to advance Phase 15 with small, safe boxes. U
|
||||
|
||||
- JSON v0 bridge: `tools/ny_parser_bridge_smoke.sh` / `tools/ny_parser_bridge_smoke.ps1`
|
||||
- E2E roundtrip: `tools/ny_roundtrip_smoke.sh` / `tools/ny_roundtrip_smoke.ps1`
|
||||
- EXE-first smoke: `tools/build_compiler_exe.sh && (cd dist/nyash_compiler && ./nyash_compiler tmp/sample.nyash > sample.json)`
|
||||
- EXE-first smoke: `tools/build_compiler_exe.sh && (cd dist/nyash_compiler && ./nyash_compiler tmp/sample.hako > sample.json)`
|
||||
|
||||
## Implementation Dependencies
|
||||
|
||||
|
||||
@ -362,11 +362,11 @@ box BootstrapVerifier {
|
||||
verify() {
|
||||
// Stage 0でStage 1をビルド
|
||||
local stage0 = new CompilerBox() // Rust版
|
||||
local stage1_code = stage0.compile(readFile("compiler.nyash"))
|
||||
local stage1_code = stage0.compile(readFile("compiler.hako"))
|
||||
|
||||
// Stage 1でStage 2をビルド
|
||||
local stage1 = stage1_code.instantiate()
|
||||
local stage2_code = stage1.compile(readFile("compiler.nyash"))
|
||||
local stage2_code = stage1.compile(readFile("compiler.hako"))
|
||||
|
||||
// バイナリ比較
|
||||
if stage1_code.equals(stage2_code) {
|
||||
|
||||
@ -158,20 +158,20 @@ fn main() -> Result<()> {
|
||||
### 統合実行(将来)
|
||||
```bash
|
||||
# ワンステップビルド
|
||||
nyash build --backend llvm --emit exe program.nyash -o program.exe
|
||||
nyash build --backend llvm --emit exe program.hako -o program.exe
|
||||
|
||||
# デバッグ用分離実行
|
||||
nyash --dump-mir program.nyash > program.mir.json
|
||||
nyash --dump-mir program.hako > program.mir.json
|
||||
nyash-llvm-compiler program.mir.json -o program.exe
|
||||
```
|
||||
|
||||
### パイプライン実行
|
||||
```bash
|
||||
# Unix pipe
|
||||
nyash --dump-mir program.nyash | nyash-llvm-compiler - -o program.exe
|
||||
nyash --dump-mir program.hako | nyash-llvm-compiler - -o program.exe
|
||||
|
||||
# Windows
|
||||
nyash --dump-mir program.nyash > temp.mir
|
||||
nyash --dump-mir program.hako > temp.mir
|
||||
nyash-llvm-compiler temp.mir -o program.exe
|
||||
```
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ Internal Architecture
|
||||
|
||||
Integration Points
|
||||
- Parser EXE → MIR Builder EXE
|
||||
- `./nyash_compiler <in.nyash> | ny_mir_builder --stdin --emit obj -o a.o`
|
||||
- `./nyash_compiler <in.hako> | ny_mir_builder --stdin --emit obj -o a.o`
|
||||
- Compose with link step for quick end‑to‑end: `... --emit exe -o a.out`
|
||||
- Runner (future option)
|
||||
- `NYASH_USE_NY_COMPILER_EXE=1`: Runner spawns parser EXE; optionally chain into MIR Builder EXE for AOT.
|
||||
|
||||
@ -186,7 +186,7 @@ fn execute_mir_call(&mut self, mir_call: &MirCall) -> Result<VMValue, VMError> {
|
||||
mini-vmは新規実装のため、最初から統一MirCall対応で実装:
|
||||
|
||||
```nyash
|
||||
// apps/selfhost/vm/call_executor.nyash
|
||||
// apps/selfhost/vm/call_executor.hako
|
||||
static box CallExecutor {
|
||||
execute(mir_call: MirCallBox) {
|
||||
local callee_type = mir_call.getCalleeType()
|
||||
@ -432,7 +432,7 @@ impl MirInterpreter {
|
||||
### 📅 Medium(1ヶ月以内)
|
||||
|
||||
7. **mini-vm統一Call実装**
|
||||
- `apps/selfhost/vm/call_executor.nyash`作成
|
||||
- `apps/selfhost/vm/call_executor.hako`作成
|
||||
- Nyashでの統一処理実装
|
||||
|
||||
8. **環境変数デフォルト化**
|
||||
|
||||
@ -146,8 +146,8 @@ fn is_reserved_type(name: &str) -> bool {
|
||||
#### 2. プラグイン版テスト
|
||||
```bash
|
||||
# Step 1: 単体テスト
|
||||
NYASH_USE_PLUGIN_CORE_BOXES=1 ./target/release/nyash test_integer.nyash
|
||||
NYASH_USE_PLUGIN_CORE_BOXES=1 ./target/release/nyash test_string.nyash
|
||||
NYASH_USE_PLUGIN_CORE_BOXES=1 ./target/release/nyash test_integer.hako
|
||||
NYASH_USE_PLUGIN_CORE_BOXES=1 ./target/release/nyash test_string.hako
|
||||
|
||||
# Step 2: スモークテスト
|
||||
NYASH_USE_PLUGIN_CORE_BOXES=1 ./tools/jit_smoke.sh
|
||||
@ -159,7 +159,7 @@ NYASH_USE_PLUGIN_CORE_BOXES=1 cargo test
|
||||
#### 3. パフォーマンス測定
|
||||
```bash
|
||||
# ベンチマーク
|
||||
./target/release/nyash --benchmark core_vs_plugin.nyash
|
||||
./target/release/nyash --benchmark core_vs_plugin.hako
|
||||
```
|
||||
|
||||
### Phase B: MIRビルダー統一(2週目)
|
||||
@ -219,13 +219,13 @@ MirType::Box(class.to_string())
|
||||
#### 3. デフォルト動作の確立
|
||||
```bash
|
||||
# 環境変数なしでプラグインBox使用
|
||||
./target/release/nyash test.nyash # StringBox = プラグイン版
|
||||
./target/release/nyash test.hako # StringBox = プラグイン版
|
||||
```
|
||||
|
||||
### Phase D: Nyashコード実装(将来)
|
||||
|
||||
```nyash
|
||||
// apps/lib/core_boxes/string_box.nyash
|
||||
// apps/lib/core_boxes/string_box.hako
|
||||
box StringBox {
|
||||
data: InternalString // 内部表現
|
||||
|
||||
@ -248,7 +248,7 @@ box StringBox {
|
||||
```
|
||||
|
||||
```nyash
|
||||
// apps/lib/core_boxes/integer_box.nyash
|
||||
// apps/lib/core_boxes/integer_box.hako
|
||||
box IntegerBox {
|
||||
value: i64
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
**要点:**
|
||||
- NyModules 共有レジストリ導入: env.modules.set/get(または ModulesBox)
|
||||
- ny_plugins のパス→名前空間導出: ルート相対、"/"→".", 拡張子 .nyash 省略、[^a-zA-Z0-9_.]→"_"
|
||||
- ny_plugins のパス→名前空間導出: ルート相対、"/"→".", 拡張子 .hako 省略、[^a-zA-Z0-9_.]→"_"
|
||||
- Windowsパス: "\\"→"/" 正規化後に上記規則を適用
|
||||
- 予約衝突: nyashstd.* の登録を明示拒否しログ出力
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
|
||||
**スモーク/CI:**
|
||||
- `tools/ny_roundtrip_smoke.sh` / `tools/ny_parser_bridge_smoke.sh`
|
||||
- `tools/parity.sh --lhs pyvm --rhs llvmlite <smoke.nyash>`(Nyパーサ経路ON)
|
||||
- `tools/parity.sh --lhs pyvm --rhs llvmlite <smoke.hako>`(Nyパーサ経路ON)
|
||||
|
||||
**完了基準:**
|
||||
- esc_dirname_smoke / dep_tree_min_string が Ny パーサ経路でも PyVM/llvmlite と一致(stdout/exit)。
|
||||
@ -140,7 +140,7 @@
|
||||
cargo build --release --features cranelift-jit
|
||||
|
||||
# 実行
|
||||
./target/release/nyash --backend vm apps/selfhost-minimal/main.nyash
|
||||
./target/release/nyash --backend vm apps/selfhost-minimal/main.hako
|
||||
|
||||
# スモーク
|
||||
./tools/jit_smoke.sh
|
||||
@ -158,7 +158,7 @@ cargo build --release --features cranelift-jit
|
||||
|
||||
- 2並走・重複回避: `CODEX_MAX_CONCURRENT=2 CODEX_DEDUP=1 CODEX_ASYNC_DETACH=1`
|
||||
- 監視: `pgrep -af 'codex .* exec'` / `tail -f ~/.codex-async-work/logs/codex-*.log`
|
||||
- Windowsパス/名前空間: "\\"→"/" 正規化 → ルール適用(/→., .nyash除去, sanitize)
|
||||
- Windowsパス/名前空間: "\\"→"/" 正規化 → ルール適用(/→., .hako除去, sanitize)
|
||||
|
||||
## 備考
|
||||
|
||||
|
||||
@ -186,10 +186,10 @@ Error: @derive(Equals) cannot be applied to UserBox
|
||||
### デバッグ支援
|
||||
```bash
|
||||
# マクロ展開の可視化
|
||||
nyash --expand program.nyash
|
||||
nyash --expand program.hako
|
||||
|
||||
# ステップバイステップ追跡
|
||||
NYASH_MACRO_TRACE=1 nyash program.nyash
|
||||
NYASH_MACRO_TRACE=1 nyash program.hako
|
||||
```
|
||||
|
||||
## 📊 成功指標(2週間後)
|
||||
|
||||
@ -110,7 +110,7 @@ test_person_equals() {
|
||||
|
||||
```bash
|
||||
# テスト実行
|
||||
nyash --run-tests my_program.nyash
|
||||
nyash --run-tests my_program.hako
|
||||
# [TEST] test_person_creation ... OK
|
||||
# [TEST] test_person_equals ... OK
|
||||
# Tests: 2 passed, 0 failed
|
||||
@ -158,10 +158,10 @@ macro bad_macro() {
|
||||
### **マクロ展開の可視化**
|
||||
```bash
|
||||
# マクロ展開結果を表示
|
||||
nyash --expand my_program.nyash
|
||||
nyash --expand my_program.hako
|
||||
|
||||
# 詳細トレース
|
||||
NYASH_MACRO_TRACE=1 nyash my_program.nyash
|
||||
NYASH_MACRO_TRACE=1 nyash my_program.hako
|
||||
# [MACRO] @derive(Equals) -> generating equals() method for Person
|
||||
# [MACRO] @test -> collecting test_person_creation()
|
||||
# [MACRO] Expansion complete: 2 macros processed, 0 errors
|
||||
@ -174,7 +174,7 @@ box Person {}
|
||||
|
||||
// エラー例:
|
||||
// error: Unknown derive trait 'UnknownTrait'
|
||||
// --> person.nyash:1:9
|
||||
// --> person.hako:1:9
|
||||
// |
|
||||
// 1 | @derive(UnknownTrait)
|
||||
// | ^^^^^^^^^^^^
|
||||
|
||||
@ -14,7 +14,7 @@ Status: active (Stage B → C 準備)
|
||||
Stages(概要)
|
||||
- Stage A(完了)
|
||||
- 文字列スキャンで整数抽出→print、if(リテラル条件)の最小到達。
|
||||
- サンプル: `apps/selfhost-vm/mini_vm*.nyash`
|
||||
- サンプル: `apps/selfhost-vm/mini_vm*.hako`
|
||||
- スモーク(v2): `tools/smokes/v2/run.sh --profile quick --filter "mini_vm|selfhost"`
|
||||
- Stage B(進行中)
|
||||
- stdinローダ(`NYASH_MINIVM_READ_STDIN=1`)[実装済]
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
Week 1 — LoopForm MVP(while, break/continue無し)
|
||||
- 目標: whileループを“キャリア(タプル)”へ正規化するユーザーマクロを実装(Nyash/PyVM)。
|
||||
- 成果物:
|
||||
- apps/macros/examples/loop_normalize_macro.nyash(MVP)
|
||||
- apps/macros/examples/loop_normalize_macro.hako(MVP)
|
||||
- ゴールデン: while基本/2変数キャリア/更新式の正規化
|
||||
- スモーク: selfhost-preexpand で自動適用→PyVM/LLVMの一致
|
||||
- 受け入れ基準:
|
||||
|
||||
@ -39,7 +39,7 @@ Constraints / Notes
|
||||
- 衛生: MacroCtx.gensym で __car_phi/__carK などの一意名を生成。
|
||||
|
||||
Integration
|
||||
- ユーザーマクロ: `apps/macros/examples/loop_normalize_macro.nyash`
|
||||
- ユーザーマクロ: `apps/macros/examples/loop_normalize_macro.hako`
|
||||
- 事前展開: selfhost‑preexpand auto(PyVM限定)で適用
|
||||
- 検証: macro‑golden + LLVM PHI健全性スモーク(空PHIなし/先頭グループ化)
|
||||
|
||||
|
||||
@ -39,9 +39,9 @@ Purpose: ship a tiny, beautiful vertical slice that runs Core‑13 IR end‑to
|
||||
- Events (lines): `{"event":"EnterFunc","func":"main"}` / `{"event":"ExitFunc","func":"main"}`.
|
||||
|
||||
5) CLI UX
|
||||
- `nyash run --engine=vm apps/hello.nyash`
|
||||
- `nyash run --engine=remote --exe ./nyash-engine-core13 apps/hello.nyash`
|
||||
- `nyash ir-emit --ir=core13 --format=json apps/hello.nyash > out.json`
|
||||
- `nyash run --engine=vm apps/hello.hako`
|
||||
- `nyash run --engine=remote --exe ./nyash-engine-core13 apps/hello.hako`
|
||||
- `nyash ir-emit --ir=core13 --format=json apps/hello.hako > out.json`
|
||||
- `nyash ir-run --engine=vm < out.json`
|
||||
|
||||
6) Milestones
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
## 🎯 核心的なアイデア
|
||||
|
||||
```
|
||||
ソースコード(.nyash) ⇔ データベース(SQLite)
|
||||
ソースコード(.hako) ⇔ データベース(SQLite)
|
||||
↓ ↓
|
||||
Git管理 高速リファクタリング
|
||||
エディタ編集 構造化分析
|
||||
@ -185,7 +185,7 @@ box FileSyncDaemon {
|
||||
local watcher = new FileWatcher(directory)
|
||||
|
||||
watcher.on("change") { event ->
|
||||
if event.file.endsWith(".nyash") {
|
||||
if event.file.endsWith(".hako") {
|
||||
me.syncFileToDb(event.file)
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user