Commit Graph

2 Commits

Author SHA1 Message Date
52cb38805a feat: complete evidence threading in C backend
C backend now fully threads evidence through effectful function calls:

- Track effectful functions via effectful_functions HashSet
- Add has_evidence flag to track context during code generation
- Add LuxEvidence* ev parameter to effectful function signatures
- Transform effect operations to use ev->console->print() when evidence available
- Update function calls to pass evidence (ev or &default_evidence)
- Update main entry point to pass &default_evidence

Generated code now uses zero-cost evidence passing:
  void greet_lux(LuxEvidence* ev) {
      ev->console->print(ev->console->env, "Hello!");
  }

This completes the evidence passing implementation for both interpreter
(O(1) HashMap lookup) and C backend (direct function pointer calls).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 11:58:26 -05:00
ce4ab45651 feat: implement evidence passing for O(1) effect handler lookup
Interpreter changes:
- Add evidence HashMap for O(1) handler lookup instead of O(n) stack search
- Update eval_run to manage evidence when entering/exiting run blocks
- Modify handle_effect to use evidence.get() instead of stack iteration

C backend infrastructure:
- Add handler structs (LuxConsoleHandler, LuxStateHandler, LuxReaderHandler)
- Add LuxEvidence struct containing pointers to all handlers
- Add default handlers that delegate to built-in implementations
- Add Console.readLine built-in implementation

Documentation:
- Create docs/EVIDENCE_PASSING.md explaining design and implementation
- Update docs/C_BACKEND.md with current progress

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 11:52:00 -05:00