Commit Graph

5 Commits

Author SHA1 Message Date
6a4b2d9a33 Fix compile-match: inline clauses via letrec for JIT visibility
compile-match-clauses was a separate define that the JIT VM couldn't
find at runtime ("VM undefined: compile-match-clauses"). Inline it
as a letrec-bound local function inside compile-match so it's
captured in the closure and visible to JIT-compiled code.

1166 passed, 0 failed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:25:39 +00:00
98f74149b2 Add compile-match to bytecode compiler, use match in compile-list
The JIT compiler now handles the match special form, emitting the
same DUP/compare/JUMP_IF_FALSE bytecode pattern as case. Supports
literal patterns (string, number, boolean, nil), _ wildcard, symbol
binding, and quoted symbol patterns.

This fixes the infinite JIT retry loop where compile-list (which
used match for dispatch) couldn't be JIT-compiled, causing
parse-loop to endlessly fall back to CEK evaluation.

1166 passed, 0 failed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:20:30 +00:00
9057f5a42e Revert compiler.sx match conversion — broke JIT compilation
The match special form in compile-list caused JIT-compiled functions
to fail with "Expected number, got symbol" errors, creating an
infinite retry loop in parse-loop. The JIT compiler can't compile
match expressions, so compile-list fell back to CEK on every call.

Revert to the original cond-based dispatch. The evaluator.sx match
conversions are fine (not used by JIT), only the compiler was affected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:13:32 +00:00
8bba02fbc9 Use match for value dispatch in evaluator and compiler
Convert large cond chains doing string equality dispatch to use the
match special form: step-eval-list (42 arms), step-continue (31 arms),
compile-list (30 arms), ho-setup-dispatch (7 arms), value-matches-type?
(10 arms). Also fix test-canonical.sx to use defsuite/deftest format
and load canonical.sx in both test runners.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 07:53:16 +00:00
f3f70cc00b Move stdlib out of spec — clean spec/library boundary
spec/ now contains only the language definition (5 files):
  evaluator.sx, parser.sx, primitives.sx, render.sx, special-forms.sx

lib/ contains code written IN the language (8 files):
  stdlib.sx, types.sx, freeze.sx, content.sx,
  bytecode.sx, compiler.sx, vm.sx, callcc.sx

Test files follow source: spec/tests/ for core language tests,
lib/tests/ for library tests (continuations, freeze, types, vm).

Updated all consumers:
- JS/Python/OCaml bootstrappers: added lib/ to source search paths
- OCaml bridge: spec_dir for parser/render, lib_dir for compiler/freeze
- JS test runner: scans spec/tests/ (always) + lib/tests/ (--full)
- OCaml test runner: scans spec/tests/, lib tests via explicit request
- Docker dev mounts: added ./lib:/app/lib:ro

Tests: 1041 JS standard, 1322 JS full, 1101 OCaml — all pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:18:30 +00:00