docs+runner+parser: SSOT+AST using finalized (legacy text inlining removed); provider verify reads nyash.toml; preflight warn hook; method-body guard removed; CURRENT_TASK updated for next JSON work
This commit is contained in:
@ -114,5 +114,5 @@ Nyash Source ──▶ MIR (Builder)
|
||||
- `docs/reference/architecture/mir-26-instruction-diet.md`
|
||||
|
||||
See also
|
||||
- `docs/examples/http_result_patterns.md` - HTTPのResult挙動(unreachable/404/500)のE2E例
|
||||
- `docs/guides/examples/http_result_patterns.md` - HTTPのResult挙動(unreachable/404/500)のE2E例
|
||||
- `docs/VM_README.md` - VM統計とプラグイン周りの既知制約
|
||||
|
||||
23
docs/reference/architecture/phi-and-ssa.md
Normal file
23
docs/reference/architecture/phi-and-ssa.md
Normal file
@ -0,0 +1,23 @@
|
||||
# PHI and SSA in Nyash
|
||||
|
||||
Overview
|
||||
- Nyash lowers high-level control flow (If/Loop/Match) to MIR and backends that rely on SSA form.
|
||||
- We prioritize IR hygiene and observability while keeping runtime cost at zero.
|
||||
|
||||
Design points
|
||||
- PHI hygiene: no empty PHIs; PHIs at block head only.
|
||||
- JoinResult hint: when both branches assign the same variable, we emit a MIR hint for diagnostics.
|
||||
- Loop carriers: loops may expose a carrier observation (≤ N variables, where N is unconstrained by design; smokes emphasize common cases).
|
||||
|
||||
Normalization
|
||||
- If: may optionally wrap into LoopForm under a conservative gate (dev only). Semantics remain unchanged.
|
||||
- Match: scrutinee evaluated once, guard fused; normalized to nested If‑chain in macro/core pass.
|
||||
|
||||
Testing
|
||||
- LLVM smokes: fixed small cases ensure no empty PHIs and head placement.
|
||||
- MIR smokes: trace `scope|join|loop` to validate shaping without peeking into IR details.
|
||||
|
||||
Roadmap
|
||||
- Remove text-level sanitization once finalize‑PHI is trustworthy across Loop/If/Match.
|
||||
- Expand goldens to cover nested joins and multi‑carrier loops while keeping CI light.
|
||||
|
||||
85
docs/reference/config/nyash-toml.md
Normal file
85
docs/reference/config/nyash-toml.md
Normal file
@ -0,0 +1,85 @@
|
||||
# nyash.toml — Configuration Reference (Phase 15.5)
|
||||
|
||||
Status: Proposed(受け口から段階導入。未指定時は現行既定を維持)
|
||||
|
||||
## 目的
|
||||
- 依存関係・実行方針の**唯一の真実(SSOT)**。
|
||||
- using の解決(AST プレリュード)と、将来の Provider/Type 分離(受け口)を一元管理。
|
||||
|
||||
## セクション一覧
|
||||
|
||||
### [env]
|
||||
任意の既定環境変数(`NYASH_*`)。CI/ローカルで上書き可。
|
||||
|
||||
### [using]
|
||||
検索ルート `paths = ["apps","lib","."]`、名前付きパッケージ `[using.<name>]`、エイリアス `[using.aliases]`。
|
||||
|
||||
例:
|
||||
```toml
|
||||
[using]
|
||||
paths = ["apps", "lib", "."]
|
||||
|
||||
[using.json_native]
|
||||
path = "apps/lib/json_native/"
|
||||
main = "parser/parser.nyash"
|
||||
|
||||
[using.string_utils]
|
||||
path = "apps/lib/json_native/utils/string.nyash"
|
||||
|
||||
[using.aliases]
|
||||
json = "json_native"
|
||||
StringUtils = "string_utils"
|
||||
```
|
||||
|
||||
### Provider/Type(受け口・既定OFF)
|
||||
|
||||
Stable Type Name(STN)を Provider ID(PVN)にマッピング。未指定時は現行ランタイム既定。
|
||||
|
||||
```toml
|
||||
[types.StringBox]
|
||||
provider = "kernel:string@1.0"
|
||||
interop = "forbid" # forbid|explicit|auto(既定: forbid)
|
||||
|
||||
[providers."kernel:string@1.0"]
|
||||
crate = "nyash-plugin-base-string" # 静的リンクのブートストラップ提供者
|
||||
|
||||
[providers."acme:string@2.1"]
|
||||
path = "./plugins/libacme_string.so"
|
||||
override = true
|
||||
|
||||
[policy]
|
||||
factory = "plugin-first" # plugin-first|compat_plugin_first|static_only
|
||||
```
|
||||
|
||||
注意:
|
||||
- 本仕様は「受け口」の段階。実行挙動は段階導入(Verify→Lock→実行)。
|
||||
- 互換性重視のため、未指定時は現行と同じ既定にフォールバックする。
|
||||
|
||||
### [plugins.bootstrap] / [plugins.dynamic](提案)
|
||||
静的リンクのブートストラップ束/動的ロード(開発)を明示。
|
||||
|
||||
```toml
|
||||
[plugins.bootstrap]
|
||||
string = { crate = "nyash-plugin-base-string", version = "2.3.0" }
|
||||
integer = { crate = "nyash-plugin-base-integer", version = "1.5.1" }
|
||||
|
||||
[plugins.dynamic]
|
||||
# string = { path = "./plugins/libnyash_string_plugin.so", override = true }
|
||||
```
|
||||
|
||||
## Profiles(using / AST)
|
||||
`NYASH_USING_PROFILE={dev|ci|prod}`
|
||||
|
||||
- dev/ci: AST プレリュード既定ON(file-usingはdevで許可、ciは警告/限定)
|
||||
- prod: AST 既定OFF(toml 由来のみ、file-using はエラー)
|
||||
|
||||
実装ノート:
|
||||
- AST 既定は `src/config/env.rs: using_ast_enabled()` でプロファイルに従い決定。
|
||||
- 既存のレガシー前置きは prod で禁止、dev/ci でも段階的に削除予定。
|
||||
|
||||
## Verify(plugin-tester)
|
||||
CI/起動前に最低限の契約を検査(例: String の `birth/fini/toUtf8/fromUtf8/equals/length/concat`)。欠落時は即停止。
|
||||
|
||||
## 参考
|
||||
- Kernel/Plugin 方針: docs/reference/runtime/kernel-and-plugins.md
|
||||
- ADR: docs/development/adr/adr-001-no-corebox-everything-is-plugin.md
|
||||
@ -64,7 +64,7 @@ pub enum QualifiedCallee {
|
||||
Policy
|
||||
- Accept `using` lines at the top of the file to declare module namespaces or file imports.
|
||||
- Resolution is performed by the Rust Runner when `NYASH_ENABLE_USING=1`.
|
||||
- 実体の結合は AST マージのみ。テキストの前置き/連結は行わない(移行完了後に完全廃止)。
|
||||
- 実体の結合は AST マージのみ。テキストの前置き/連結は行わない(レガシー経路は呼び出し側から削除済み)。
|
||||
- Runner は `nyash.toml` の `[using]` を唯一の真実として参照(prod)。dev/ci は段階的に緩和可能。
|
||||
- Selfhost compiler (Ny→JSON v0) collects using lines and emits `meta.usings` when present. The bridge currently ignores this meta field.
|
||||
|
||||
@ -191,15 +191,18 @@ Runner Configuration
|
||||
- Enable using pre‑processing: `NYASH_ENABLE_USING=1`
|
||||
- CLI from-the-top registration: `--using "ns as Alias"` or `--using '"apps/foo.nyash" as Foo'` (repeatable)
|
||||
- Using profiles (phase‑in): `NYASH_USING_PROFILE={dev|ci|prod}`
|
||||
- dev: toml + file using(path)可、AST マージ、候補提示 ON
|
||||
- ci: toml 優先、file using は警告/限定、AST マージ、フォールバック OFF
|
||||
- prod: toml のみ、file using/path はエラー(追記ガイドを表示)
|
||||
- dev: AST マージ 既定ON、legacy前置きは既定で無効(必要時は `NYASH_LEGACY_USING_ALLOW=1` で一時許可)
|
||||
- ci: AST マージ 既定ON、legacy前置きは既定で無効(同上の一時許可)
|
||||
- prod: AST マージ 既定OFF、toml のみ(file using/path はエラー・追記ガイド)
|
||||
- Strict mode (plugin prefix required): `NYASH_PLUGIN_REQUIRE_PREFIX=1` または `nyash.toml` の `[plugins] require_prefix=true`
|
||||
- Aliases from env: `NYASH_ALIASES="Foo=apps/foo/main.nyash,Bar=lib/bar.nyash"`
|
||||
- Additional search paths: `NYASH_USING_PATH="apps:lib:."`
|
||||
- Selfhost pipeline keeps child stdout quiet and extracts JSON only: `NYASH_JSON_ONLY=1` (set by Runner automatically for child)
|
||||
- Selfhost emits `meta.usings` automatically when present; no additional flags required.
|
||||
|
||||
Note: Provider/Type 分離(型名は不変で提供者のみを切替)については ADR を参照。
|
||||
docs/development/adr/adr-001-no-corebox-everything-is-plugin.md
|
||||
|
||||
## 🔬 Quick Smokes(AST + Profiles)
|
||||
|
||||
開発・CIで最小コストに確認できるスモークを用意しています。AST プレリュードとプロファイル(dev/prod)の基本動作をカバーします。
|
||||
|
||||
51
docs/reference/runtime/kernel-and-plugins.md
Normal file
51
docs/reference/runtime/kernel-and-plugins.md
Normal file
@ -0,0 +1,51 @@
|
||||
# NyKernel と Plugins — 最小ランタイムとプラグイン体系(Phase 15.5)
|
||||
|
||||
Status: Proposed (受け口のみ; 既定OFF)
|
||||
ADR: docs/development/adr/adr-001-no-corebox-everything-is-plugin.md
|
||||
|
||||
## 目的
|
||||
- Kernel を最小化(箱を持たない)し、機能はすべて Plugin で提供する。
|
||||
- VM/LLVM 双方から同一 ABI(`ny_new_box` / `ny_call_method`)で箱を扱う。
|
||||
|
||||
## 起動シーケンス(標準形)
|
||||
1) NyKernel init(GC/Handle/TLV/Extern/PluginRegistry)
|
||||
2) nyash.toml 読み込み
|
||||
- `plugins.bootstrap`(静的束)を登録
|
||||
- `plugins.dynamic`(.so/.dll)があれば dlopen 登録
|
||||
3) Plugin Verify(必須メソッド/TLV/ABI)
|
||||
4) 実行(VM/LLVM → `ny_call_method`)
|
||||
|
||||
ブートの不変条件(重要)
|
||||
- Provider Lock(型→提供者の対応表)が確定するまで、いかなる Box 生成も禁止。
|
||||
- Kernel ログ(生バイト)で初期エラーを出力し、`StringBox` 等の Box をログ用途に使わない。
|
||||
- Verify に失敗した場合は、Kernel ログで理由を表示して即終了する。
|
||||
|
||||
## Provider/Type 分離(概要)
|
||||
- Stable Type Name(STN): `StringBox`, `IntegerBox` など。コード上の型名は不変。
|
||||
- Provider ID(PVN): `kernel:string@1.0` / `acme:string@2.1` など実装提供者。
|
||||
- TOML で STN→PVN をバインドし、置換は TOML 側で行う。
|
||||
|
||||
Provider Lock(ロック)
|
||||
- 起動時に `types.<Type>` の provider を決定し、Provider Lock を作成・固定する。
|
||||
- Lock 前の `ny_new_box` / `ny_call_method` はエラー(E_PROVIDER_NOT_LOCKED)。
|
||||
- Handle は `{ type_id, provider_id }` を保持し、デバッグビルドでは不一致検知時に panic(本番では混入しない設計)。
|
||||
|
||||
## ポリシー(例)
|
||||
- `plugin-first`(デフォルト): 動的プラグインの上書きを許可
|
||||
- `compat_plugin_first`: 静的→動的のフォールバックを許可(移行期)
|
||||
- `static_only`(本番): 静的のみ許可
|
||||
|
||||
Interop(同一型の異 Provider 混在)
|
||||
- 既定は混在禁止(forbid)。同一プロセス内で 1 Type = 1 Provider を維持する。
|
||||
- 研究・開発用途でのみ `explicit/auto` を許可できるが、本番非推奨。
|
||||
- explicit: 明示 API による変換のみ許可(UTF‑8 などの正規形式を介する)
|
||||
- auto: 暗黙変換を許可し、変換回数・バイト数をメトリクスに集計(本番非推奨)
|
||||
|
||||
## 現状の段階
|
||||
- 受け口/ドキュメントの整備を先行(挙動は不変)。
|
||||
- using は SSOT+AST に移行済み(prod は file-using 禁止)。
|
||||
- VM fallback の個別救済は暫定(短期で Bootstrap Pack へ移行し撤去)。
|
||||
|
||||
関連ドキュメント
|
||||
- nyash.toml のスキーマと例: docs/reference/config/nyash-toml.md
|
||||
- using(SSOT/AST/Profiles): docs/reference/language/using.md
|
||||
Reference in New Issue
Block a user