This commit is contained in:
Nilton Constantino
2026-01-31 17:23:29 +00:00
parent dd61314bf9
commit e784dab34e
12 changed files with 688 additions and 191 deletions
-42
View File
@@ -1,45 +1,3 @@
## PR-03 — Frame model v0: locals, operand stack, and function metadata
**Why:** `let x: int = 1` failing usually means locals/frames are not modeled correctly.
### Scope
* Define `FunctionMeta`:
* `code_offset`, `code_len`
* `param_slots`, `local_slots`, `return_slots`
* `max_stack_slots` (computed by verifier or compiler)
* Define `Frame`:
* `base` (stack base index)
* `locals_base` (or equivalent)
* `return_slots`
* `pc_return`
* Decide representation:
* Option A (recommended v0): **single VM stack** with fixed layout per frame:
* `[args][locals][operand_stack...]`
* Use `base + local_index` addressing.
### Deliverables
* `CallStack` with `Vec<Frame>`
* `enter_frame(meta)` allocates locals area (zero-init)
* `leave_frame()` reclaims to previous base
### Tests
* locals are isolated per call
* locals are zero-initialized
* stack is restored exactly after return
### Acceptance
* Locals are deterministic and independent from operand stack usage.
---
## PR-04 — Locals opcodes: GET_LOCAL / SET_LOCAL / INIT_LOCAL
**Why:** PBS `let` and parameters need first-class support.