feat(frontend): real statement lowering — let/if/else/while/indexed access + parser skip_declaration fix#199
Merged
Conversation
…ccess + skip_declaration bug fix
Takes example 03/04 system bodies from representative stubs to REAL
typed loads/stores with pinned access sites, executed correctly in a
real engine.
- parser: general statement lowerer (tried after the exact reader/
writer shapes; bails to the stub on anything unsupported). Covers
`let [mut] x: ty = expr`, assignment, `if`/`else`, `while` (block/
loop/br_if), `return [expr]`, indexed `region.get/set $h[i] .f`
(base + i*stride), `cast<i32|f32|f64>`, typed expression lowering
with precedence (cmp > add > mul > primary) and no implicit
promotion. Each region param is copied to a base local ONCE in the
prologue so own/&mut discipline holds under per-path use counting
regardless of how many accesses follow.
- IR: Op gains locals/control-flow/arithmetic/conversion instructions;
Func gains `locals` (emitted via Function::new_with_locals_types).
- REAL BUG FIX: skip_declaration skipped a balanced `{...}` block and
then KEPT SCANNING for a `;` — so example-04's top-level
`invariant ... { ... }` blocks swallowed every following declaration:
ex04's functions were never parsed at all (its "6/6 corpus
round-trip" was regions-only). Now returns after a block-shaped
declaration; ex04 parses 4 functions, 3 lower for real.
- tests/example04.rs: real-lowering assertions for ex03/ex04 bodies
(pinned sites), all-verifier-passes gate (validate + L7/L10 + L2
bounds + L2 access-typing), and a wasmi execution gate proving
while/if-else/indexed/cast lowering COMPUTES correct results
(sum-abs + f32-scale over a cell array).
Workspace: 166 tests, 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Increment 2 of 3 on the independence construction path.
The statement lowerer takes ECS-style bodies (examples 03/04) from representative stubs to real typed loads/stores with pinned access sites:
let, assignment,if/else,while, indexedregion.get/set $h[i] .f,cast<>, typed expressions with precedence and no implicit promotion. Region params are copied to a base local once in the prologue, soown/&mutdiscipline survives arbitrarily many accesses under the verifier's per-path use counting.Also fixes a real parser bug found by the new tests:
skip_declarationskipped a balanced{…}and then kept scanning for a;, so example-04's top-levelinvariant … { … }blocks swallowed every following declaration — ex04's functions were never parsed at all (its corpus "round-trip" was regions-only). After the fix ex04 parses 4 functions and 3 lower for real.Verification: all-passes gate (structural validation + L7/L10 + L2 bounds + L2 access-typing on the pinned sites) over both examples, plus a wasmi execution gate proving the lowered control flow computes correct results (both if-branches, loop entry/skip, cast round-trip). 166 workspace tests, 0 failures.
🤖 Generated with Claude Code