feat(selfhost): Phase 151 - ConsoleBox Selfhost Support
- Identify ConsoleBox registration issue: plugins registered but PluginBoxFactory can't find them - Root cause: timing/initialization order between BoxFactoryRegistry and UnifiedBoxRegistry - Solution: Add ConsoleBox builtin fallback for selfhost Stage-3 pipeline - Implementation: Plugin-preferred, builtin as fallback - Test results: 2/2 PASS (esc_dirname_smoke.hako, string_ops_basic.hako) Modified files: - src/box_factory/builtin_impls/console_box.rs (new, 35 lines) - src/box_factory/builtin_impls/mod.rs (add console_box module) - src/box_factory/builtin.rs (add ConsoleBox creation and box_types) - CURRENT_TASK.md (Phase 151 completion) - docs/development/current/main/phase151_consolebox_selfhost_support.md (implementation summary) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -138,6 +138,23 @@ static box Main {
|
||||
- VM/MIR/LLVM いずれのバックエンドでも、この規約に基づき引数個数(arity)を判定する。
|
||||
- 開発時のガイドライン: 静的Box内に定義する全メソッドは「先頭に `self` を取る」形で設計すること(将来の最適化や検証で一貫性を保つため)。
|
||||
|
||||
📌 **構文に関する注意(`static method` について)**
|
||||
|
||||
- Stage‑3 の正式仕様では、静的な機能は **`static box` + その内部のメソッド定義** で表現する。
|
||||
- かつて検討された `static method main() { ... }` のような **宣言構文としての `static method`** は、
|
||||
- EBNF / 言語仕様には含まれておらず、
|
||||
- selfhost テスト用フィクスチャに一部残っているだけの **legacy/非推奨構文** だよ。
|
||||
- **推奨スタイル**:
|
||||
```nyash
|
||||
static box Main {
|
||||
main() {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
```
|
||||
- 静的メソッド的な意味は、`static box` による「ファイルに 1 個のグローバル Box」+その内部メソッドで表現する。
|
||||
- これによりパーサ・MIR・JoinIR・selfhost のすべてで一貫した扱いになる。
|
||||
|
||||
### **2.2 変数宣言**
|
||||
|
||||
#### **基本パターン**
|
||||
|
||||
@ -202,6 +202,13 @@ static box Main {
|
||||
}
|
||||
```
|
||||
|
||||
📌 **Note: `Type::static_method` と宣言構文について**
|
||||
|
||||
- 呼び出し側では `Type::static_method(...)` のように「型にぶら下がった関数」を使うことができるが、
|
||||
これはあくまで **呼び出し構文** だよ。
|
||||
- 宣言側の構文としては **`static box` の中に通常のメソッドを定義する** のが Stage‑3 仕様の正しい形で、
|
||||
`static method foo() { ... }` のようなトップレベル/Box外の宣言構文は **legacy/非推奨** であり、今後の実装では使用しない。
|
||||
|
||||
Runner Configuration
|
||||
- Enable using pre‑processing: `NYASH_ENABLE_USING=1`
|
||||
- CLI from-the-top registration: `--using "ns as Alias"` or `--using '"apps/foo.hako" as Foo'` (repeatable)
|
||||
|
||||
Reference in New Issue
Block a user