refactor(plan): Phase 286C-4 Step 1 - plan_helpers module
Create helper functions to support plan_rewrites() extraction: - build_local_block_map(): Build block ID mapping for a function - sync_spans(): Synchronize instruction spans after rewriting These pure functions will be used by both the current monolithic merge_and_rewrite() and the new plan_rewrites() function. Progress: Step 1/4 (helpers) complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -17,7 +17,21 @@ logic := compare (('&&' | '||') compare)*
|
||||
compare := sum (( '==' | '!=' | '<' | '>' | '<=' | '>=' ) sum)?
|
||||
sum := term (('+' | '-') term)*
|
||||
term := unary (('*' | '/') unary)*
|
||||
unary := ('-' | '!' | 'not' | '~' | 'weak') unary | factor
|
||||
unary := ( '-' | '!' | 'not' | '~' ) unary
|
||||
| weak_unary
|
||||
| factor
|
||||
|
||||
; Phase 285W-Syntax-0.1: `weak(<expr>)` is invalid. The operand must not be a grouped
|
||||
; expression starting with `(`. (Write `weak x`, not `weak(x)`.)
|
||||
weak_unary := 'weak' unary_no_group
|
||||
unary_no_group := ( '-' | '!' | 'not' | '~' ) unary_no_group
|
||||
| INT
|
||||
| STRING
|
||||
| IDENT call_tail*
|
||||
| 'new' IDENT '(' args? ')'
|
||||
| '[' args? ']' ; Array literal (Stage‑1 sugar, gated)
|
||||
| '{' map_entries? '}' ; Map literal (Stage‑2 sugar, gated)
|
||||
| match_expr ; Pattern matching (replaces legacy peek)
|
||||
|
||||
factor := INT
|
||||
| STRING
|
||||
|
||||
@ -304,7 +304,7 @@ This section documents current backend reality so we can detect drift as bugs.
|
||||
|
||||
| Feature | VM | LLVM | WASM |
|
||||
|---------|-----|------|------|
|
||||
| WeakRef (`weak <expr>`, `weak_to_strong()`) | ✅ | ❌ unsupported (285LLVM-1) | ❌ unsupported |
|
||||
| WeakRef (`weak <expr>`, `weak_to_strong()`) | ✅ | ✅ LLVM harness (Phase 285LLVM-1.4) | ❌ unsupported |
|
||||
| Leak Report (`NYASH_LEAK_LOG`) | ✅ | ⚠️ Parent process roots only (285LLVM-0) | ❌ |
|
||||
|
||||
**LLVM Leak Report の制限** (Phase 285LLVM-0):
|
||||
@ -316,7 +316,7 @@ This section documents current backend reality so we can detect drift as bugs.
|
||||
### Notes
|
||||
|
||||
- **Block-scoped locals** are the language model (`local` drops at `}`), but the *observable* effects depend on where the last strong reference is held.
|
||||
- **WeakRef** (Phase 285A0): VM backend fully supports `weak <expr>` and `weak_to_strong()`. LLVM harness support is planned for Phase 285LLVM-1.
|
||||
- **WeakRef** (Phase 285A0+): VM backend fully supports `weak <expr>` and `weak_to_strong()`. LLVM harness also supports this surface as of Phase 285LLVM-1.4.
|
||||
- **WASM backend** currently treats MIR `WeakNew/WeakLoad` as plain copies (weak behaves like strong). This does not satisfy the SSOT weak semantics yet (see also: `docs/guides/wasm-guide/planning/unsupported_features.md`).
|
||||
- **Leak Report** (Phase 285): `NYASH_LEAK_LOG={1|2}` prints exit-time diagnostics showing global roots still held (modules, host_handles, plugin_boxes). See `docs/reference/environment-variables.md`.
|
||||
- Conformance gaps (any backend differences from this document) must be treated as bugs and tracked explicitly; do not "paper over" differences by changing this SSOT without a decision.
|
||||
|
||||
@ -26,7 +26,7 @@ Display & Conversion
|
||||
- JSONシリアライズ: `toJson(x)`(文字列)/ `toJsonNode(x)`(構造)
|
||||
|
||||
Operators (precedence high→low)
|
||||
- Unary: `! ~ -`
|
||||
- Unary: `! ~ - weak` (`weak <expr>` produces a `WeakRef`; `weak(expr)` is invalid)
|
||||
- Multiplicative: `* / %`
|
||||
- Additive: `+ -`
|
||||
- Compare: `== != < <= > >=`
|
||||
|
||||
Reference in New Issue
Block a user