This commit is contained in:
Nilton Constantino
2026-01-31 17:36:26 +00:00
parent e784dab34e
commit 13e58a8efd
5 changed files with 208 additions and 43 deletions
-33
View File
@@ -1,36 +1,3 @@
## PR-04 — Locals opcodes: GET_LOCAL / SET_LOCAL / INIT_LOCAL
**Why:** PBS `let` and parameters need first-class support.
### Scope
* Implement opcodes:
* `GET_LOCAL <u16 slot>` pushes value slots
* `SET_LOCAL <u16 slot>` pops value slots and writes
* `INIT_LOCAL <u16 slot>` (optional) for explicit initialization semantics
* Enforce bounds: local slot index must be within `[0..param+local_slots)`
* Enforce slot width: if types are multi-slot, compiler emits multiple GET/SET or uses `*_N` variants.
### Deliverables
* `LocalAddressing` utilities
* Deterministic trap codes:
* `TRAP_INVALID_LOCAL`
* `TRAP_LOCAL_WIDTH_MISMATCH` (if enforced)
### Tests
* `let x: int = 1; return x;` works
* invalid local index traps
### Acceptance
* `let` works reliably; no stack side effects beyond specified pops/pushes.
---
## PR-05 — Core arithmetic + comparisons in VM (int/bounded/bool)
**Why:** The minimal executable PBS needs arithmetic that doesn’t corrupt stack.