pr6.3
This commit is contained in:
@@ -1,96 +1,3 @@
|
||||
# PR-6.3 — CALL_CLOSURE (Model B Hidden Arg0)
|
||||
|
||||
## Briefing
|
||||
|
||||
Closures must be dynamically invokable.
|
||||
|
||||
Under Model B, invocation semantics are:
|
||||
|
||||
* The closure object itself becomes hidden `arg0`.
|
||||
* User-supplied arguments become `arg1..argN`.
|
||||
* Captures remain inside the closure and are accessed explicitly.
|
||||
|
||||
---
|
||||
|
||||
## Target
|
||||
|
||||
Introduce opcode:
|
||||
|
||||
`CALL_CLOSURE arg_count`
|
||||
|
||||
Stack before call:
|
||||
|
||||
```
|
||||
[..., argN, ..., arg1, closure_ref]
|
||||
```
|
||||
|
||||
Execution steps:
|
||||
|
||||
1. Pop `closure_ref`.
|
||||
2. Validate object is `ObjectKind::Closure`.
|
||||
3. Pop `arg_count` arguments.
|
||||
4. Read `fn_id` from closure object.
|
||||
5. Create new call frame:
|
||||
|
||||
* Inject `closure_ref` as `arg0`.
|
||||
* Append user arguments as `arg1..argN`.
|
||||
6. Jump to function entry.
|
||||
|
||||
No environment copying into locals.
|
||||
|
||||
---
|
||||
|
||||
## Work Items
|
||||
|
||||
1. Add `CALL_CLOSURE` opcode.
|
||||
2. Implement dispatch logic.
|
||||
3. Integrate with call frame creation.
|
||||
4. Ensure stack discipline is preserved.
|
||||
|
||||
---
|
||||
|
||||
## Acceptance Checklist
|
||||
|
||||
* [ ] CALL_CLOSURE implemented.
|
||||
* [ ] closure_ref validated.
|
||||
* [ ] arg_count respected.
|
||||
* [ ] Hidden arg0 injected correctly.
|
||||
* [ ] Errors thrown on non-closure call.
|
||||
|
||||
---
|
||||
|
||||
## Tests
|
||||
|
||||
1. Closure returning constant.
|
||||
2. Closure capturing value and using it.
|
||||
3. Calling non-closure results in trap.
|
||||
4. Nested closure calls work.
|
||||
|
||||
---
|
||||
|
||||
## Junie Instructions
|
||||
|
||||
You MAY:
|
||||
|
||||
* Modify interpreter call logic.
|
||||
* Add tests.
|
||||
|
||||
You MUST NOT:
|
||||
|
||||
* Change stack model.
|
||||
* Introduce coroutine semantics.
|
||||
* Modify GC.
|
||||
|
||||
If function signature metadata is insufficient to validate arg_count, STOP and ask.
|
||||
|
||||
---
|
||||
|
||||
## Definition of Done
|
||||
|
||||
Closures can be dynamically invoked with hidden arg0 semantics.
|
||||
|
||||
---
|
||||
|
||||
# PR-6.4 — GC Traversal for Closures (Model B)
|
||||
|
||||
## Briefing
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
vamos as PR7s todas em um unico canvas markdown ingles, devem ser auto contidas com briefing, alvo, checklist, test quando necessario e comandos do que a Junie pode ou nao fazer (Junie eh task operator nao arquiteta ou assume nada, questiona quando necessario).
|
||||
|
||||
7 — Coroutines (único modelo de concorrência, cooperativo)
|
||||
|
||||
7.1. Definir objeto Coroutine no heap: stack/frames próprios, status, wake time, mailbox/queue se existir.
|
||||
|
||||
Reference in New Issue
Block a user